Commit Graph

2474 Commits

Author SHA1 Message Date
Jonas Devlieghere 2bc38ab3d0 [lldb/Breakpoint] Recogize hardware breakpoints as such
Recognize hardware breakpoints as breakpoints instead of just mach
exceptions. The mach exception is the same for watch and breakpoints, so
we have to try each to figure out which is which.

Differential revision: https://reviews.llvm.org/D73401
2020-01-24 19:24:25 -08:00
Jonas Devlieghere 96f3ea0d21 [lldb/debugserver] Implement hardware breakpoints for x86_64 and i386
This implements hardware breakpoints for x86_64 and i386 in debugserver.
It's based on Pedro's patch sent to lldb-commits [1] although most of it
is the same as the existing hardware watchpoint implementation.

[1] http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20200113/060327.html

Differential revision: https://reviews.llvm.org/D72985
2020-01-24 15:07:31 -08:00
Pavel Labath 77cedb0cdb [lldb] Fix nondeterminism in TestCppBitfields
The test was printing a char[3] variable without a terminating nul. The
memory after that variable (an unnamed bitfield) was not initialized. If
the memory happened to be nonzero, the summary provider for the variable
would run off into the next field.

This is probably not the right behavior (it should stop at the end of
the array), but this is not the purpose of this test. I have filed
pr44649 for this bug, and fixed the test to not depend on this behavior.
2020-01-24 12:09:20 +01:00
shafik fcaf5f6c01 [LLDB] Fix the handling of unnamed bit-fields when parsing DWARF
We ran into an assert when debugging clang and performing an expression on a class derived from DeclContext. The assert was indicating we were getting the offsets wrong for RecordDeclBitfields. We were getting both the size and offset of unnamed bit-field members wrong. We could fix this case with a quick change but as I extended the test suite to include more combinations we kept finding more cases that were being handled incorrectly. A fix that handled all the new cases as well as the cases already covered required a refactor of the existing technique.

Differential Revision: https://reviews.llvm.org/D72953
2020-01-23 14:46:24 -08:00
Jim Ingham 29c7e6c8c9 Clang added a new feature to the ObjC compiler that will translate method
calls to commonly un-overridden methods into a function that checks whether
the method is overridden anywhere and if not directly dispatches to the
NSObject implementation.

That means if you do override any of these methods, "step-in" will not step
into your code, since we hit the wrapper function, which has no debug info,
and immediately step out again.

Add code to recognize these functions as "trampolines" and a thread plan that
will get us from the function to the user code, if overridden.

<rdar://problem/54404114>

Differential Revision: https://reviews.llvm.org/D73225
2020-01-23 12:41:14 -08:00
Raphael Isemann 6e3b0cc2fb [lldb][NFC] Rename ClangASTContext to TypeSystemClang
Summary:
This commit renames ClangASTContext to TypeSystemClang to better reflect what this class is actually supposed to do
(implement the TypeSystem interface for Clang). It also gets rid of the very confusing situation that we have both a
`clang::ASTContext` and a `ClangASTContext` in clang (which sometimes causes Clang people to think I'm fiddling
with Clang's ASTContext when I'm actually just doing LLDB work).

I also have plans to potentially have multiple clang::ASTContext instances associated with one ClangASTContext so
the ASTContext naming will then become even more confusing to people.

Reviewers: #lldb, aprantl, shafik, clayborg, labath, JDevlieghere, davide, espindola, jdoerfert, xiaobai

Reviewed By: clayborg, labath, xiaobai

Subscribers: wuzish, emaste, nemanjai, mgorny, kbarton, MaskRay, arphaman, jfb, usaxena95, jingham, xiaobai, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72684
2020-01-23 10:09:14 +01:00
Davide Italiano f55b033c02 [TestStdModuleSysroot] Only run locally. 2020-01-22 13:56:51 -08:00
Jim Ingham 89c8866c04 Convert AssertTrue( A == B) to AssertEqual(A, B) in TestObjCStepping.py. 2020-01-22 13:20:15 -08:00
Pavel Labath 0157a74bec [lldb] Fix an asan error from 27df2d9f55
This error is caused by a combination of a couple of factors:
- the test accidentally creating a list with a single (empty) FileSpec
  instead of an empty list
- lldb overzeleously converting empty strings into nullptrs
- asan overzeleously validating symlink(2) arguments (the real symlink
  call would just fail with EFAULT)

I fix this by using FileSpec::GetPath instead of GetCString. This avoids
the nullptr and also avoids inserting the path into the global string
pool.

I also enhance the test case to test both empty paths and empty lists.
2020-01-22 10:14:47 +01:00
Adrian Prantl fa001767f0 Fix typos 2020-01-21 15:32:34 -08:00
Fred Riss 0478eadf73 [lldb/DataFormatters] Fix the `$$deference$$` synthetic child
Summary:
The ValueObject code checks for a special `$$dereference$$` synthetic
child to allow formatter providers to implement a natural
dereferencing behavior in `frame variable` for objects like smart
pointers.

This support was broken when used directly throught the Python API and
not trhough `frame variable`. The reason is that
SBFrame.FindVariable() will return by default the synthetic variable
if it exists, while `frame variable` will not do this eagerly. The
code in `ValueObject::Dereference()` accounted for the latter but not
for the former. The fix is trivial. The test change includes
additional covergage for the already-working bahevior as it wasn't
covered by the testsuite before.

This commit also adds a short piece of documentatione explaining that
it is possible (even advisable) to provide this synthetic child
outstide of the range of the normal children.

Reviewers: jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73053
2020-01-21 13:35:55 -08:00
Daniel Kiss 95116c591f [lldb] Add a setting to not install the main executable
Summary:
Add setting target.auto-install-main-executable that controls whether
the main executable should be automatically installed when connected to
a remote platform even if it does not have an explicit install path
specified. The default is true as the current behaviour.

Reviewers: omjavaid, JDevlieghere, srhines, labath, clayborg

Reviewed By: clayborg

Subscribers: kevin.brodsky, lldb-commits, llvm-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71761
2020-01-21 19:26:18 +00:00
Francesco Petrogalli 9bb11785dc Revert "[lldb] Add a setting to not install the main executable"
The commit has been reverted as it does not mention the author of the
patch.

This reverts commit 7c9bcba644.
2020-01-21 19:24:02 +00:00
Francesco Petrogalli 7c9bcba644 [lldb] Add a setting to not install the main executable
Summary:
Add setting target.auto-install-main-executable that controls whether
the main executable should be automatically installed when connected to
a remote platform even if it does not have an explicit install path
specified. The default is true as the current behaviour.

Reviewers: omjavaid, JDevlieghere, srhines, labath, clayborg

Reviewed By: clayborg

Subscribers: kevin.brodsky, lldb-commits, llvm-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71761
2020-01-21 19:06:44 +00:00
Jonas Devlieghere 04de24e690 [lldb/IOHandler] Improve synchronization between IO handlers.
The way the IO handlers are currently managed by the debugger is wrong. The
implementation lacks proper synchronization between RunIOHandlerSync and
RunIOHandlers. The latter is meant to be run by the "main thread", while the
former is meant to be run synchronously, potentially from a different thread.

Imagine a scenario where RunIOHandlerSync is called from a different thread
than RunIOHandlers. Both functions manipulate the debugger's IOHandlerStack.
Although the push and pop operations are synchronized, the logic to activate,
deactivate and run IO handlers is not.

While investigating PR44352, I noticed some weird behavior in the Editline
implementation. One of its members (m_editor_status) was modified from another
thread. This happened because the main thread, while running RunIOHandlers
ended up execution the IOHandlerEditline created by the breakpoint callback
thread. Even worse, due to the lack of synchronization within the IO handler
implementation, both threads ended up executing the same IO handler.

Most of the time, the IO handlers don't need to run synchronously. The
exception is sourcing commands from external files, like the .lldbinit file.

I've added a (recursive) mutex to prevent another thread from messing with the
IO handlers wile another thread is running one synchronously. It has to be
recursive, because we might have to source another file when encountering a
command source in the original file.

Differential revision: https://reviews.llvm.org/D72748
2020-01-20 11:17:55 -08:00
Raphael Isemann 65bab53afb [lldb][NFC] Add test for iterator invalidation during code completion. 2020-01-20 15:01:39 +01:00
Raphael Isemann 22447a61d4 [lldb] Mark the implicit copy constructor as deleted when a move constructor is provided.
Summary:
CXXRecordDecls that have a move constructor but no copy constructor need to
have their implicit copy constructor marked as deleted (see C++11 [class.copy]p7, p18)
Currently we don't do that when building an AST with ClangASTContext which causes
Sema to realise that the AST is malformed and asserting when trying to create an implicit
copy constructor for us in the expression:
```
Assertion failed: ((data().DefaultedCopyConstructorIsDeleted || needsOverloadResolutionForCopyConstructor())
    && "Copy constructor should not be deleted"), function setImplicitCopyConstructorIsDeleted, file include/clang/AST/DeclCXX.h, line 828.
```

In the test case there is a class `NoCopyCstr` that should have its copy constructor marked as
deleted (as it has a move constructor). When we end up trying to tab complete in the
`IndirectlyDeletedCopyCstr` constructor, Sema realises that the `IndirectlyDeletedCopyCstr`
has no implicit copy constructor and tries to create one for us. It then realises that
`NoCopyCstr` also has no copy constructor it could find via lookup. However because we
haven't marked the FieldDecl as having a deleted copy constructor the
`needsOverloadResolutionForCopyConstructor()` returns false and the assert fails.
`needsOverloadResolutionForCopyConstructor()` would return true if during the time we
added the `NoCopyCstr` FieldDecl to `IndirectlyDeletedCopyCstr` we would have actually marked
it as having a deleted copy constructor (which would then mark the copy constructor of
`IndirectlyDeletedCopyCstr ` as needing overload resolution and Sema is happy).

This patch sets the correct mark when we complete our CXXRecordDecls (which is the time when
we know whether a copy constructor has been declared). In theory we don't have to do this if
we had a Sema around when building our debug info AST but at the moment we don't have this
so this has to do the job for now.

Reviewers: shafik

Reviewed By: shafik

Subscribers: aprantl, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72694
2020-01-20 14:34:07 +01:00
Pavel Labath 27df2d9f55 [lldb] Don't process symlinks deep inside DWARFUnit
Summary:
This code is handling debug info paths starting with /proc/self/cwd,
which is one of the mechanisms people use to obtain "relocatable" debug
info (the idea being that one starts the debugger with an appropriate
cwd and things "just work").

Instead of resolving the symlinks inside DWARFUnit, we can do the same
thing more elegantly by hooking into the existing Module path remapping
code. Since llvm::DWARFUnit does not support any similar functionality,
doing things this way is also a step towards unifying llvm and lldb
dwarf parsers.

Reviewers: JDevlieghere, aprantl, clayborg, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71770
2020-01-20 13:05:00 +01:00
Jonas Devlieghere f78f15a60e [lldb/Test] XFAIL TestRequireHWBreakpoints when HW BPs are avialable
Resolves PR44055
2020-01-18 13:15:44 -08:00
Fred Riss 546f8f4264 [lldb/testsuite] Modernize 2 test Makefiles
Those old Makefiles used completely ad-hoc rules for building files,
which means they didn't obey the test harness' variants.

They were somewhat tricky to update as they use very peculiar build
flags for some files. For this reason I was careful to compare the
build commands before and after the change, which is how I found the
discrepancy fixed by the previous commit.

While some of the make syntax used here might not be easy to grasp for
newcomers (per-target variable overrides), it seems better than to
have to repliacte the Makefile.rules logic for the test variants and
platform support.
2020-01-17 20:56:28 -08:00
Fred Riss 509b78883d [lldb/Makefile.rules] Force the default target to be 'all'
The test harness invokes the test Makefiles with an explicit 'all'
target, but it's handy to be able to recursively call Makefile.rules
without speficying a goal.

Some time ago, we rewrote some tests in terms of recursive invocations
of Makefile.rules. It turns out this had an unintended side
effect. While using $(MAKE) for a recursive invocation passes all the
variables set on the command line down, it doesn't pass the make
goals. This means that those recursive invocations would invoke the
default rule. It turns out the default rule of Makefile.rules is not
'all', but $(EXE). This means that ti would work becuase the
executable is always needed, but it also means that the created
binaries would not follow some of the other top-level build
directives, like MAKE_DSYM.

Forcing 'all' to be the default target seems easier than making sure
all the invocations are correct going forward. This patch does this
using the .DEFAULT_GOAL directive rather than hoisting the 'all' rule
to be the first one of the file. It seems like this explicit approach
will be less prone to be broken in the future. Hopefully all the make
implementations we use support it.
2020-01-17 20:34:16 -08:00
Davide Italiano c1bc094f36 [TestQuoting] Use the fully qualified path for remote platforms.
Patch by Jason Molenda, fixes a test failure on arm64 devices.
2020-01-17 10:57:35 -08:00
Raphael Isemann 5ac610668a [lldb] Re-add NSDate formatter
This test had been overwritten by accident in ff75262f70.
This just readds the test with the correct content.
2020-01-17 08:56:05 +01:00
Vedant Kumar 6c4d377334 lldb: xfail TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on arm/aarch64
This effectively reverts commit
8d2f252bb8, which went a bit too far and
disabled these on all non-Darwin systems.
2020-01-16 14:48:51 -08:00
Jonas Devlieghere 5f8e412188 [lldb/test] Exted test for CMTime data formatter
Cover more cases handled by the formatter.
2020-01-16 11:58:34 -08:00
Raphael Isemann 81eaa3ddd0 [lldb][NFC] Delete TestDataFormatterObjCNSDate.py
This test is just TestDataFormatterObjCNSData.py copied but without any changes
(and it therefore doesn't even test NSDate).

It's also failing as NSData has been changed by me in
4f244bba4f.
2020-01-16 17:28:07 +01:00
Pavel Labath 15a6df52ef [lldb/DWARF/test] Freshen up debug_names tests
These tests used "clang -mllvm -accel-tables=Dwarf" as a way to
guarantee that clang will emit the debug_names table. Unfortunately,
a change it clang made that insufficient (-gpubnames is required now
too), which rendered these tests ineffective. Since lldb automatically
falls back to the manual index, the tests didn't fail and this change
went largely unnoticed.

This patch updates the tests to really use debug_names (-gdwarf-5
-gpubnames) is the combination that works now, and it adds additional
checks to ensure the section is actually emitted.

Fortunately, no regressions crept in while these tests were disabled.
2020-01-16 16:25:49 +01:00
Raphael Isemann 39d6b6c21f [lldb][NFC] Migrate several tests to expect_expr
expect_expr is the stricter and safer way of testing these expressions.
2020-01-16 13:45:30 +01:00
Raphael Isemann 4f244bba4f [lldb] Fix asan failures in data-formatter-objc tests
The test is currently failing on some systems with ASAN enabled due to:
```
==22898==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000003da4 at pc 0x00010951c33d bp 0x7ffee6709e00 sp 0x7ffee67095c0
READ of size 5 at 0x603000003da4 thread T0
    #0 0x10951c33c in wrap_memmove+0x16c (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x1833c)
    #1 0x7fff4a327f57 in CFDataReplaceBytes+0x1ba (CoreFoundation:x86_64+0x13f57)
    #2 0x7fff4a415a44 in __CFDataInit+0x2db (CoreFoundation:x86_64+0x101a44)
    #3 0x1094f8490 in main main.m:424
    #4 0x7fff77482084 in start+0x0 (libdyld.dylib:x86_64+0x17084)
0x603000003da4 is located 0 bytes to the right of 20-byte region [0x603000003d90,0x603000003da4)
allocated by thread T0 here:
    #0 0x109547c02 in wrap_calloc+0xa2 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x43c02)
    #1 0x7fff763ad3ef in class_createInstance+0x52 (libobjc.A.dylib:x86_64+0x73ef)
    #2 0x7fff4c6b2d73 in NSAllocateObject+0x12 (Foundation:x86_64+0x1d73)
    #3 0x7fff4c6b5e5f in -[_NSPlaceholderData initWithBytes:length:copy:deallocator:]+0x40 (Foundation:x86_64+0x4e5f)
    #4 0x7fff4c6d4cf1 in -[NSData(NSData) initWithBytes:length:]+0x24 (Foundation:x86_64+0x23cf1)
    #5 0x1094f8245 in main main.m:404
    #6 0x7fff77482084 in start+0x0 (libdyld.dylib:x86_64+0x17084)
```

The reason is that we create a string "HELLO" but get the size wrong (it's 5 bytes instead
of 4). Later on we read the buffer and pretend it is 5 bytes long, causing an OOB read
which ASAN detects.

In general this test probably needs some cleanup as it produces on macOS 10.15 around
100 compiler warnings which isn't great, but let's first get the bot green.
2020-01-16 09:59:07 +01:00
Vedant Kumar 8d2f252bb8 lldb: Run TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on Darwin only
See https://bugs.llvm.org/show_bug.cgi?id=44561, these tests are failing
on an aarch64/Linux bot:

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/655

For some reason the backtrace the tests are expecting to find is
incomplete.
2020-01-15 14:00:05 -08:00
Vedant Kumar f0120556c7 [DWARF] Emit DW_AT_call_return_pc as an address
This reverts D53469, which changed llvm's DWARF emission to emit
DW_AT_call_return_pc as a function-local offset. Such an encoding is not
compatible with post-link block re-ordering tools and isn't standards-
compliant.

In addition to reverting back to the original DW_AT_call_return_pc
encoding, teach lldb how to fix up DW_AT_call_return_pc when the address
comes from an object file pointed-to by a debug map. While doing this I
noticed that lldb's support for tail calls that cross a DSO/object file
boundary wasn't covered, so I added tests for that. This latter case
exercises the newly added return PC fixup.

The dsymutil changes in this patch were originally included in D49887:
the associated test should be sufficient to test DW_AT_call_return_pc
encoding purely on the llvm side.

Differential Revision: https://reviews.llvm.org/D72489
2020-01-15 13:02:23 -08:00
Raphael Isemann 13f22f5d59 [lldb] Add expect_expr function for testing expression evaluation in dotests.
Summary:
This patch adds a new function to lldbtest: `expect_expr`. This function is supposed to replace the current approach
of calling `expect`/`runCmd` with `expr`, `p` etc.

`expect_expr` allows evaluating expressions and matching their value/summary/type/error message without
having to do any string matching that might allow unintended passes (e.g., `self.expect("expr 3+4", substrs=["7"])`
can unexpectedly pass for results like `(Class7) $0 = 7`, `(int) $7 = 22`, `(int) $0 = 77` and so on).

This only uses the function in a few places to test and demonstrate it. I'll migrate the tests in follow up commits.

Reviewers: JDevlieghere, shafik, labath

Reviewed By: labath

Subscribers: christof, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70314
2020-01-15 13:04:04 +01:00
Jonas Devlieghere 914b551eee [lldb/test] Add test for CMTime data formatter
Add a test for the CMTime data formatter. The coverage report showed
that this code path was untested.
2020-01-14 23:11:15 -08:00
Adrian Prantl b53d44b17a dotest.py: Add option to pass extra lldb settings to dotest
The primary motivation for this is to add another dimension to the
Swift LLDB test matrix, but this seems generally useful.

Differential Revision: https://reviews.llvm.org/D72662
2020-01-14 12:35:24 -08:00
Stella Stamenova ab72db7fc8 [lldb/test] test_breakpoints_func_full from TestNamespace.NamespaceBreakpointTestCase is now passing on Windows
After https://reviews.llvm.org/D70846, the test is now passing on Windows
2020-01-14 11:15:48 -08:00
Levon Ter-Grigoryan a705cf1acb Expression eval lookup speedup by not returning methods in ManualDWARFIndex::GetFunctions
Summary:
This change is connected with
https://reviews.llvm.org/D69843

In large codebases, we sometimes see Module::FindFunctions (when called from
ClangExpressionDeclMap::FindExternalVisibleDecls) returning huge amounts of
functions.

In current fix I trying to return only function_fullnames from ManualDWARFIndex::GetFunctions when eFunctionNameTypeFull is passed as argument.

Reviewers: labath, jarin, aprantl

Reviewed By: labath

Subscribers: shafik, clayborg, teemperor, arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70846
2020-01-14 14:59:56 +01:00
Med Ismail Bennani 877723b7ce [lldb/Expression] Improve interpreter error message with a non-running target
When trying to interpret an expression with a function call, if the
process hasn't been launched, the expression fails to be interpreted
and the user gets the following  error message:

```error: Can't run the expression locally```

This message doesn't explain why the expression failed to be
interpreted, that's why this patch improves the error message that is
displayed when trying to run an expression while no process is running.

rdar://11991708

Differential Revision: https://reviews.llvm.org/D72510

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-01-14 13:06:58 +01:00
Raphael Isemann d8ffd601d5 [lldb][NFC] Rewrite python_api/rdar-12481949 test
Summary:
This renames the test `rdar-12481949` to `get-value-32bit-int` as it just tests that we return the
correct result get calling GetValueAsSigned/GetValueAsUnsigned on 32-bit integers.

It also deletes all the strange things going on in this test including resetting the data formatters (which are to my
knowledge not used to calculate scalar values) and testing Python's long integers (let's just assume that our Python
distribution works correctly). Also modernises the setup code.

Reviewers: labath, aprantl

Reviewed By: aprantl

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72593
2020-01-14 10:10:24 +01:00
Raphael Isemann 61b6a4e826 [lldb] Fix that SBThread.GetStopDescription is returning strings with uninitialized memory at the end.
Summary:
`SBThread.GetStopDescription` is a curious API as it takes a buffer length as a parameter that specifies
how many bytes the buffer we pass has. Then we fill the buffer until the specified length (or the length
of the stop description string) and return the string length. If the buffer is a nullptr however, we instead
return how many bytes we would have written to the buffer so that the user can allocate a buffer with
the right size and pass that size to a subsequent `SBThread.GetStopDescription` call.

Funnily enough, it is not possible to pass a nullptr via the Python SWIG bindings, so that might be the
first API in LLDB that is not only hard to use correctly but impossible to use correctly. The only way to
call this function via Python is to throw in a large size limit that is hopefully large enough to contain the
stop description (otherwise we only get the truncated stop description).

Currently passing a size limit that is smaller than the returned stop description doesn't cause the
Python bindings to return the stop description but instead the truncated stop description + uninitialized characters
at the end of the string. The reason for this is that we return the result of `snprintf` from the method
which returns the amount of bytes that *would* have been written (which is larger than the buffer).
This causes our Python bindings to return a string that is as large as full stop description but the
buffer that has been filled is only as large as the passed in buffer size.

This patch fixes this issue by just recalculating the string length in our buffer instead of relying on the wrong
return value. We also have to do this in a new type map as the old type map is also used for all methods
with the given argument pair `char *dst, size_t dst_len` (e.g. SBProcess.GetSTDOUT`). These methods have
different semantics for these arguments and don't null-terminate the returned buffer (they instead return the
size in bytes) so we can't change the existing typemap without breaking them.

Reviewers: labath, jingham

Reviewed By: labath

Subscribers: clayborg, shafik, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72086
2020-01-14 09:34:32 +01:00
Raphael Isemann 577efd09e3 [lldb] Revert ddf044290e for TestProcessAPI.py
It seems ddf044290e caused the test to
time out on the Windows bot, but it's unclear to me why.
2020-01-13 22:09:20 +01:00
Raphael Isemann c1fbede984 [lldb][NFC] Remove debug print statement from TestExprDiagnostics.py 2020-01-13 14:17:55 +01:00
Raphael Isemann ddf044290e [lldb] Mark several tests as not dependent on debug info
Summary:
This just adds `NO_DEBUG_INFO_TESTCASE` to tests that don't really exercise anything debug information specific
and therefore don't need to be rerun for all debug information variants.

Reviewers: labath, jingham, aprantl, mib, jfb

Reviewed By: aprantl

Subscribers: dexonsmith, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72447
2020-01-13 10:40:29 +01:00
Vedant Kumar 4c00dbf22d lldbutil: Forward ASan launch info to test inferiors
This allows an unsanitized test process which loads a sanitized DSO (the
motivating example is a Swift runtime dylib) to launch on Darwin.

rdar://57290132

Differential Revision: https://reviews.llvm.org/D71379
2020-01-10 14:52:51 -08:00
Tatyana Krasnukha 3eea082535 [lldb][tests] Make it possible to expect failure for a whole category
There already are decorators and "--excluded" option to mark test-cases/files
as expected to fail. However, when a new test file is added and it which relates
to a feature that a target doesn't support, this requires either adding decorators
to that file or modifying the file provided as "--excluded" option value.

The purpose of this patch is to avoid any modifications in such cases.
E.g. if a target doesn't support "watchpoints" and passes "--xfail-category watchpoint"
to dotest, a testing job will not fail after a new watchpoint-related test file is added.

Differential Revision: https://reviews.llvm.org/D71906
2020-01-10 17:37:55 +03:00
Tatyana Krasnukha e20a3b9b6c [lldb][tests][NFC] Unify variable naming convention 2020-01-10 17:37:55 +03:00
Tatyana Krasnukha b3af8ab7f8 [lldb][tests] Cleanup '.categories' 2020-01-10 16:39:38 +03:00
Tatyana Krasnukha 9ba1512748 [lldb][test] NFC, re-use _getTestPath() function 2020-01-10 16:31:03 +03:00
Tatyana Krasnukha e4d6729710 [lldb][tests] Take into account all parent's categories when traverse folders upwards
This is needed to not re-write parent's categories by categories of a nested folder,
e.g. commands/expression/completion specify "cmdline" category, however it still belongs
to parent's "expression" category.

The sentinel ".categories" in the test-suite root directory is no longer needed.

Differential Revision: https://reviews.llvm.org/D71905
2020-01-10 16:31:02 +03:00
Jaroslav Sevcik 902974277d Data formatters: Look through array element typedefs
Summary:
Motivation: When formatting an array of typedefed chars, we would like to display the array as a string.

The string formatter currently does not trigger because the formatter lookup does not resolve typedefs for array elements (this behavior is inconsistent with pointers, for those we do look through pointee typedefs). This patch tries to make the array formatter lookup somewhat consistent with the pointer formatter lookup.

Reviewers: teemperor, clayborg

Reviewed By: teemperor, clayborg

Subscribers: clayborg, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72133
2020-01-10 11:45:24 +01:00
Jason Molenda 02113918ed When reading Aux file in chunks, read consecutive byte ranges
qemu has a very small maximum packet size (4096) and it actually
only uses half of that buffer for some implementation reason,
so when lldb asks for the register target definitions, the x86_64
definition is larger than 4096/2 and we need to fetch it in two parts.

This patch and test is fixing a bug in
GDBRemoteCommunicationClient::ReadExtFeature when reading a target
file in multiple parts.  lldb was assuming that it would always
get back the maximum packet size response (4096) instead of
using the actual size received and asking for the next group of
bytes.

We now have two tests in gdb_remote_client for unique features
of qemu - TestNestedRegDefinitions.py would test the ability
of lldb to follow multiple levels of xml includes; I opted to
create a separate TestRegDefinitionInParts.py test to test this
wrinkle in qemu's gdb remote serial protocol stub implementation.
Instead of combining both tests into a single test file.

<rdar://problem/49537922>
2020-01-09 16:05:38 -08:00
Raphael Isemann 782ad91cc4 [lldb] Fix that TestNoSuchArch.py was passing for the wrong reason
The command here failed due to the type in 'create' but the expect
did not actually check for the error message. This fixes the typo
and adds a check for the actuall error message we should see.
2020-01-09 12:09:48 +01:00
Jason Molenda 450073c639 Change the patterns to include the prefix '= ' so we don't pass errantly.
Looking at a sometimes-passing test case on a platform
where random values were being returned - sometimes
the expected digit ('1' or '2') would be included in the
random returned value.  Add a prefix to reduce the likelihood of
this a bit.
2020-01-06 15:20:13 -08:00
Jonas Devlieghere 3abc2927cb [lldb/Test] Move @skipIfAsan from test class to test methods.
skipTestIfFn can only be used to decorate a test method.
2020-01-06 09:53:06 -08:00
Jonas Devlieghere 8eba3fbb12 [lldb/Test] Temporarily skip TestFoundationDisassembly on the ASan bot.
This test is timing out on the sanitized bot on GreenDragon. Temporarily
disable it to increase the signal-to-noise ration.
2020-01-06 09:06:09 -08:00
Med Ismail Bennani df71f92fbb [lldb/Command] Add --force option for `watchpoint delete` command
Currently, there is no option to delete all the watchpoint without LLDB
asking for a confirmation. Besides making the watchpoint delete command
homogeneous with the breakpoint delete command, this option could also
become handy to trigger automated watchpoint deletion i.e. using
breakpoint actions.

rdar://42560586

Differential Revision: https://reviews.llvm.org/D72096

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-01-04 03:11:15 +01:00
Med Ismail Bennani 4117c8c019 Revert "[lldb/Command] Add --force option for `watchpoint delete` command"
This reverts commit 3620e5f28a.
2020-01-03 02:14:45 +01:00
Jonas Devlieghere d265c8bf0d [lldb/Python] Remove unused imports (NFC) 2020-01-02 16:55:09 -08:00
Jonas Devlieghere 8580397f2e [lldb/Python] Remove unused support file (NFC) 2020-01-02 16:55:09 -08:00
Med Ismail Bennani 3620e5f28a [lldb/Command] Add --force option for `watchpoint delete` command
Currently, there is no option to delete all the watchpoint without LLDB
asking for a confirmation. Besides making the watchpoint delete command
homogeneous with the breakpoint delete command, this option could also
become handy to trigger automated watchpoint deletion i.e. using
breakpoint actions.

rdar://42560586

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-01-03 01:51:22 +01:00
Raphael Isemann 7ead008729 [lldb] Fix crash in AccessDeclContextSanity when copying FunctionTemplateDecl inside a record.
Summary:
We currently don't set access specifiers for function template declarations. This seems to be fine
as long as the function template is not declared inside any record in which case Clang asserts
with the following once we try to query it's access:
```
Assertion failed: (Access != AS_none && "Access specifier is AS_none inside a record decl"), function AccessDeclContextSanity,
```

This patch just marks these function template declarations as public to make Clang happy.

Reviewers: shafik, teemperor

Reviewed By: teemperor

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71909
2020-01-02 14:47:04 +01:00
Saleem Abdulrasool fb170fd652 tests: XFAIL/UNSUPPORTED tests on Windows
Now that we are building the python bindings on Windows once more, the
extended testsuite is running.  Mark a few failing tests and skip a few
tests which hang.  This should at least bring the bot back to green
without reverting the Python changes which are an improvement for the
build system and enable another ~35% of the test suite which was
previously disabled.
2020-01-01 14:22:49 -08:00
Muhammad Omair Javaid e25e3d7585 [lldb] Silent random xpass on aarch64-linux buildbot
This patch adds skipif decorator to TestWatchLocationWithWatchSet.py.
Decorator will trigger for aarch64-linux as this test passes randomly
causing buildbot failure.
2019-12-27 17:01:58 +05:00
Tatyana Krasnukha db1fa62bf8 [lldb][test] Don't include "test_common.h" in the debug macros test
GCC produces incorrect .debug_macro section when "-include" option is used:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93075.
2019-12-26 18:49:36 +03:00
Tatyana Krasnukha b7c45ac352 [lldb][NFC] Add "lldb-vscode" to all_categories
Required to make the category manually disableable.
2019-12-26 18:49:35 +03:00
Tatyana Krasnukha 04359f48f0 [lldb][NFC] Simplify if-return 2019-12-26 18:49:35 +03:00
Tatyana Krasnukha a58bd0e42c [lldb][tests] Platform triple can be None
If a remote target is not connected, SBPlatform's GetTriple function returns None.
2019-12-26 18:49:35 +03:00
Tatyana Krasnukha f57b35af2f [lldb][tests] Posix function strdup requires macro _POSIX_C_SOURCE 2019-12-26 18:49:34 +03:00
Saleem Abdulrasool 64c6bb3783 test: ensure that we dead-strip in the linker
`/OPT:REF` is needed for link to dead strip functions, `/Gy` by itself
is not sufficient.
2019-12-24 10:19:22 -08:00
Saleem Abdulrasool 4b0563f89f test: correct flags for Windows
Adjust the flags for the LLDB test on Windows.  This test was previously
not running, but after the fix to the python detection, we now run this.
2019-12-23 20:21:26 -08:00
Jonas Devlieghere a32f8dd195 [lldb/test] Skip editline tests when LLDB_ENABLE_LIBEDIT is off.
Add a new decorator that checks if LLDB was build with editline support
and mark the relevant tests as skipped when that's not the case.
2019-12-20 21:01:23 -08:00
Pavel Labath b04b92c3a4 [lldb/pexpect] Force-set the TERM environment variable
In some environments (typically, buildbots), this variable may not be
available. This can cause tests to behave differently.

Explicitly set the variable to "vt100" to ensure consistent test
behavior. It should not matter that we do not inherit the process TERM
variable, as the child process runs in a new virtual terminal anyway.
2019-12-20 15:19:41 +01:00
Raphael Isemann 29bd219497 [lldb] Added test for objc_direct calls with categories
As pointed out in D71694 this wasn't tested before in LLDB.
2019-12-20 11:07:30 +01:00
Pavel Labath 4cc5659a7a [lldb] Remove XFAIL from TestDeadStrip.py
Fixed by 92211b.
2019-12-20 10:04:25 +01:00
shafik 6a7df3a3f9 [ASTImporter][LLDB] Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton
This fix was motivated by a crashes in expression parsing during code generation in which we had a RecordDecl that had incomplete FieldDecl. During code generation when computing the layout for the RecordDecl we crash because we have several incomplete FieldDecl.

This fixes the issue by assuring that during ImportDefinition(...) for a RecordDecl we also import the definitions for each FieldDecl.

Differential Revision: https://reviews.llvm.org/D71378
2019-12-19 11:16:54 -08:00
Jason Molenda 997bc8b2e6 Add prototype for a function we call. 2019-12-18 14:18:52 -08:00
Raphael Isemann ff0102b32c [lldb] Remove modern-type-lookup
Summary:
As discussed on the mailing list [1] we have to make a decision for how to proceed with the modern-type-lookup.

This patch removes modern-type-lookup from LLDB. This just removes all the code behind the modern-type-lookup
setting but it does *not* remove any code from Clang (i.e., the ExternalASTMerger and the clang-import-test stay around
for now).

The motivation for this is that I don't think that the current approach of implementing modern-type-lookup
will work out. Especially creating a completely new lookup system behind some setting that is never turned on by anyone
and then one day make one big switch to the new system seems wrong. It doesn't fit into the way LLVM is developed and has
so far made the transition work much more complicated than it has to be.

A lot of the benefits that were supposed to come with the modern-type-lookup are related to having a better organization
in the way types move across LLDB and having less dependencies on unrelated LLDB code. By just looking at the current code (mostly
the ClangASTImporter) I think we can reach the same goals by just incrementally cleaning up, documenting, refactoring
and actually testing the existing code we have.

[1] http://lists.llvm.org/pipermail/lldb-dev/2019-December/015831.html

Reviewers: shafik, martong

Subscribers: rnkovacs, christof, arphaman, JDevlieghere, usaxena95, lldb-commits, friss

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71562
2019-12-17 12:24:31 +01:00
Pavel Labath dcd14324dc [lldb-vscode] Centrally skip debug info variants for vscode tests
Previously each test was annotated manually. This does the same thing.
2019-12-17 11:08:52 +01:00
Raphael Isemann d5b54bbfaf [lldb] Add support for calling objc_direct methods from LLDB's expression evaluator.
Summary:
D69991 introduced `__attribute__((objc_direct))` that allows directly calling methods without message passing.
This patch adds support for calling methods with this attribute to LLDB's expression evaluator.

The patch can be summarised in that LLDB just adds the same attribute to our module AST when we find a
method with `__attribute__((objc_direct))` in our debug information.

Reviewers: aprantl, shafik

Reviewed By: shafik

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71196
2019-12-17 10:28:40 +01:00
Jim Ingham 9e9c5f0a63 Explicitly specify -std=c++11 and include <mutex> and <condition_variable>.
These files built on macos but not on Debian Linux.  Let's see if this fixes it.
2019-12-16 18:09:24 -08:00
Jim Ingham 434905b97d Run all threads when extending a next range over a call.
If you don't do this you end up running arbitrary code with
only one thread allowed to run, which can cause deadlocks.

<rdar://problem/56422478>

Differential Revision: https://reviews.llvm.org/D71440
2019-12-16 17:45:21 -08:00
Pavel Labath 755a66ebde [lldb] Use file-based synchronization in TestVSCode_attach
The is the best method we have at the moment for attach-style tests.
2019-12-16 14:10:42 +01:00
Jonas Devlieghere 4e26cf2cfb [lldb/CMake] Rename LLDB_DISABLE_PYTHON to LLDB_ENABLE_PYTHON
This matches the naming scheme used by LLVM and all the other optional
dependencies in LLDB.

Differential revision: https://reviews.llvm.org/D71482
2019-12-13 13:41:11 -08:00
Med Ismail Bennani 2c91d5ba83 LanguageRuntime: Simplify NSException::GetSummary() output
Summary:
Right now, NSException::GetSummary() has the following output:
"name: $exception_name - reason: $exception_reason"

It would be better to simplify the output by removing the name and only
showing the exception's reason. This way, annotations would look nicer in
the editor, and would be a shorter summary in the Variables Inspector.

Accessing the exception's name can still be done by expanding the
NSException object in the Variables Inspector.

rdar://54770115

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71311

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2019-12-13 12:33:31 -08:00
Jonas Devlieghere 1ef7c4269b [lldb/Test] C++ test should use CXXFLAGS_EXTRAS
Thanks Ted Woodward for noticing this.
2019-12-13 10:00:59 -08:00
Raphael Isemann 9bace26a69 [lldb][NFC] Remove all `setUp` overrides that only call the parent implementation
Summary:
A lot of our tests copied the setUp code from our TestSampleTest.py:

```
    def setUp(self):
        # Call super's setUp().
        TestBase.setUp(self)
```

This code does nothing unless we actually do any setUp work in there, so let's remove all these method definitions.

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71454
2019-12-13 12:34:49 +01:00
Raphael Isemann a52a11139c [lldb][NFC] Remove 'from __future__ import print_function' from all tests that don't actually call 'print()'
Summary:
A lot of tests do this trick but the vast majority of them don't even call `print()`.

Most of this patch was generated by a script that just looks at all the files and deletes the line if there is no `print (` or `print(` anywhere else in the file.
I checked the remaining tests manually and deleted the import if we never call print (but instead do stuff like `expr print(...)` and similar false-positives).
I also corrected the additional empty lines after the import in the files that I manually edited.

Reviewers: JDevlieghere, labath, jfb

Reviewed By: labath

Subscribers: dexonsmith, wuzish, nemanjai, kbarton, christof, arphaman, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71452
2019-12-13 12:23:04 +01:00
Raphael Isemann 4286aca5d5 [lldb][NFC] Add reminder to TestSampleTest that setUp should be deleted if it not needed. 2019-12-13 12:10:05 +01:00
Muhammad Omair Javaid 5536c62f3c [lldb] Remove xpasses after pr44037 fix committed
This patch removes xpass decorator from tests which were failing due to
pr44037.

pr44037 was fixed by rev 6ce1a897b6
2019-12-13 12:30:58 +05:00
Jordan Rupprecht 786b6db8e6 [lldb][dotest] Add `#include <algorithm>` to libc++ detection
Summary: Speculative fix after 34ef51b5f9 broke the lldb buildbot on libc++ tests.

Reviewers: echristo, EricWF

Subscribers: ldionne, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71376
2019-12-11 14:06:14 -08:00
Jordan Rupprecht 34ef51b5f9 [lldb][dotest] Improve libc++ detection
Summary: The test logic for running libc++ tests only looks to see if `/usr/include/c++/v1` exists. This adds a fallback for including libc++ tests as long as `$(CC) -stdlib=libc++` works.

Reviewers: labath, EricWF

Subscribers: ldionne, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71319
2019-12-11 13:38:05 -08:00
Jason Molenda 6d64162a2d return-object-by-reference ("non trivial") xfail on arm64 in TestTrivialABI.py
I don't think this test case can be handled correctly on AAPCS64.
The ABI says that the caller passes the address of the return object
in x8.  x8 is a caller-spilled (aka "volatile") register, and the
function is not required to preserve x8 or to copy the address back
into x8 on function exit like the SysV x86_64 ABI does with rax.
(from aapcs64: "there is no requirement for the callee to preserve the
value stored in x8")

From my quick reading of ABISysV_arm64, I worry that it may actually be
using the value in x8 at function exit, assuming it still has the
address of the return object -

    if (is_return_value) {
      // We are assuming we are decoding this immediately after returning from
      // a function call and that the address of the structure is in x8
      reg_info = reg_ctx->GetRegisterInfoByName("x8", 0);

This will work on trivial test programs / examples, but if the function
does another function call, or overwrites x8 as a scratch register, lldb
will provide incorrect values to the user.

ABIMacOSX_arm64 doesn't do this, but it also doesn't flag the value
as unavailable so we're providing incorrect values to the user all
the time.  I expect my fix will be to make ABIMacOSX_arm64 flag
the return value as unretrievable, unless I've misread the ABI.
2019-12-11 12:00:16 -08:00
Jason Molenda 52c5342ebc update TestThreadStepOut.py to expect correct source line on arm64. 2019-12-11 09:17:03 -08:00
Jason Molenda 24a4d27acd Don't run expect based tests remotely. 2019-12-11 08:29:18 -08:00
Jason Molenda af3aac9a22 Change the mtc Makefile to check $SDKROOT value instead
of depending on it being set in the environment.  Fred's change
from October assumed that SDKROOT was set in the environment
so that 'xcrun --show-sdk-path' would print the path.  If it
was passed in as a Makefile variable, it wouldn't be set in
the environment and xcrun --show-sdk-path would always show the
macOS SDK path.  When running the lldb testsuite against an ios
device via lit, this seems to be the case.
2019-12-10 18:48:40 -08:00
Adrian Prantl 62a6d97704 Do not cache hardcoded formats in FormatManager
The cache in FormatCache uses only a type name as key. The hardcoded
formats, synthetic children, etc inspect an entire ValueObject to
determine their eligibility, which isn't modelled in the cache. This
leads to bugs such as the one in this patch (where two similarly named
types in different files have different hardcoded summary
providers). The problem is exaggerated in the Swift language plugin
due to the language's dynamic nature.

rdar://problem/57756763

Differential Revision: https://reviews.llvm.org/D71233
2019-12-10 15:53:40 -08:00
Jason Molenda b0937be06e Skip TestGuiBasic.py on ios etc device testing. 2019-12-10 15:15:25 -08:00
Jason Molenda 90f4355b43 Skip TestMultilineCompletion.py on ios testsuite runs. 2019-12-10 14:55:04 -08:00
Vedant Kumar d0789e6346 Assert launch success in run_to_breakpoint_do_run 2019-12-10 11:19:17 -08:00
Raphael Isemann 14f3d13412 [lldb] Actually enable wchar support in Editline when it is defined in the host config
Summary:
Our Editline implementation in LLDB supports using the wchar interface of Editline which
should improve handling of unicode input when using Editline. At the moment we essentially
just ignore unicode input and echo the escaped unicode code point (`\U1234`) to the command line
(which we then also incorrectly treat as multiple characters, so console navigation is also broken afterwards).

This patch just adds the include to the host config file which already contains the LLDB_EDITLINE_USE_WCHAR
define to enable the Editline support (we just never included it in the file before). With this we now actually
echo back unicode characters on macOS and we no longer ignore unicode input. On Linux this doesn't
seem to improve the echoing back of characters but at least it fixes that we ignore unicode input.

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71251
2019-12-10 14:30:41 +01:00
Serhiy Redko 6dad5e441d The field ‘totalFrames’ which is total number of frames available, is mandatory in StackTraces response for VSCode extension that implements DAP and declares capability 'supportsDelayedStackTraceLoading':
"The debug adapter supports the delayed loading of parts of the stack,
which requires that both the 'startFrame' and 'levels' arguments and the
'totalFrames' result of the 'StackTrace' request are supported."

Lack of this field makes VSCode incorrectly display stack traces information

D71034
2019-12-09 10:43:50 -08:00
Pavel Labath be05633e28 [lldb] Clean up accidentally passing TestDeadStrip.py
This test was accidentally passing on non-darwin OS because it was
explicitly setting the CFLAGS make variable. This meant that (in the
default config) it was building with absolutely no debug info, and so
setting a breakpoint on a stripped symbol failed, because there was
really no trace of it remaining. In other configurations, we were
generating the debug info (-gsplit-dwarf implies -g) and the test failed
because we did not treat the zeroed out debug info address specially.
The test was also xfailed in pretty much every non-standard
configuration.

This patch fixes the makefile to avoid messing with CFLAGS (use
CFLAGS_EXTRAS instead). This causes it to fail in all configurations
(except darwin), and so I replace the various decorators with a simple
os!=darwin check.
2019-12-09 19:01:52 +01:00
Muhammad Omair Javaid 0964733bae [lldb] Remove Xfail decorators from steadily passing tests
This patch removes xfail decorator from some lldb testcases which are
passing steadily now for past few week/months on aarch64/linux buildbot.
2019-12-09 19:08:59 +05:00
Muhammad Omair Javaid 7d175cf504 [lldb] Xfail TestCallOverriddenMethod.py for aarch64/linux
This test still fails on Linux aarch64.
Tested by buildbot running Ubuntu Bionic

Differential Revision: https://reviews.llvm.org/D70722
2019-12-09 16:38:33 +05:00
Raphael Isemann f6e05672f6 [lldb] Add a test for how we lazily create Clang AST nodes
Summary:
One of the ways we try to make LLDB faster is by only creating the Clang declarations (and loading the associated types)
when we actually need them for something. For example an evaluated expression might need to load types to
type check and codegen the expression.

Currently this mechanism isn't really tested, so we currently have no way to know how many Clang nodes we load and
when we load them. In general there seems to be some confusion when and why certain Clang nodes are created.
As we are about to make some changes to the code which is creating Clang AST nodes we probably should have
a test that at least checks that the current behaviour doesn't change. It also serves as some kind of documentation
on the current behaviour.

The test in this patch is just evaluating some expressions and checks which Clang nodes are created due to this in the
module AST. The check happens by looking at the AST dump of the current module and then scanning it for the
declarations we are looking for.

I'm aware that there are things missing in this test (inheritance, template parameters, non-expression evaluation commands)
but I'll expand it in follow up patches.

Also this test found two potential bugs in LLDB which are documented near the respective asserts in the test:

1. LLDB seems to always load all types of local variables even when we don't reference them in the expression. We had patches
that tried to prevent this but it seems that didn't work as well as it should have (even though we don't complete these
types).
2. We always seem to complete the first field of any record we run into. This has the funny side effect that LLDB is faster when
all classes in a project have an arbitrary `char unused;` as their first member. We probably want to fix this.

Reviewers: shafik

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71056
2019-12-09 09:59:40 +01:00
Jordan Rupprecht 03a242bd41 [lldb][test] Handle .categories lookup for inline tests.
Summary:
When creating a test with `lldbinline.MakeInlineTest()`, the reported `inspect.getfile(test.__class__)` is `lldbtest.pyc`, meaning any `.categories` file will be ineffective for those tests. Check for the test_filename first, which inline tests will set.

Additionally, raise an error with the starting dir if `.categories` is not found. This makes the problem more obvious when it occurs: when the test is separated from the test framework tree.

Reviewers: labath, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71099
2019-12-06 08:36:23 -08:00
Pavel Labath 0d2472ff6f [lldb/IRExecutionUnit] Stop searching based on demangled names
Summary:
This was causing problems on linux, where we'd end up calling the
deleting destructor instead of a regular one (because they have the same
demangled name), making a lot of mischief in the process.

The only place where this was necessary (according to the test suite, at
least) was to call a base structor instead of a complete one, but this
is now handled in a more targeted fashion.

TestCallOverriddenMethod is now re-enabled as it now passes reliably.

Reviewers: teemperor, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70722
2019-12-06 10:17:49 +01:00
Jordan Rupprecht 0d236d8b4f [lldb] Update hardcoded Makefile.rules inclusions.
This replaces `include $(LEVEL)/Makefile.rules` with `include Makefile.rules`.
The lldb test driver already passes the include path when running make, and specifically looking for "../../Makefile.rules" forces the test to be in a specific location.
Removing this hardcoded relative path will make it possible to move this test as-is.
2019-12-05 15:50:03 -08:00
Djordje Todorovic 4b4ede440a Reland "[LiveDebugValues] Introduce entry values of unmodified params"
Relanding this after resolving the cause of the test failure.
2019-12-05 11:10:49 +01:00
Jim Ingham 3151d7af72 Clear out the python class name in OptionParsingStarted for the OptionGroupPythonClassWithDict
options class.  This value was hanging around so for instance if you made a scripted breakpoint
resolver, then went to set another breakpoint, it would still think you had passed in a class
name and the breakpoint wouldn't do what you expected.
2019-12-04 17:40:57 -08:00
Joseph Tremoulet 95b2e516bd Change Target::FindBreakpointsByName to return Expected<vector>
Summary:
Using a BreakpointList corrupts the breakpoints' IDs because
BreakpointList::Add sets the ID, so use a vector instead, and
update the signature to return the vector wrapped in an
llvm::Expected which can propagate any error from the inner
call to StringIsBreakpointName.

Note that, despite the similar name, SBTarget::FindBreakpointsByName
doesn't suffer the same problem, because it uses a SBBreakpointList,
which is more like a BreakpointIDList than a BreakpointList under the
covers.

Add a check to TestBreakpointNames that, without this fix, notices the
ID getting mutated and fails.

Reviewers: jingham, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70907
2019-12-04 09:57:15 -05:00
Pavel Labath 1351672eed [lldb] s/assertTrue/assertEqual in TestStepTarget.py
this improves error messages.
2019-12-04 10:56:38 +01:00
Djordje Todorovic 409350deea Revert "[LiveDebugValues] Introduce entry values of unmodified params"
This reverts commit rG4cfceb910692 due to LLDB test failing.
2019-12-03 13:13:27 +01:00
Raphael Isemann b37a43d93d [lldb] Remove all remaining tabs from TestReturnValue.py
I assumed this was just a single typo, but it seems we actually have
a whole bunch of tabs in this file which cause Python to complain
about mixing tabs and spaces.
2019-12-03 12:14:40 +01:00
Raphael Isemann 4821d2a014 [lldb][NFC] Test going up/down one line in the multiline expression editor 2019-12-03 12:06:40 +01:00
Diana Picus 057626b439 Fixup 6d18e53: xfail TestShowLocationDwarf5.py properly
Forgot to squash this...
2019-12-03 11:53:28 +01:00
Raphael Isemann 46d0ec3a80 [lldb] Remove tab from TestReturnValue.py
Mixing tabs and spaces makes Python exit with this error:

  File "llvm/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py", line 23
    return (self.getArchitecture() == "aarch64" and self.getPlatform() == "linux")
                                                                                 ^
TabError: inconsistent use of tabs and spaces in indentation
2019-12-03 11:44:24 +01:00
Pavel Labath 2b8db387f2 [lldb] Move register info "augmentation" from gdb-remote into ABI
Summary:
Previously the ABI plugin exposed some "register infos" and the
gdb-remote code used those to fill in the missing bits. Now, the
"filling in" code is in the ABI plugin itself, and the gdb-remote code
just invokes that.

The motivation for this is two-fold:
a) the "augmentation" logic is useful outside of process gdb-remote. For
  instance, it would allow us to avoid repeating the register number
  definitions in minidump code.
b) It gives more implementation freedom to the ABI classes. Now that
  these "register infos" are essentially implementation details, classes
  can use other methods to obtain dwarf/eh_frame register numbers -- for
  instance they can consult llvm MC layer.

Since the augmentation code was not currently tested anywhere, I took
the opportunity to create a simple test for it.

Reviewers: jasonmolenda, clayborg, tatyana-krasnukha

Subscribers: aprantl, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70906
2019-12-03 11:39:20 +01:00
Djordje Todorovic 4cfceb9106 [LiveDebugValues] Introduce entry values of unmodified params
The idea is to remove front-end analysis for the parameter's value
modification and leave it to the value tracking system. Front-end in some
cases marks a parameter as modified even the line of code that modifies the
parameter gets optimized, that implies that this will cover more entry
values even. In addition, extending the support for modified parameters
will be easier with this approach.

Since the goal is to recognize if a parameter’s value has changed, the idea
at very high level is: If we encounter a DBG_VALUE other than the entry
value one describing the same variable (parameter), we can assume that the
variable’s value has changed and we should not track its entry value any
more. That would be ideal scenario, but due to various LLVM optimizations,
a variable’s value could be just moved around from one register to another
(and there will be additional DBG_VALUEs describing the same variable), so
we have to recognize such situation (otherwise, we will lose a lot of entry
values) and salvage the debug entry value.

Differential Revision: https://reviews.llvm.org/D68209
2019-12-03 11:01:45 +01:00
Diana Picus 6d18e5366c Mark some tests as xfail on AArch64 Linux
I have either opened new bug reports for these tests, or added links to
existing bugs.

This should help make the lldb-aarch64-ubuntu buildbot green (there will
still be some unexpected passes that someone should look into, but those
can be handled later).
2019-12-03 10:57:42 +01:00
António Afonso afd5d91281 [lldb] Fix TestFormattersSBAPI test
Summary:
This test was broken in two ways:
* Using the wrong API (e.g.: format = instead of SetFormat)
* The hex checker was only checking "01" which will pass with 0x0000001

Reviewers: clayborg, lanza, wallace

Reviewed By: clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70884
2019-12-02 12:24:11 -08:00
Raphael Isemann 160a5045c6 [lldb][NFC] Add 'breakpoint command list' test
The command has zero test coverage and I'll have to touch the
code formatting the output commands, so let's start by adding a
test for it.
2019-12-02 11:57:55 +01:00
Eric Christopher fd39b1bb20 Revert "Revert "As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.""
This reapplies: 8ff85ed905

Original commit message:

As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.

This change doesn't include any change to move from selection dag to fast isel
and that will come with other numbers that should help inform that decision.
There also haven't been any real debuggability studies with this pipeline yet,
this is just the initial start done so that people could see it and we could start
tweaking after.

Test updates: Outside of the newpm tests most of the updates are coming from either
optimization passes not run anymore (and without a compelling argument at the moment)
that were largely used for canonicalization in clang.

Original post:

http://lists.llvm.org/pipermail/llvm-dev/2019-April/131494.html

Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65410

This reverts commit c9ddb02659.
2019-11-26 20:28:52 -08:00
Michał Górny 3cd9a8b7dc [lldb] [test] Un-XFAIL lldb-server tests fixed on NetBSD 2019-11-26 16:46:21 +01:00
Michał Górny 7644d8ba4d [lldb] [Process/NetBSD] Fix handling concurrent watchpoint events
Fix handling concurrent watchpoint events so that they are reported
correctly in LLDB.

If multiple watchpoints are hit concurrently, the NetBSD kernel reports
them as series of SIGTRAPs with a thread specified, and the debugger
investigates DR6 in order to establish which watchpoint was hit.  This
is normally fine.

However, LLDB disables and reenables the watchpoint on all threads after
each hit, which results in the hit status from DR6 being wiped.
As a result, it can't establish which watchpoint was hit in successive
SIGTRAP processing.

In order to workaround this problem, clear DR6 only if the breakpoint
is overwritten with a new one.  More specifically, move cleaning DR6
from ClearHardwareWatchpoint() to SetHardwareWatchpointWithIndex(),
and do that only if the newly requested watchpoint is different
from the one being set previously.  This ensures that the disable-enable
logic of LLDB does not clear watchpoint hit status for the remaining
threads.

This also involves refactoring of watchpoint logic.  With the old logic,
clearing watchpoint involved wiping dr6 & dr7, and setting it setting
dr{0..3} & dr7.  With the new logic, only enable bit is cleared
from dr7, and the remaining bits are cleared/overwritten while setting
new watchpoint.

Differential Revision: https://reviews.llvm.org/D70025
2019-11-25 20:11:59 +01:00
Michał Górny d970d4d4aa [lldb] [Process/NetBSD] Copy watchpoints to newly-created threads
NetBSD ptrace interface does not populate watchpoints to newly-created
threads.  Solve this via copying the watchpoints from the current thread
when new thread is reported via TRAP_LWP.

Add a test that verifies that when the user does not have permissions
to set watchpoints on NetBSD, the 'watchpoint set' errors out gracefully
and thread monitoring does not crash on being unable to copy watchpoints
to new threads.

Differential Revision: https://reviews.llvm.org/D70023
2019-11-25 20:11:59 +01:00
Michał Górny 8d9400b65b [lldb] [Process/NetBSD] Improve threading support
Implement major improvements to multithreaded program support.  Notably,
support tracking new and exited threads, associate signals and events
with correct threads and support controlling individual threads when
resuming.

Firstly, use PT_SET_EVENT_MASK to enable reporting of created and exited
threads via SIGTRAP.  Handle TRAP_LWP events to keep track
of the currently running threads.

Secondly, update the signal (both generic and SIGTRAP) handling code
to account for per-thread signals correctly.  Signals delivered
to the whole process are reported on all threads, while per-thread
signals and events are reported only to the specific thread.
The remaining threads are marked as 'stopped with no reason'.  Note that
NetBSD always stops all threads on debugger events.

Thirdly, implement the ability to set every thread as running, stopped
or single-stepping separately while continuing the process.  This also
provides the ability to send a signal to the whole process or to one
of its thread while resuming.

Differential Revision: https://reviews.llvm.org/D70022
2019-11-25 20:11:58 +01:00
Michał Górny 6a7f6145d0 [lldb] [test] XFAIL ASAN tests on NetBSD 2019-11-25 20:03:41 +01:00
Pavel Labath aa16bf15fe [lldb-vscode] Fix a race in test_extra_launch_commands
Summary:
The test used a non-stopping "run" command to launch the process. This
is different from the regular launch with no extra launch commands,
which uses eLaunchFlagStopAtEntry to ensure that the process stops
straight away.

I'm not really sure what's supposed to happen in non-stop-at-entry mode,
or if that's even supported, but what ended up happening was the launch
packet got a reply while the process was running. Then the test case did
a continue_to_next_stop(), which queued a *second* resume request
(along with the internal "resumes" which were being issued as a part of
normal process startup). These two resumes ended up chasing each other's
tails inside lldb in a way which produced hilarious log traces.
Surprisingly, the test ended up passing most of the time, but it did
cause spurious failures when the test seemed to miss a breakpoint.

This changes the test to use stop-at-entry mode in the manual launch
sequence too, which seems to be enough to make the test pass reliably.

Reviewers: clayborg, kusmour, jankratochvil

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70127
2019-11-25 10:07:38 +01:00
Jason Molenda 45098b6809 Remove extraneous log enabling. 2019-11-22 14:13:35 -08:00
Vedant Kumar 4fdbc0728d [DWARF] Handle call sites with indirect call targets
Split CallEdge into DirectCallEdge and IndirectCallEdge. Teach
DWARFExpression how to evaluate entry values in cases where the current
activation was created by an indirect call.

rdar://57094085

Differential Revision: https://reviews.llvm.org/D70100
2019-11-22 11:50:22 -08:00
Jordan Rupprecht 506144da04 [lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.
Summary:
When built w/ `-funsigned-char`, `std::string` becomes equivalent to `std::basic_string<unsigned char>`, causing these formatters to not match. This patch adds overloads for both libstdc++ and libc++ string formatters that accepts unsigned char.

Motivated by the following example:

```
$ cat pretty_print.cc

template <typename T>
void print_val(T s) {
  std::cerr << s << '\n';  // Set a breakpoint here!
}

int main() {
  std::string val = "hello";
  print_val(val);
  return 0;
}
$ clang++ -stdlib=libc++ -funsigned-char -fstandalone-debug -g pretty_print.cc
$ lldb ./a.out -b -o 'b pretty_print.cc:6' -o r -o 'fr v'
...
(lldb) fr v
(std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >) s = {
  __r_ = {
    std::__1::__compressed_pair_elem<std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__rep, 0, false> = {
      __value_ = {
         = {
          __l = (__cap_ = 122511465736202, __size_ = 0, __data_ = 0x0000000000000000)
          __s = {
             = (__size_ = '\n', __lx = '\n')
            __data_ = {
              [0] = 'h'
              [1] = 'e'
              [2] = 'l'
              [3] = 'l'
              [4] = 'o'
              [5] = '\0'
...
```

Reviewers: labath, JDevlieghere, shafik

Subscribers: christof, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70517
2019-11-22 10:25:03 -08:00
Adrian Prantl 539117616d Complete complete types early when importing types from Clang module DWARF.
This affects -gmodules only.

Under normal operation pcm_type is a shallow forward declaration
that gets completed later. This is necessary to support cyclic
data structures. If, however, pcm_type is already complete (for
example, because it was loaded for a different target before),
the definition needs to be imported right away, too.
Type::ResolveClangType() effectively ignores the ResolveState
inside type_sp and only looks at IsDefined(), so it never calls
ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(),
which does extra work for Objective-C classes. This would result
in only the forward declaration to be visible.

An alternative implementation would be to sink this into Type::ResolveClangType ( 88235812a7/lldb/source/Symbol/Type.cpp (L5809)) though it isn't clear to me how to best do this from a layering perspective.

rdar://problem/52134074

Differential Revision: https://reviews.llvm.org/D70415
2019-11-22 09:58:16 -08:00
Martin Svensson 0b0dca9f6f [lldb] Fix exception breakpoint not being resolved when set on dummy target
Summary: Ensure that breakpoint ivar is properly set in exception breakpoint resolver so that exception breakpoints set on dummy targets are resolved once real targets are created and run.

Reviewers: jingham

Reviewed By: jingham

Subscribers: teemperor, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69880
2019-11-22 11:20:09 +01:00
Raphael Isemann b30dabfe90 [lldb] Don't enable expression log in TestEmptyStdModule.py
Thanks for pointing this out Jason!
2019-11-22 08:34:08 +01:00
Jonas Devlieghere 44fe1f024d [test] Mark TestEditline as skipped with ASan.
As discussed in https://reviews.llvm.org/D70324.
2019-11-21 13:09:40 -08:00
Jonas Devlieghere f5759d5dbc [Test] Split up TestIntegerTypes.py
The unsplit test is timing out on GreenDragon's sanitized bot. By
splitting the test we avoid this issue and increase parallelism.
2019-11-21 11:24:14 -08:00
Tatyana Krasnukha ffc4ff868f [lldb][NFC] Remove test directory completely
The test was moved to "completion-in-lambda-and-unnamed-class" by D66175.

+ Fix typo in the directory name.
2019-11-21 15:03:37 +03:00
Jason Molenda f24ed3a051 Handle the case where the 'g' packet doesn't get all regs.
lldb would silently accept a response to the 'g' packet
(read all registers) which was too large; this handles the
case where it is too small.

Differential Revision: https://reviews.llvm.org/D70417

<rdar://problem/34916465>
2019-11-20 14:15:08 -08:00
Michał Górny 923afb4a61 [lldb] [test] Un-XFAIL one lldb-server test on NetBSD 2019-11-20 21:16:34 +01:00
Djordje Todorovic ce1f95a6e0 Reland "[clang] Remove the DIFlagArgumentNotModified debug info flag"
It turns out that the ExprMutationAnalyzer can be very slow when AST
gets huge in some cases. The idea is to move this analysis to the LLVM
back-end level (more precisely, in the LiveDebugValues pass). The new
approach will remove the performance regression, simplify the
implementation and give us front-end independent implementation.

Differential Revision: https://reviews.llvm.org/D68206
2019-11-20 10:08:07 +01:00
Jordan Rupprecht 327a18ca0a [lldb][test] Prevent \n in calls to lldb's expect() test helper.
Summary:
expect() forwards its command to sendline(). This can be problematic if the command already contains a newline: sendline() unconditionally adds a newline to the command, which causes the command to run twice (hitting enter in lldb runs the previous command). The expect() helper looks for the prompt and finds the first one, but because the command has run a second time, the buffer will contain the contents of the second time the command ran, causing potential erroneous matching.

Simplify the editline test, which was using different commands to workaround this misunderstanding.

Reviewers: labath

Reviewed By: labath

Subscribers: merge_guards_bot, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70324
2019-11-19 15:17:35 -08:00
Raphael Isemann f6ffe6fc9d [lldb] Also test Get[De]mangledName of SBType in TestSBTypeClassMembers.py
I just used the mangled names as this test is anyway a Darwin-only ObjC++ test.
We probably should also test this on other platforms but that will be
another commit as we need to untangle the ObjC and C++ parts first.
2019-11-19 14:04:02 +01:00
Diana Picus bb7c8e984f Mark PR44037 tests as XFAIL on AArch64 Linux dwo
These tests are failing with various assertion failures, but they all
throw the following error message first:

error: a.out 0x0000002d: adding range [0x14-0x24) which has a base that
is less than the function's low PC 0x40060c.

See llvm.org/pr44037.

Differential Revision: https://reviews.llvm.org/D70381
2019-11-19 10:49:00 +01:00
Michał Górny 0854867798 [lldb] [test] XFAIL more lldb-server tests on NetBSD 2019-11-18 22:36:04 +01:00
Michał Górny 4539a2d20c [lldb] [test] Mark segv-related tests XFAIL on NetBSD
There seems to be a regression in the kernel causing those tests
to fail.  Mark them XFAIL, to be addressed later.
2019-11-18 22:36:03 +01:00
Michał Górny 23a766dcad [lldb] [Process/NetBSD] Implement thread name getting
Implement thread name getting sysctl() on NetBSD.  Also fix
the incorrect type in pthread_setname_np() in the relevant test.

Differential Revision: https://reviews.llvm.org/D70363
2019-11-18 11:21:17 +01:00
Michał Górny e8924d6403 [lldb] [test] Enable lldb-server tests on NetBSD, and set XFAILs
Differential Revision: https://reviews.llvm.org/D70335
2019-11-18 11:21:16 +01:00
Sylvestre Ledru 9b40a7f3bf Remove +x permission on some files 2019-11-16 14:47:20 +01:00
Walter Erquinigo 2c7c528d7a [lldb-vscode] support the completion request
Summary:
The DAP has a completion request that has been unimplemented. It allows showing autocompletion tokens inside the Debug Console.
I implemented it in a very simple fashion mimicking what the user would see when autocompleting an expression inside the CLI.
There are two cases: normal variables and commands. The latter occurs when a text is prepepended with ` in the Debug Console.
These two cases work well and have tests.

Reviewers: clayborg, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69873
2019-11-15 17:37:55 -08:00
Adrian Prantl 0304360a40 Add a testcase for Clang modules being updated within one LLDB session.
This actually works as expected, but wasn't explicitly tested before.
2019-11-15 16:27:14 -08:00