[lldb-dev] [Bug 48049] New: platform shell doesn't fail if the shell command fails

2020-11-02 Thread via lldb-dev
https://bugs.llvm.org/show_bug.cgi?id=48049

Bug ID: 48049
   Summary: platform shell doesn't fail if the shell command fails
   Product: lldb
   Version: 11.0
  Hardware: PC
OS: Linux
Status: NEW
  Severity: normal
  Priority: P
 Component: All Bugs
  Assignee: lldb-dev@lists.llvm.org
  Reporter: david.spick...@linaro.org
CC: jdevliegh...@apple.com, llvm-b...@lists.llvm.org

In an interactive shell we get all the output you'd expect:
$ ./bin/lldb
(lldb) platform shell not_a_cmd
/bin/bash: not_a_cmd: command not found
error: command returned with status 127

But when using the API (via the test framework) the command is marked as
succeeded even though it failed on the platform:
@no_debug_info_test
+def test_shell_command_failure(self):
+""" Test that the platform shell command passes on command failures"""
+triple = self.dbg.GetSelectedPlatform().GetTriple()
+# TODO: windows/android like above
+self.runCmd("platform shell definitley_not_a_command", check=False)
+self.assertFalse(self.res.Succeeded())

FAIL: test_shell_command_failure (TestPlatformCommand.PlatformCommandTestCase)
Test that the platform shell command passes on command failures
--
Traceback (most recent call last):
  File
"/work/open_source/nightly-llvm/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
line 346, in wrapper
return func(self, *args, **kwargs)
  File
"/work/open_source/nightly-llvm/llvm-project/lldb/test/API/commands/platform/basic/TestPlatformCommand.py",
line 85, in test_shell_command_failure
self.assertFalse(self.res.Succeeded())
AssertionError: True is not False

I can see some logic in saying it's a success because lldb successfully sent
the command text to and from the platform. Whether the command itself was
successful is the user's business. Is that intentional or just how "platform
shell" happens to act?

I initially assumed that a failed shell command would be a failed lldb command.
I couldn't find mention of this in the docs.

The one existing test using SBPlatformCommand is:
API/python_api/sbplatform/TestSBPlatform.py
Which also checks that the command output contains the expected text.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


Re: [lldb-dev] [RFC] Segmented Address Space Support in LLDB

2020-11-02 Thread Pavel Labath via lldb-dev

On 22/10/2020 10:25, Jason Molenda wrote:

Hi Greg, Pavel.

I think it's worth saying that this is very early in this project.  We know 
we're going to need the ability to track segments on addresses, but honestly a 
lot of the finer details aren't clear yet.  It's such a fundamental change that 
we wanted to start a discussion, even though I know it's hard to have detailed 
discussions still.

In the envisioned environment, there will be a default segment, and most 
addresses will be in the default segment.  DWARF, user input (lldb cmdline), SB 
API, and clang expressions are going to be the places where segments are 
specified --- Dump methods and ProcessGDBRemote will be the main place where 
the segments are displayed/used.  There will be modifications to the memory 
read/write gdb RSP packets to include these.

This early in the project, it's hard to tell what will be upstreamed to the 
llvm.org monorepo, or when.  My personal opinion is that we don't actually want 
to add segment support to llvm.org lldb at this point.  We'd be initializing 
every address object with LLDB_INVALID_SEGMENT or LLDB_DEFAULT_SEGMENT, and 
then testing that each object is initialized this way?  I don't see this 
actually being useful.

However, changing lldb's target addresses to be strictly handled in terms of 
objects will allow us to add a segment discriminator ivar to Address and 
ProcessAddress on our local branch while this is in development, and minimize 
the places where we're diverging from the llvm.org sources.  We'll need to have 
local modifications at the places where a segment is input (DWARF, cmdline, SB 
API, compiler type) or output (Dump, ProcesssGDBRemote) and, hopefully, the 
vast majority of lldb can be unmodified.

The proposal was written in terms of what we need to accomplish based on our 
current understanding for this project, but I think there will be a lot of 
details figured out as we get more concrete experience of how this all works.  
And when it's appropriate to upstream to llvm.org, we'll be better prepared to 
discuss the tradeoffs of the approaches we took in extending 
Address/ProcessAddress to incorporate a segment.

My hope is that these generic OO'ification of target addresses will not change 
lldb beyond moving off of addr_t for now.
I think that wrapping addr_t inside a class would be a nice change, even 
without the subsequent segmentification -- I'm hoping that this would 
add some type safety to the way we work with addresses (as we have 
various kinds of addresses that are all just plain ints). I'd like to 
see a concrete proposal for this class's interface though. (And I still 
remain mildly sceptical about automating this transition.)



To be honest, we haven't thought about the UI side of this very much yet.  I 
think there will be ABI or ArchSpec style information that maps segment numbers 
to human-understandable names.


The details of this are pretty interesting for the Wasm use case, as it 
does not have a fixed number of segments/address spaces -- every module 
gets its own address space. I suppose the Wasm ArchSpec could just say 
it has UINT32_MAX address spaces, and then the dynamic loader would just 
assign modules into address spaces based on some key.


The interesting aspect here would be that the DWARF does *not* contain 
address space information here (as it's all in the same address space), 
so there may need to be a way for it to say "I don't actually know my 
address space -- I'll go whereever the dynamic loader puts me".


Still pretty early to determine that, but I'm mentioning this as it is 
the last use case of someone needing address space support in lldb (even 
though it's a slightly stranger form of address spaces).


pl
___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev