Commit Graph

22751 Commits

Author SHA1 Message Date
Jonas Devlieghere e5bb542362 [lldb/Test] Import all decorators.
Fixes "NameError: name 'skipIfReproducer' is not defined".
2020-05-27 21:13:08 -07:00
Jonas Devlieghere 5238b80058 [lldb/Reproducers] Skip or fix the remaining tests.
After this patch all remaining tests should pass on macOS when replayed
from a reproducer.

To capture the reproducers:

  ./bin/llvm-lit ../llvm-project/lldb/test/ --param lldb-run-with-repro=capture

To replay the reproducers:

  ./bin/llvm-lit ../llvm-project/lldb/test/ --param lldb-run-with-repro=replay
2020-05-27 21:02:36 -07:00
Adrian Prantl a57a67c59b Fix a use-after-free in GetXcodeSDKPath
Introduced in https://reviews.llvm.org/D80595. Thanks Jonas for noticing!

Differential Revision: https://reviews.llvm.org/D80666
2020-05-27 14:27:16 -07:00
Jonas Devlieghere f9bea9bc4a [lldb/Reproducers] Skip & add FIXME to tests failing with unexpected packet.
Add skip decorator to tests failing with an unexpected packet during
passive replay.
2020-05-27 13:52:48 -07:00
Jonas Devlieghere 5f97a540ad [lldb/Reproducers] Differentiate active and passive replay unexpected packet. 2020-05-27 13:52:38 -07:00
Adrian Prantl 3345521507 Also cache negative results in GetXcodeSDKPath (NFC)
This fixes a performance issue in the failure case.

rdar://63547920

Differential Revision: https://reviews.llvm.org/D80595
2020-05-27 12:26:04 -07:00
Jonas Devlieghere c30c2368c7 [lldb/Reproducers] Skip tests relying on timeouts
The reproducer don't model timeouts so tests that rely on them end up
with unexpected packets during replay. Skip them until we can handle
this scenario.
2020-05-27 12:08:41 -07:00
Jonas Devlieghere fe9d8442e0 [lldb/Test] Generate YAML binary in build directory
Although it's not entirely clear to me why, this test was generating its
binary in the source directory instead of the build directory. This
patch fixes that following the same approach as other tests.
2020-05-27 12:08:41 -07:00
Jonas Devlieghere e7f1067ad6 [lldb/Reproducers] Skip API logging in the DUMMY macro
The purpose of the LLDB_RECORD_DUMMY macro is twofold: it is used in
functions that take arguments that we don't know how to serialize (e.g.
void*) and it's used by function where we want to avoid doing excessive
work because they can be called from a signal handler (e.g.
setTerminalWidth).

To support the latter case, I've disabled API logging form the Recorder
ctor used by the DUMMY macro. This ensures we don't allocate memory when
called from a signal handler.
2020-05-27 10:35:43 -07:00
Raphael Isemann 74a51753a6 [lldb] Make order of completions for expressions deterministic and sorted by Clang's priority values.
Summary:

It turns out that the order in which we provide completions for expressions is
nondeterministic. This leads to confusing user experience and also breaks the
reproducer tests (as two LLDB tests can go out of sync due to the
non-determinism in the completion lists)

The reason for the non-determinism is that the CompletionConsumer informs us
about decls in the order in which it finds declarations in the lookup store of
the DeclContexts it visits (mainly this snippet in SemaLookup.cpp):

``` lang=c++
    // Enumerate all of the results in this context.
    for (DeclContextLookupResult R :
         Load ? Ctx->lookups()
              : Ctx->noload_lookups(/*PreserveInternalState=*/false)) {
       [...]
```

This storage of the lookup is sorted by pointer values (see the hash of
`DeclarationName`) and can therefore be non-deterministic. The LLDB code
completion consumer that receives these calls originally expected that the order
of declarations is defined by Clang, but it seems the API expects the client to
provide an order to the completions.

This patch fixes the issue as follows:

* We sort the completions we get from Clang alphabetically and also by the
priority value we get from Clang (with priority value sorting having precedence
over the alphabetical sorting)

* We make all the functions/variables that touch a completion before the sorting
const-qualified. The idea is that this should prevent that we never have
observable side-effect from touching these declarations in a non-deterministic
order (e.g., we don't try to complete the type by accident).

This way we behave like the other parts of Clang which also sort the results by
some deterministic value (usually the name or something computed from a name,
e.g., edit distance to a given string).

We most likely also need to fix the Clang code to make the loop I listed above
deterministic to prevent these issues in the future (tracked in rdar://63442513
). This wouldn't replace the functionality provided in this patch though as we
would still need the priority and overall alphabetical sorting.

Note: I had to increase the lldb-vscode completion limit to 100 as the tests
look for strings that aren't in the first 50 results anymore due to variable
names starting with letters like 'v' (which are now always shown much further
down in the list due to the alphabetical sorting).

Fixes rdar://63200995

Reviewers: JDevlieghere, clayborg

Reviewed By: JDevlieghere

Subscribers: mgrang, abidh

Differential Revision: https://reviews.llvm.org/D80292
2020-05-27 19:22:01 +02:00
Gongyu Deng 763bc23057 [lldb] Tab completion for process plugin name
Summary:

1. Added tab completion to `process launch -p`, `process attach -P`, `process
connect -p`;

2. Bound the plugin name common completion as the default completion for
`eArgTypePlugin` arguments.

Reviewers: teemperor, JDevlieghere

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79929
2020-05-27 14:11:16 +02:00
Raphael Isemann 18bb1f1067 [lldb] Fix a potential bug that may cause assert failure in CommandObject::CheckRequirements
Summary: `CommandObject::CheckRequirements` requires cleaning up `m_exe_ctx`
between commands. Function `HandleOptionCompletion` returns without cleaning up
`m_exe_ctx` could cause assert failure in later `CheckRequirements`.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D80447
2020-05-27 14:05:17 +02:00
Raphael Isemann 019bd6485c [lldb] Don't complete ObjCInterfaceDecls in ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName
Summary:
For ObjCInterfaceDecls, LLDB iterates over the `methods` of the interface in FindExternalVisibleDeclsByName
since commit ef423a3ba5 .
However, when LLDB calls `oid->methods()` in that function, Clang will pull in all declarations in the current
DeclContext from the current ExternalASTSource (which is again, `ClangExternalASTSourceCallbacks`). The
reason for that is that `methods()` is just a wrapper for `decls()` which is supposed to provide a list of *all*
(both currently loaded and external) decls in the DeclContext.

However, `ClangExternalASTSourceCallbacks::FindExternalLexicalDecls` doesn't implement support for ObjCInterfaceDecl,
so we don't actually add any declarations and just mark the ObjCInterfaceDecl as having no ExternalLexicalStorage.

As LLDB uses the ExternalLexicalStorage to see if it can complete a type with the ExternalASTSource, this causes
that LLDB thinks our class can't be completed any further by the ExternalASTSource
and will from on no longer make any CompleteType/FindExternalLexicalDecls calls to that decl. This essentially
renders those types unusable in the expression parser as they will always be considered incomplete.

This patch just changes the call to `methods` (which is just a `decls()` wrapper), to some ad-hoc `noload_methods`
call which is wrapping `noload_decls()`. `noload_decls()` won't trigger any calls to the ExternalASTSource, so
this prevents that ExternalLexicalStorage will be set to false.

The test for this is just adding a method to an ObjC interface. Before this patch, this unset the ExternalLexicalStorage
flag and put the interface into the state described above.

In a normal user session this situation was triggered by setting a breakpoint in a method of some ObjC class. This
caused LLDB to create the MethodDecl for that specific method and put it into the the ObjCInterfaceDecl.
Also `ObjCLanguageRuntime::LookupInCompleteClassCache` needs to be unable to resolve the type do
an actual definition when the breakpoint is set (I'm not sure how exactly this can happen, but we just
found no Type instance that had the `TypePayloadClang::IsCompleteObjCClass` flag set in its payload in
the situation where this happens. This however doesn't seem to be a regression as logic wasn't changed
from what I can see).

The module-ownership.mm test had to be changed as the only reason why the ObjC interface in that test had
it's ExternalLexicalStorage flag set to false was because of this unintended side effect. What actually happens
in the test is that ExternalLexicalStorage is first set to false in `DWARFASTParserClang::CompleteTypeFromDWARF`
when we try to complete the `SomeClass` interface, but is then the flag is set back to true once we add
the last ivar of `SomeClass` (see `SetMemberOwningModule` in `TypeSystemClang.cpp` which is called
when we add the ivar). I'll fix the code for that in a follow-up patch.

I think some of the code here needs some rethinking. LLDB and Clang shouldn't infer anything about the ExternalASTSource
and its ability to complete the current type form the `ExternalLexicalStorage` flag. We probably should
also actually provide any declarations when we get asked for the lexical decls of an ObjCInterfaceDecl. But both of those
changes are bigger (and most likely would cause us to eagerly complete more types), so those will be follow up patches
and this patch just brings us back to the state before commit ef423a3ba5 .

Fixes rdar://63584164

Reviewers: aprantl, friss, shafik

Reviewed By: aprantl, shafik

Subscribers: arphaman, abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D80556
2020-05-27 12:39:24 +02:00
Jonas Devlieghere 40c4ecabc2 [lldb/Docs] Add the application speicfic lldbinit to the man page
This used to be part of the man page but got lost when we moved to
generating it with Sphinx.
2020-05-26 17:34:09 -07:00
Alex Langford 1079978b3c [lldb][Core] Remove dead codepath in Mangled
Summary:
Objective-C names are stored in m_demangled, not in m_mangled. The
method in the condition will never return true.

Differential Revision: https://reviews.llvm.org/D79823
2020-05-26 17:12:20 -07:00
Jonas Devlieghere e724db0375 [lldb/Test] Modify TestSymbolTable.py for reproducers
Work around global module caching during reproducer replay. See inline
comment for the details.
2020-05-26 17:07:41 -07:00
Vedant Kumar 6e39379bbb [DwarfExpression] Support entry values for indirect parameters
Summary:
A struct argument can be passed-by-value to a callee via a pointer to a
temporary stack copy. Add support for emitting an entry value DBG_VALUE
when an indirect parameter DBG_VALUE becomes unavailable. This is done
by omitting DW_OP_stack_value from the entry value expression, to make
the expression describe the location of an object.

rdar://63373691

Reviewers: djtodoro, aprantl, dstenb

Subscribers: hiraditya, lldb-commits, llvm-commits

Tags: #lldb, #llvm

Differential Revision: https://reviews.llvm.org/D80345
2020-05-26 14:22:28 -07:00
Adrian Prantl 09de6e0fbd Let @skipUnlessAddressSanitizer imply @skipIfAsan
Don't run tests that use address sanitizer inside an address-sanitized
LLDB. The tests don't support that configuration. Incidentally they
were skipped on green dragon for a different reason, so this hasn't
come up there before.
2020-05-26 13:51:08 -07:00
Jonas Devlieghere e1d2cecec5 [lldb/Test] Cleanup TestSymbolTable.py (NFC) 2020-05-26 13:17:43 -07:00
Jonas Devlieghere ae903f0313 [lldb/Test] Reinstate FoundationSymtabTestCase 2020-05-26 12:14:42 -07:00
Eric Christopher 713538b629 Be more specific about auto * vs auto for po alias. 2020-05-26 11:59:09 -07:00
Jonas Devlieghere 8d31dd23ec [lldb/Reproducers] Skip remaining failing test in python_api subdir
Skip the remaining two failing test in the python_api subdirectory. See
inline comments for the reason why.
2020-05-26 11:23:52 -07:00
Jonas Devlieghere d1f0a76b21 [YAMLTraits] Remove char trait and serialize as uint8_t in lldb.
As discussed in https://reviews.llvm.org/D79745
2020-05-26 11:07:27 -07:00
Pavel Labath c34936dae7 [lldb] s/dyn_cast/isa
The cast result is unused and produces a warning with gcc.
2020-05-26 09:21:54 +02:00
Jonas Devlieghere b321b42941 [lldb/Test] Add a trace method to replace print statements.
Many tests use (commented out) print statement for debugging the test
itself. This patch adds a new trace method to lldbtest to reuse the
existing tracing infrastructure and replace these print statements.

Differential revision: https://reviews.llvm.org/D80448
2020-05-25 11:11:46 -07:00
Pavel Labath ba03bcbc4a [lldb] Remove custom DWARF expression printing code
The llvm DWARFExpression dump is nearly identical, but better -- for
example it does print a spurious space after zero-argument expressions.

Some parts of our code (variable locations) have been already switched
to llvm-based expression dumping. This switches the remainder: unwind
plans and some unit tests.
2020-05-25 16:09:25 +02:00
Raphael Isemann fe22e5689e [lldb][NFC] Pass DeclarationName to NameSearchContext by value
DeclarationName is usually passed around by value as it's just a pointer.
2020-05-25 12:37:22 +02:00
Jaroslav Sevcik 83bd2c4a06 Prevent GetNumChildren from transitively walking pointer chains
Summary:

This is an attempt to fix https://bugs.llvm.org/show_bug.cgi?id=45988,
where SBValue::GetNumChildren returns 2, but SBValue::GetChildAtIndex(1) returns
an invalid value sentinel.

The root cause of this seems to be that GetNumChildren can return the number of
children of a wrong value. In particular, for pointers GetNumChildren just
recursively calls itself on the pointee type, so it effectively walks chains of
pointers. This is different from the logic of GetChildAtIndex, which only
recurses if pointee.IsAggregateType() returns true (IsAggregateType is false for
pointers and references), so it never follows chain of pointers.

This patch aims to make GetNumChildren (more) consistent with GetChildAtIndex by
only recursively calling GetNumChildren for aggregate types.

Ideally, GetNumChildren and GetChildAtIndex would share the code that decides
which pointers/references are followed, but that is a bit more invasive change.

Reviewers: teemperor, jingham, clayborg

Reviewed By: teemperor, clayborg

Subscribers: clayborg, labath, shafik, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D80254
2020-05-25 11:30:22 +02:00
Jonas Devlieghere c3116182c8 Revert "[lldb/Interpreter] Fix another eExpressionThreadVanished warning"
This reverts commit f2ffa33c79. My local
checkout was behind and Eric already took care of it in the meantime.
2020-05-23 13:37:46 -07:00
Jonas Devlieghere f2ffa33c79 [lldb/Interpreter] Fix another eExpressionThreadVanished warning
Fixes warning: enumeration value 'eExpressionThreadVanished' not handled
in switch [-Wswitch] in CommandInterpreter.cpp.
2020-05-23 13:27:31 -07:00
Adrian Prantl a8a048ac72 Restrict test for DW_AT_APPLE_optimized to Darwin 2020-05-22 15:52:00 -07:00
Adrian Prantl 220c17ffd4 Print a warning when stopped in a frame LLDB has no plugin for.
This patchs adds an optional warning that is printed when stopped at a
frame that was compiled in a source language that LLDB has no plugin
for.

The motivational use-case is debugging Swift code on Linux. When the
user accidentally invokes the system LLDB that was built without the
Swift plugin, it is very much non-obvious why debugging doesnt
work. This warning makes it easy to figure out what went wrong.

<rdar://problem/56986569>
2020-05-22 15:37:36 -07:00
Eric Christopher 7510aede62 Handle eExpressionThreadVanished in error switch to handle
covered switch warning.
2020-05-22 13:43:10 -07:00
Jonas Devlieghere a67b2faa7c [lldb/Test] Disable APITests.exe on Windows
The generated binary (APITests.exe) is not a valid googletest binary. I
suspect it has something to do with us linking against liblldb.
2020-05-22 13:07:10 -07:00
Jonas Devlieghere 5a85582eb2 [lldb/Reproducers] Make the type tests work with reproducers 2020-05-22 13:07:10 -07:00
Raphael Isemann 8cb7574541 Revert "[lldb] Enable C++14 when evaluating expressions in a C++14 frame"
This reverts commit 5f88f39ab8. It broke these
three tests on the Window bot:
  lldb-api :: commands/expression/completion/TestExprCompletion.py
  lldb-api :: lang/cpp/scope/TestCppScope.py
  lldb-api :: lang/cpp/standards/cpp11/TestCPP11Standard.py
2020-05-22 21:23:03 +02:00
Jonas Devlieghere d89c98a020 [lldb/Test] Remove issue_verification subdirectory
These files haven't been touched since 2015. According to Pavel these
were intended to be test for the test framework which never really took
of and are mostly irrelevant by now.

Differential revision: https://reviews.llvm.org/D80408
2020-05-22 09:32:12 -07:00
Pavel Labath 053b0634ea [lldb] Increase timeout in TestExitDuringExpression
200 microseconds is not enough time for any expression to execute
reliably. On linux, calling pthread_exit can result in call to dlopen,
which cannot complete in that time, particularly when running under a
debugger.

On linux, this test failed all the time, on macos, about two thirds of
runs were failing.  This patch increases the timeout to 100ms, which is
enough to get it passing reliably on linux, though I wouldn't be
surprised if an even bigger timeout would be needed for remote test
runs.
2020-05-22 12:47:34 +02:00
Raphael Isemann 5f88f39ab8 [lldb] Enable C++14 when evaluating expressions in a C++14 frame
Summary:
Currently we never enable C++14 in the expression evaluator. This enables it when the language of the program is C++14.

It seems C++17 and so on isn't yet in any of the language enums (and the DWARF standard it seems), so C++17 support will be a follow up patch.

Reviewers: labath, JDevlieghere

Reviewed By: labath, JDevlieghere

Subscribers: aprantl

Differential Revision: https://reviews.llvm.org/D80308
2020-05-22 11:42:44 +02:00
Raphael Isemann bca378f68a [lldb][NFC] Overload raw_ostream operator << for ConstString
Summary: We are not doing this very often, but sometimes it's convenient when I can just << ConstStrings into llvm::errs() during testing.

Reviewers: labath, JDevlieghere

Reviewed By: labath, JDevlieghere

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D80310
2020-05-22 11:24:48 +02:00
Jonas Devlieghere 8a6333ef38 [lldb/REPL] Fix unhandled switch case
Fix warning: enumeration value 'eExpressionThreadVanished' not handled
in switch [-Wswitch]
2020-05-21 23:22:17 -07:00
Jonas Devlieghere 329abed10b [lldb/Reproducers] Skip test that changes the source file while debugging
The VFS is a snapshot and cannot capture changes to the file system.
2020-05-21 20:36:39 -07:00
Jonas Devlieghere e3a0283e5a [lldb/Test] Fix replay with TestSetWatchpoint.py
The reproducers only track the creation of objects and not their
destruction. Therefore it keeps all objects alive indefinitely.
2020-05-21 20:35:32 -07:00
Jim Ingham 54c2c2add7 Maybe I need ENABLE_THREADS in the Makefile. 2020-05-21 18:38:49 -07:00
Jim Ingham 1583766ed2 This very simple .c file is failing on the Debian bot wit the error
undefined reference to pthread_create

I skipped the test till I can figure out why this didn't build.
2020-05-21 18:26:01 -07:00
Jim Ingham dbbed971e3 Handle the case where a thread exits while we are running a function on it. 2020-05-21 17:55:53 -07:00
Jonas Devlieghere 9e391d4faa [lldb/Test] Cleanup TestSymbolContext.py
Remove commented out code, fix the indentation and always use the full
path to the executable. The latter is necessary for the test to pass
from reproducer replay.
2020-05-21 17:32:05 -07:00
Jonas Devlieghere 1d64d69ab7 [lldb/Reproducers] Skip lldb-vscode category when lldb-run-with-repro is set.
This skips all the lldb-vscode tests when running the test suite with
reproducers.
2020-05-21 17:02:04 -07:00
Adrian Prantl e6b613254d Rename FunctionOptimizationWarning to the more generic FrameSelectedCallback (NFC) 2020-05-21 16:22:01 -07:00
Adrian Prantl 60dff35fd4 Move decorator to the correct function. 2020-05-21 10:42:26 -07:00