Commit Graph

5239 Commits

Author SHA1 Message Date
David Spickett f31e390453 [lldb][AArch64] Don't check for VmFlags in smaps files
AArch64 kernel builds default to having /smaps and
the "VmFlags" line was added in 3.8. Long before MTE
was supported.

So we can assume that if you're AArch64 with MTE,
you can run this test.

The previous method of checking had a race condition
where the process we read smaps for, could finish before
we get to read the file.

I explored some alternatives but in the end I think
it's fine to just assume we have what we need.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D100493
2021-04-29 09:30:14 +01:00
Adrian Prantl 711a473cd9 Update testcase for D101333. 2021-04-27 13:24:24 -07:00
Adrian Prantl 25bf137b1e Also display the underlying error message when displaying a fixit
When the user running LLDB with default settings sees the fixit
notification it means that the auto-applied fixit didn't work. This
patch shows the underlying error message instead of just the fixit to
make it easier to understand what the error in the expression was.

Differential Revision: https://reviews.llvm.org/D101333
2021-04-27 10:40:42 -07:00
Michał Górny ca7824c2a8 [lldb] [gdb-remote] Report QPassSignals and qXfer via extensions API
Remove hardcoded platform list for QPassSignals, qXfer:auxv:read
and qXfer:libraries-svr4:read and instead query the process plugin
via the GetSupportedExtensions() API.

Differential Revision: https://reviews.llvm.org/D101241
2021-04-27 19:34:00 +02:00
Raphael Isemann a0c735e29a [lldb] Skip TestPointerToMemberTypeDependingOnParentSize on Windows and GCC
The test added in D100977 is failing to compile on these platforms. This seems
to be caused by GCC, MSVC and Clang@Windows rejecting the code because
`ToLayout` isn't complete when pointer_to_member_member is declared (even though
that seems to be valid code).

This also reverts the test changes in the lazy-loading test from D100977 as
that failed for the same reason.
2021-04-26 18:55:54 +02:00
Jonas Devlieghere 7d850db6b6 [lldb] Don't use ::fork or ::vfork on watchOS or tvOS
Update lldb-server to not use fork or vfork on watchOS and tvOS as these
functions are explicitly marked unavailable there.

llvm-project/lldb/test/API/tools/lldb-server/main.cpp:304:11:
error: 'fork' is unavailable: not available on watchOS
      if (fork() == 0)
          ^
WatchSimulator6.2.sdk/usr/include/unistd.h:447:8: note: 'fork' has been
explicitly marked unavailable here
pid_t    fork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
         ^
llvm-project/lldb/test/API/tools/lldb-server/main.cpp:307:11:
error: 'vfork' is unavailable: not available on watchOS
      if (vfork() == 0)
          ^
WatchSimulator6.2.sdk/usr/include/unistd.h:602:8: note: 'vfork' has been
explicitly marked unavailable here
pid_t    vfork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
         ^
2021-04-26 09:31:35 -07:00
Emre Kultursay e439a463a3 [lldb] Use forward type in pointer-to-member
This change is similar in spirit to the change at:
https://reviews.llvm.org/rG34c697c85e9d0af11a72ac4df5578aac94a627b3

It fixes the problem where the layout of a type was being accessed
while its base classes were not populated yet; which caused an
incorrect layout to be produced and cached.

This fixes PR50054

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D100977
2021-04-26 15:23:58 +02:00
Michał Górny bbae0c1f7b [lldb] [llgs] Support owning and detaching extra processes
Add a NativeDelegate API to pass new processes (forks) to LLGS,
and support detaching them via the 'D' packet.  A 'D' packet without
a specific PID detaches all processes, otherwise it detaches either
the specified subprocess or the main process, depending on the passed
PID.

Differential Revision: https://reviews.llvm.org/D100191
2021-04-24 11:08:33 +02:00
Michał Górny 312257688e [lldb] [Process] Introduce protocol extension support API
Introduce a NativeProcessProtocol API for indicating support for
protocol extensions and enabling them.  LLGS calls
GetSupportedExtensions() method on the process factory to determine
which extensions are supported by the plugin.  If the future is both
supported by the plugin and reported as supported by the client, LLGS
enables it and reports to the client as supported by the server.

The extension is enabled on the process instance by calling
SetEnabledExtensions() method.  This is done after qSupported exchange
(if the debugger is attached to any process), as well as after launching
or attaching to a new inferior.

The patch adds 'fork' extension corresponding to 'fork-events+'
qSupported feature and 'vfork' extension for 'vfork-events+'.  Both
features rely on 'multiprocess+' being supported as well.

Differential Revision: https://reviews.llvm.org/D100153
2021-04-24 11:08:33 +02:00
Jonas Devlieghere 91d3f73937 [lldb] Update register state parsing for JSON crashlogs
- The register encoding state in the JSON crashlog format changes.
   Update the parser accordingly.
 - Print the register state when printing the symbolicated thread.
2021-04-22 16:40:59 -07:00
Adrian Prantl 007158ac42 Skip unreliable LLDB tests when running under asan 2021-04-22 11:55:43 -07:00
Jonas Devlieghere a62cbd9a02 [lldb] Include thread name in crashlog.py output
Update the JSON parser to include the thread name in the Thread object.

rdar://76677320
2021-04-22 11:38:53 -07:00
Raphael Isemann d616a6bd10 [lldb] Fix that the expression commands --top-level flag overwrites --allow-jit false
The `--allow-jit` flag allows the user to force the IR interpreter to run the
provided expression.

The `--top-level` flag parses and injects the code as if its in the top level
scope of a source file.

Both flags just change the ExecutionPolicy of the expression:
* `--allow-jit true` -> doesn't change anything (its the default)
* `--allow-jit false` -> ExecutionPolicyNever
* `--top-level` -> ExecutionPolicyTopLevel

Passing `--allow-jit false` and `--top-level` currently causes the `--top-level`
to silently overwrite the ExecutionPolicy value that was set by `--allow-jit
false`. There isn't any ExecutionPolicy value that says "top-level but only
interpret", so I would say we reject this combination of flags until someone
finds time to refactor top-level feature out of the ExecutionPolicy enum.

The SBExpressionOptions suffer from a similar symptom as `SetTopLevel` and
`SetAllowJIT` just silently disable each other. But those functions don't have
any error handling, so not a lot we can do about this in the meantime.

Reviewed By: labath, kastiglione

Differential Revision: https://reviews.llvm.org/D91780
2021-04-22 18:51:03 +02:00
Raphael Isemann d2223c7a49 [lldb] XFAIL TestStoppedInStaticMemberFunction on Windows
It seems we can't find the symbols of static members on Windows? The bug is not
 relevant to what this test is actually testing so let's just XFAIL it.
2021-04-22 13:46:27 +02:00
Raphael Isemann 00764c36ed [lldb] Add support for evaluating expressions in static member functions
At the moment the expression parser doesn't support evaluating expressions in
static member functions and just pretends the expression is evaluated within a
non-member function. This causes that all static members are inaccessible when
doing unqualified name lookup.

This patch adds support for evaluating in static member functions. It
essentially just does the same setup as what LLDB is already doing for
non-static member functions (i.e., wrapping the expression in a fake member
function) with the difference that we now mark the wrapping function as static
(to prevent access to non-static members).

Reviewed By: shafik, jarin

Differential Revision: https://reviews.llvm.org/D81550
2021-04-22 12:14:31 +02:00
Jonas Devlieghere 39ea3ceda3 [lldb] Disable TestSimulatorPlatform.py because it's causing a SIGHUP
Ever since Dave Zarzycki's patch to sort test start times based on prior
test timing data (https://reviews.llvm.org/D98179) the test suite aborts
with a SIGHUP. I don't believe his patch is to blame, but rather
uncovers an preexisting issue by making test runs more deterministic.

I was able to narrow down the issue to TestSimulatorPlatform.py. The
issue also manifests itself on the standalone bot on GreenDragon [1].
This patch disables the test until we can figure this out.

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/

rdar://76995109
2021-04-21 20:00:51 -07:00
Walter Erquinigo c9a0754b44 [lldb-vscode] Distinguish shadowed variables in the scopes request
VSCode doesn't render multiple variables with the same name in the variables view. It only renders one of them. This is a situation that happens often when there are shadowed variables.
The nodejs debugger solves this by adding a number suffix to the variable, e.g. "x", "x2", "x3" are the different x variables in nested blocks.

In this patch I'm doing something similar, but the suffix is " @ <file_name:line>), e.g. "x @ main.cpp:17", "x @ main.cpp:21". The fallback would be an address if the source and line information is not present, which should be rare.

This fix is only needed for globals and locals. Children of variables don't suffer of this problem.

When there are shadowed variables
{F16182150}

Without shadowed variables
{F16182152}

Modifying these variables through the UI works

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D99989
2021-04-21 15:09:39 -07:00
Walter Erquinigo 64f47c1e58 [lldb-vscode] redirect stderr/stdout to the IDE's console
In certain occasions times, like when LLDB is initializing and
evaluating the .lldbinit files, it tries to print to stderr and stdout
directly. This confuses the IDE with malformed data, as it talks to
lldb-vscode using stdin and stdout following the JSON RPC protocol. This
ends up terminating the debug session with the user unaware of what's
going on. There might be other situations in which this can happen, and
they will be harder to debug than the .lldbinit case.

After several discussions with @clayborg, @yinghuitan and @aadsm, we
realized that the best course of action is to simply redirect stdout and
stderr to the console, without modifying LLDB itself. This will prove to
be resilient to future bugs or features.

I made the simplest possible redirection logic I could come up with. It
only works for POSIX, and to make it work with Windows should be merely
changing pipe and dup2 for the windows equivalents like _pipe and _dup2.
Sadly I don't have a Windows machine, so I'll do it later once my office
reopens, or maybe someone else can do it.

I'm intentionally not adding a stop-redirecting logic, as I don't see it
useful for the lldb-vscode case (why would we want to do that, really?).

I added a test.

Note: this is a simpler version of D80659. I first tried to implement a
RIIA version of it, but it was problematic to manage the state of the
thread and reverting the redirection came with some non trivial
complexities, like what to do with unflushed data after the debug
session has finished on the IDE's side.
2021-04-21 14:48:48 -07:00
Walter Erquinigo 12a2507646 Fix TestVSCode_launch test
Broken in https://lab.llvm.org/buildbot/#/builders/96/builds/6933

We don't really need to run this test on arm, but would be worth fixing
it later.
2021-04-21 14:33:34 -07:00
Walter Erquinigo 79fbbeb412 [lldb-vscode] Add postRunCommands
This diff ass postRunCommands, which are the counterpart of the preRunCommands. TThey will be executed right after the target is launched or attached correctly, which means that the targets can assume that the target is running.

Differential Revision: https://reviews.llvm.org/D100340
2021-04-21 13:51:30 -07:00
Jonas Devlieghere 5d1c43f333 [lldb] Use the compiler from the SDK in simulator tests
Use the clang compiler from the SDK to build the simulator test programs
to ensure we pick up the correct libc++.
2021-04-21 13:22:58 -07:00
Michał Górny e414ede2cd [lldb] [test/Register] Initial tests for regsets in core dumps
Add initial tests for reading register sets from core dumps.  This
includes a C++ program to write registers and dump core, resulting core
dumps for Linux, FreeBSD and NetBSD, and the tests to verify them.

The tests are split into generic part, verifying user-specified register
values, and coredump-specific tests that verify memory addresses that
differ for every dump.

At this moment, all platforms support GPRs and FPRs up to XMM for amd64
target.  The i386 target does not work on NetBSD at all, and is missing
FPRs entirely on FreeBSD.

Differential Revision: https://reviews.llvm.org/D91963
2021-04-21 19:41:09 +02:00
Pavel Labath 55ee541653 [lldb/test] Clean up TestThreadSpecificBpPlusCondition inferior
The test had a race that could cause two threads to end up with the same
"thread local" value. I believe this would not cause the test to fail,
but it could cause it to succeed even when the functionality is broken.

The new implementation removes this uncertainty, and removes a lot of
cruft left over from the time this test was written using pthreads.
2021-04-21 17:37:30 +02:00
Pavel Labath 953f580b90 [lldb/test] Modernize lldb-server test inferior
Avoid c string manipulation by introducing a StringRef-like
consume_front operation.
2021-04-21 17:02:41 +02:00
Pavel Labath cd64273f5e [lldb/ELF] Fix IDs of synthetic eh_frame symbols
The code used the total number of symbols to create a symbol ID for the
synthetic symbols. This is not correct because the IDs of real symbols
can be higher than their total number, as we do not add all symbols (and
in particular, we never add symbol zero, which is not a real symbol).

This meant we could have symbols with duplicate IDs, which caused
problems if some relocations were referring to the duplicated IDs. This
was the cause of the failure of the test D97786.

This patch fixes the code to use the ID of the highest (last) symbol
instead.
2021-04-21 11:24:43 +02:00
Jonas Devlieghere eff4f65afb [lldb] Simplify check for nill value in breakpoint_function_callback.test 2021-04-20 21:53:30 -07:00
Jonas Devlieghere cc68799056 [lldb] Stop unsetting LLDB_DEBUGSERVER_PATH from TestLaunchProcessPosixSpawn
We no longer need this after Pavel's change to automatically find debug
servers to test. (3ca7b2d)
2021-04-19 12:28:22 -07:00
Jonas Devlieghere a7712091ea [lldb] Update breakpoint_function_callback.test for different error message
Adjust for the Lua error message printed by Lua 5.4.3.
2021-04-19 12:23:23 -07:00
Caroline Tice 3dc24bc31e [LLDB] Re-land: Use path relative to binary for finding .dwo files.
DWARF allows .dwo file paths to be relative rather than absolute. When
they are relative, DWARF uses DW_AT_comp_dir to find the .dwo
file. DW_AT_comp_dir can also be relative, making the entire search
patch for the .dwo file relative. In this case, LLDB currently
searches relative to its current working directory, i.e. the directory
from which the debugger was launched. This is not right, as the
compiler, which generated the relative paths, can have no idea where
the debugger will be launched. The correct thing is to search relative
to the location of the executable binary. That is what this patch
does.

Differential Revision: https://reviews.llvm.org/D97786
2021-04-16 11:12:39 -07:00
Caroline Tice 042668d092 Revert "[LLDB] Use path relative to binary for finding .dwo files."
This reverts commit b241f3cb29.

Test case is breaking windows builder.
2021-04-15 17:17:44 -07:00
Caroline Tice b241f3cb29 [LLDB] Use path relative to binary for finding .dwo files.
DWARF allows .dwo file paths to be relative rather than absolute. When
they are relative, DWARF uses DW_AT_comp_dir to find the .dwo
file. DW_AT_comp_dir can also be relative, making the entire search
patch for the .dwo file relative. In this case, LLDB currently
searches relative to its current working directory, i.e. the directory
from which the debugger was launched. This is not right, as the
compiler, which generated the relative paths, can have no idea where
the debugger will be launched. The correct thing is to search relative
to the location of the executable binary. That is what this patch
does.

Differential Revision: https://reviews.llvm.org/D97786
2021-04-15 14:43:47 -07:00
Jonas Devlieghere a749bd7639 [lldb] Add addressing_bits to KNOWN_HOST_INFO_KEYS and sort the list
This fixes TestGdbRemoteHostInfo on Apple Silicon.
2021-04-14 14:15:17 -07:00
Pavel Labath ded660495f [lldb/test] Remove the "expect_captures" feature of lldb-server tests
This functionality is used exactly once, and it is trivial to implement
it differently (capture into two distinct variables, and compare for
equality afterwards).
2021-04-14 21:08:55 +02:00
David Spickett 6cdc2239db [lldb][AArch64] Simplify MTE memory region test
By checking for cpu and toolchain features ahead
of time we don't need the custom return codes.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D97684
2021-04-14 11:50:45 +01:00
Jonas Devlieghere accb095512 [lldb] Disable TestClangModulesUpdate.py because it's flaky
The test is failing intermittently on GreenDragon.

rdar://76540904
2021-04-13 20:37:17 -07:00
Pavel Labath 872b1da6ad [lldb/test] s/add_no_ack_remote_stream/do_handshake
These two functions are doing the same thing, only one of them is
sending the packets immediately and the other "queues" them to be sent
later. The first one is better as in case of errors, the backtrace will
point straight to the place that caused them.

Modify the first method to avoid duplication, and ten standardize on it.
2021-04-13 17:10:32 +02:00
David Spickett 29a4d7813c [lldb][AArch64] Only run MTE memory region test if we have MTE
This test is flakey because it tries to read the proc/smaps
file of the first lldb-server process it finds. This process
can finish before we finish doing that.

http://lab.llvm.org:8011/#/builders/96/builds/6634/steps/6/logs/stdio

For now limit this to MTE targets which basically means
QEMU via lldb-dotest, which doesn't have this issue.

I'll fix the race condition shortly.
2021-04-13 15:40:38 +01:00
Pavel Labath 14b9f320fe [lldb] Remote @debugserver_test from TestAppleSimulatorOSType
The annotation is now (since the introduction of @apple_simulator_test)
redundant, and the test could theoretically run on lldb-server too (if
it supported darwin hosts).
2021-04-13 16:09:50 +02:00
David Spickett f152472af5 [lldb] Require x86 for various NativePDB, Breakpad and Minidump tests
These tests fail if you build without the x86 llvm backend.
Either because they use an x86 triple or try to backtrace which
requires some x86 knowledge to see all frames.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D100194
2021-04-13 12:51:48 +00:00
Michał Górny c8d18cba4e Reland "[lldb] [Process] Watch for fork/vfork notifications" for Linux
Big thanks to Pavel Labath for figuring out my mistake.

Differential Revision: https://reviews.llvm.org/D98822
2021-04-13 14:38:31 +02:00
Michał Górny 7da3b44d67 Reland "[lldb] [Process] Watch for fork/vfork notifications" for NetBSD
Differential Revision: https://reviews.llvm.org/D98822
2021-04-13 14:35:44 +02:00
Michał Górny 63d7564105 Reland "[lldb] [Process] Watch for fork/vfork notifications" for FreeBSD
The original commit was reverted because of the problems it introduced
on Linux.  However, FreeBSD should not be affected, so restore that part
and we will address Linux separately.

While at it, remove the dbreg hack as the underlying issue has been
fixed in the FreeBSD kernel and the problem is unlikely to happen
in real life use anyway.

Differential Revision: https://reviews.llvm.org/D98822
2021-04-13 13:19:42 +02:00
Pavel Labath 121cff78a8 Revert "[lldb] [Process] Watch for fork/vfork notifications" and associated followups
This commit has caused the following tests to be flaky:
TestThreadSpecificBpPlusCondition.py
TestExitDuringExpression.py

The exact cause is not known yet, but since both tests deal with
threads, my guess is it has something to do with the tracking of
creation of new threads (which the commit touches upon).

This reverts the following commits:
d01bff8cbd,
ba62ebc48e,
e761b6b4c5,
a345419ee0.
2021-04-13 11:03:06 +02:00
David Spickett a1f3187ca8 [lldb] Require x86 for unwind no-return test
The core file used is built for i386 so we
need the x86 backend to be able to load it.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D100195
2021-04-13 08:51:04 +00:00
David Spickett 96c82166b6 [lldb][Arm/AArch64] Add basic disassemble tests for Arm/AArch64
Previously the test would fail if you built on Arm/AArch64
but did not have the x86 llvm backend enabled.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D100192
2021-04-13 08:49:48 +00:00
David Spickett 8a64d80a95 [lldb] Require x86 backend for a bunch of DWARF tests
By moving them into a folder with a local lit config
requiring x86. All these tests use x86 target triples.

There are two tests that require target-x86_64 because
they run program files (instead of just needing the backend).
Those are moved to the x86 folder also but their REQUIRES are
unchanged.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D100193
2021-04-13 08:47:41 +00:00
Jonas Devlieghere 7dbb4274ef [lldb] Fix replaying TestMemoryRead.py from reproducer
Remap the external file to the one embedded in the reproducer.
2021-04-12 21:10:09 -07:00
Jonas Devlieghere 30f591c386 [lldb] Disable TestLaunchProcessPosixSpawn.py with reproducers 2021-04-12 18:32:10 -07:00
Jonas Devlieghere ba62ebc48e [lldb] Disable Shell/Subporcess with reproducers 2021-04-12 13:08:14 -07:00
Raphael Isemann 34c697c85e [lldb] Don't recursively load types of static member variables in the DWARF AST parser
When LLDB's DWARF parser is parsing the member DIEs of a struct/class it
currently fully resolves the types of static member variables in a class before
adding the respective `VarDecl` to the record.

For record types fully resolving the type will also parse the member DIEs of the
respective class. The other way of resolving is just 'forward' resolving the type
which will try to load only the minimum amount of information about the type
(for records that would only be the name/kind of the type). Usually we always
resolve types on-demand so it's rarely useful to speculatively fully resolve
them on the first use.

This patch changes makes that we only 'forward' resolve the types of static
members. This solves the fact that LLDB unnecessarily loads debug information
to parse the type if it's maybe not needed later and it also avoids a crash where
the parsed type might in turn reference the surrounding class that is currently
being parsed.

The new test case demonstrates the crash that might happen. The crash happens
with the following steps:

1. We parse class `ToLayout` and it's members.

2. We parse the static class member and fully resolve its type
(`DependsOnParam2<ToLayout>`).

3. That type has a non-static class member `DependsOnParam1<ToLayout>` for which
LLDB will try to calculate the size.

4. The layout (and size)`DependsOnParam1<ToLayout>` turns depends on the
`ToLayout` size/layout.

5. Clang will calculate the record layout/size for `ToLayout` even though we are
currently parsing it and it's missing it's non-static member.

The created is missing the offset for the yet unparsed non-static member. If we
later try to get the offset we end up hitting different asserts. Most common is
the one in `TypeSystemClang::DumpValue` where it checks that the record layout
has offsets for the current FieldDecl.

```
        assert(field_idx < record_layout.getFieldCount());
```

Fixed rdar://67910011

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D100180
2021-04-12 14:37:07 +02:00
Muhammad Omair Javaid 428b17ce70 [LLDB] Fix buildbots breakage due to TestGuessLanguage.py
Fix LLDB buidbot breakage due to D99250.

Differential Revision: https://reviews.llvm.org/D99250
2021-04-12 15:10:46 +05:00
Alexander Belyaev 39ae25fb8c [lldb] Update object.test after 'nosync' inference was enabled.
https://reviews.llvm.org/D99769
2021-04-09 10:04:15 +02:00
Jonas Devlieghere e761b6b4c5 [lldb] (Temporarily) disable vfork-follow-parent-wp.test on Darwin
The test is failing on GreenDragon. Pinged Michał in D98822.
2021-04-08 15:05:27 -07:00
Michał Górny d01bff8cbd [lldb] [test] Skip clone() tests on Linux/aarch64 2021-04-08 20:03:45 +02:00
Michał Górny a345419ee0 [lldb] [Process] Watch for fork/vfork notifications
Watch for fork(2)/vfork(2) (also fork/vfork-style clone(2) on Linux)
notifications and explicitly detach the forked child process, and add
initial tests for these cases.  The code covers FreeBSD, Linux
and NetBSD process plugins.  There is no new user-visible functionality
provided -- this change lays foundations over subsequent work on fork
support.

Differential Revision: https://reviews.llvm.org/D98822
2021-04-08 18:49:50 +02:00
Pavel Labath 1e511bb1be [lldb] Re-skip TestVSCode_launch
The test is flaky (sleeps didn't help).
2021-04-08 16:31:18 +02:00
Michał Górny b601c67192 [lldb] [client] Support for multiprocess extension
Add a minimal support for the multiprocess extension in gdb-remote
client.  It accepts PIDs as part of thread-ids, and rejects PIDs that
do not match the current inferior.

Differential Revision: https://reviews.llvm.org/D99603
2021-04-08 13:45:07 +02:00
Jason Molenda d9773c1b4e Reorg firmware corefile tests; add test for OS plugin loading
A little cleanup to how these firmware corefile tests are done; add
a test that loads a dSYM that loads an OS plugin, and confirm that
the OS plugin's threads are created.
2021-04-08 01:45:25 -07:00
Shafik Yaghmour 79ac5bbb96 [LLDB] Clarifying the documentation for variable formatting wrt to qualifiers and adding a test that demonstrates this
When looking up user specified formatters qualifiers are removed from types before matching,
I have added a clarifying example to the document and added an example to a relevant test to demonstrate this behavior.

Differential Revision: https://reviews.llvm.org/D99827
2021-04-07 14:29:12 -07:00
Jordan Rupprecht f49a4440d3 [lldb][Editline] Fix crash when navigating through empty command history.
An empty history entry can happen by entering the expression evaluator an immediately hitting enter:

```
$ lldb
(lldb) e
Enter expressions, then terminate with an empty line to evaluate:
  1:  <hit enter>
```

The next time the user enters the expression evaluator, if they hit the up arrow to load the previous expression, lldb crashes. This patch treats empty history sessions as a single expression of zero length, instead of an empty list of expressions.

Fixes http://llvm.org/PR49845.

Differential Revision: https://reviews.llvm.org/D100048
2021-04-07 10:48:47 -07:00
Jonas Devlieghere 710651c61d [lldb] Fix bug where memory read --outfile is not truncating the file
The memory read --outfile command should truncate the output when unless
--append-outfile. Fix the bug and add a test.

rdar://76062318

Differential revision: https://reviews.llvm.org/D99890
2021-04-06 09:16:28 -07:00
Jim Ingham be0ced03ba Revert "Revert "Add support for fetching signed values from tagged pointers.""
This reverts commit 602ab188a7.

The patch replicated an lldbassert for a certain type of NSNumber for tagged
pointers.  This really shouldn't be an assert since we don't do anything wrong
with these numbers, we just don't print a summary.  So this patch changed the
lldbassert to a log message in reverting the revert.
2021-04-05 18:18:26 -07:00
Dave Lee d1a1798e51 [lldb] Replace unneeded use of Foundation with ObjectiveC in tests (NFC)
When referencing `NSObject`, it's enough to import `objc/NSObject.h`. Importing `Foundation` is unnecessary in these cases.

Differential Revision: https://reviews.llvm.org/D99867
2021-04-04 20:04:41 -07:00
Dave Lee 10ed479d73 [lldb] Import ObjectiveC module instead of Foundation in test
Use `@import ObjectiveC` instead of `@import Foundation`, as the former is all
that's needed, and results in fewer clang modules being built.

This results in the following clang modules *not* being built for this test.

ApplicationServices
CFNetwork
ColorSync
CoreFoundation
CoreGraphics
CoreServices
CoreText
DiskArbitration
Dispatch
Foundation
IOKit
ImageIO
Security
XPC
_Builtin_intrinsics
launch
libkern
os_object
os_workgroup

Differential Revision: https://reviews.llvm.org/D99859
2021-04-04 20:04:26 -07:00
Jason Molenda 602ab188a7 Revert "Add support for fetching signed values from tagged pointers."
This reverts commit 4d9039c8dc.

This is causing the greendragon bots to fail most of the time when
running TestNSDictionarySynthetic.py.  Reverting until Jim has a chance
to look at this on Monday.  Running the commands from that test from
the command line, it fails 10-13% of the time on my desktop.

This is a revert of Jim's changes in https://reviews.llvm.org/D99694
2021-04-04 01:47:35 -07:00
Muhammad Omair Javaid d302e33b97 [LLDB] Sleep for 5 second TestVSCode_launch test_progress_events
This increases sleep time to 5 seconds as the test still fails
intermittently. If failure persists then we will disable/fix the
test.
2021-04-03 03:04:37 +05:00
Muhammad Omair Javaid 455973162c [LLDB] Skip TestLoadUsingLazyBind.py on arm/linux 2021-04-02 15:54:48 +05:00
Jason Molenda 78a1412845 Handle all standalone combinations of LC_NOTEs w/ & w/o addr & uuid
Fill out ProcessMachCore::DoLoadCore to handle LC_NOTE hints with
a UUID or with a UUID+address, and load the binary at the specified
offset correctly.  Add tests for all four combinations.  Change
DynamicLoaderStatic to not re-set a Section's load address in the
Target if it's already been specified.

Differential Revision: https://reviews.llvm.org/D99571
rdar://51490545
2021-04-01 18:59:36 -07:00
Greg Clayton 2d733923b8 Fix "image lookup --address" Summary results for inline functions.
Inline callstacks were being incorrectly displayed in the results of "image lookup --address". The deepest frame wasn't displaying the line table line entry, it was always showing the inline information's call file and line on the previous frame. This is now fixed and has tests to make sure it doesn't regress.

Differential Revision: https://reviews.llvm.org/D98761
2021-04-01 11:36:26 -07:00
Jim Ingham 4d9039c8dc Add support for fetching signed values from tagged pointers.
The ObjC runtime offers both signed & unsigned tagged pointer value
accessors to tagged pointer providers, but lldb's tagged pointer
code only implemented the unsigned one.  This patch adds an
emulation of the signed one.

The motivation for doing this is that NSNumbers use the signed
accessor (they are always signed) and we need to follow that in our
summary provider or we will get incorrect values for negative
NSNumbers.

The data-formatter-objc test file had NSNumber examples (along with lots of other
goodies) but the NSNumber values weren't tested.  So I also added
checks for those values to the test.

I also did a quick audit of the other types in that main.m file, and
it looks like pretty much all the other values are either intermediates
or are tested.

Differential Revision: https://reviews.llvm.org/D99694
2021-04-01 10:59:25 -07:00
Stella Stamenova 802c5ce364 [lldb] Un-XFAIL TestAutoInstallMainExecutable on Windows 2021-04-01 08:46:23 -07:00
Pavel Labath bad5ee15ea [lldb] Make TestLoadUsingLazyBind work on linux
and probably other posix oses. Use extra_images to ensure
LD_LIBRARY_PATH is set correctly.

Also take the opportunity to remove hand-rolled library extension
management code in favor of the existing one.
2021-04-01 14:49:42 +02:00
Pavel Labath 48e3da1351 [lldb] Rewrite TestAutoInstallMainExecutable logic
The test uses debug info from one binary to debug a different one. This
does not work on macos, and its pure luck that it works elsewhere (the
variable that it inspects happens to have the same address in both).

The purpose of this test is to verify that lldb has not overwritten the
target executable. That can be more easily achieved by checking the exit
code of the binary, so change the test to do that.

Also remove the llgs_test decorator, as it's preventing the test from
running on macos. All the test needs is the platform functionality of
lldb-server, which is available everywhere.
2021-04-01 14:20:20 +02:00
Michał Górny fcea4181bb [lldb] [test] Mark lldb-server multiprocess tests as LLGS cat 2021-04-01 14:17:47 +02:00
Muhammad Omair Javaid b468f0e165 [LLDB] Fix sync issue in TestVSCode_launch.test_progress_events
This fixes flakiness in TestVSCode_launch.test_progress_events
vscode.progress_events some times failed to populate in time for
follow up iterations.

Adding a minor delay before the the for the loop fixes the issue.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D99497
2021-04-01 14:16:54 +05:00
Muhammad Omair Javaid dd2a63e1ee Revert "Revert "[LLDB] Arm64/Linux test case for MTE and Pointer Authentication regset""
This reverts commit feb6f2c78f.
2021-04-01 14:10:14 +05:00
Jonas Devlieghere d1828937ed [lldb] Remove references to LLDB_CAPTURE_REPRODUCER
Remove the remaining references to LLDB_CAPTURE_REPRODUCER. I removed
the functionality in an earlier commit but forgot that there was a
corresponding test and logic to unset it in our test suite.
2021-03-31 21:42:00 -07:00
Muhammad Omair Javaid feb6f2c78f Revert "[LLDB] Arm64/Linux test case for MTE and Pointer Authentication regset"
This reverts commit 9ab6771800.

Reason: LLDB AArch64/Linux buildbot failure.
2021-03-31 17:12:14 +05:00
Muhammad Omair Javaid 98d070396d Revert "[LLDB] Skip TestVSCode_disconnect.test_launch arm/linux"
This reverts commit 73cf85e527.
2021-03-31 15:22:49 +05:00
Walter Erquinigo 0b69756110 [trace][intel-pt] Implement trace start and trace stop
This implements the interactive trace start and stop methods.

This diff ended up being much larger than I anticipated because, by doing it, I found that I had implemented in the beginning many things in a non optimal way. In any case, the code is much better now.

There's a lot of boilerplate code due to the gdb-remote protocol, but the main changes are:

- New tracing packets: jLLDBTraceStop, jLLDBTraceStart, jLLDBTraceGetBinaryData. The gdb-remote packet definitions are quite comprehensive.
- Implementation of the "process trace start|stop" and "thread trace start|stop" commands.
- Implementaiton of an API in Trace.h to interact with live traces.
- Created an IntelPTDecoder for live threads, that use the debugger's stop id as checkpoint for its internal cache.
- Added a functionality to stop the process in case "process tracing" is enabled and a new thread can't traced.
- Added tests

I have some ideas to unify the code paths for post mortem and live threads, but I'll do that in another diff.

Differential Revision: https://reviews.llvm.org/D91679
2021-03-30 17:31:37 -07:00
Muhammad Omair Javaid 9ab6771800 [LLDB] Arm64/Linux test case for MTE and Pointer Authentication regset
This patch adds a test case to test AArch64 dynamic register sets.
This tests for the availability of certain register sets and query
their registers accordingly.

Reviewed By: labath, DavidSpickett

Differential Revision: https://reviews.llvm.org/D96463
2021-03-31 04:39:14 +05:00
Jonas Devlieghere e3d3327edb [lldb] Remove reproducer from previous test run 2021-03-30 10:11:20 -07:00
Michał Górny c62ef12079 [lldb] [test] Mark more lldb-server tests xfail on Windows 2021-03-30 18:49:04 +02:00
Pavel Labath 0bbe2a3c8a [lldb] More missing includes in TestGdbRemote_vContThreads 2021-03-30 18:05:31 +02:00
Pavel Labath 9709186681 [lldb] Add missing include in TestGdbRemote_vContThreads test
should fix the arm builtbots.
2021-03-30 17:38:52 +02:00
Pavel Labath bbae06652e [lldb] Fix TestStopOnSharedlibraryEvents.py on linux
and hopefully other ELF OSes. The problem was a missing "extra_images"
startup argument (which ensures LD_LIBRARY_PATH is set properly).
2021-03-30 17:38:51 +02:00
Pavel Labath 04b766dab0 [lldb/test] Deflake TestGdbRemote_vContThreads even more
This patch fixes an issue, where if the thread has a signal blocked when
we try to inject it into the process (via vCont), then instead of
executing straight away, the injected signal will trigger another stop
when the thread unblocks the signal.

As (linux) threads start their life with SIGUSR1 (among others)
disabled, and only enable it during initialization, injecting the signal
during this window did not behave as expected. The fix is to change the
test to ensure the signal gets injected with the signal unblocked.

The simplest way to do this was to write a dedicated inferior for this
test. I also created a new header to factor out the function retrieving
the (os-specific) thread id.
2021-03-30 17:03:14 +02:00
Pavel Labath ce03a86237 [lldb] Remove linux/mips debugging support
As discussed on lldb-dev
<https://lists.llvm.org/pipermail/lldb-dev/2021-March/016777.html> the
mips code is unmaintained and untested. It also carries a lot of
technical debt which is not limited to mips-specific code.

Generic mips support remains (and is going to be used by the upcoming
freebsd code). Resurrecting mips support should be a matter of re-adding
the relevant register context files (while avoiding reintroducing the
debt).
2021-03-30 15:24:43 +02:00
Michał Górny 6c1a8039de [lldb] [server] Support for multiprocess extension
Add a minimal support for the multiprocess extension in lldb-server.
The server indicates support for it via qSupported, and accepts
thread-ids containing a PID.  However, it still does not support
debugging more than one inferior, so any other PID value results
in an error.

Differential Revision: https://reviews.llvm.org/D98482
2021-03-30 15:09:27 +02:00
Muhammad Omair Javaid 42c3b5e5b6 Fix cleanup error in TestVSCode_disconnect.test_launch
TestVSCode_disconnect.test_launch fails with clean up error because
disconnect gets called twice once from the test case and once from
the tear down hook.

This patch disables disconnect after its been called from test_launch

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D99491
2021-03-30 15:36:45 +05:00
Raphael Isemann 6919c58262 [lldb] Add a test for Obj-C properties with conflicting names
This is apparently allowed in Objective-C so we should test this in LLDB.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D99513
2021-03-30 11:08:16 +02:00
Raphael Isemann 69e7b74578 [lldb][NFC] Add a test case for Objective-C properties with conflicting names
This is an LLDB test for the ASTImporter crash that got fixed in D99077.
The test is using Clang modules for the properties as it seems the conflicting
names are not actually correctly handled when generating debug information
(only the first property is emitted and the second one is ignored in the current
clang ToT).
2021-03-29 12:33:07 +02:00
Raphael Isemann 3c95bdf9fa [lldb] Don't search for system specific strings in assert.test
Commit 6bc1e69de2 changed the search string
to also check for the generated strings that surround the plain assert:

    Assertion `false && "lldb-test assert"' failed
                                         ^^^^^^^^^

This causes the test to fail on setups where the generated assert message
looks different. E.g., on macOS the generated message looks like this:

    Assertion failed: (false && "lldb_assert failed"), function lldb_assert

This reverts the old behaviour of just checking for the actual string we
have inside LLDB.
2021-03-29 10:46:14 +02:00
Jan Kratochvil 6bc1e69de2 [lldb] Fix Error/assert.test regression with symbols
LLDB on Linux built with symbols is showing this error.
Without symbols it still PASSes:
  lldb-test: .../lldb/source/Utility/LLDBAssert.cpp:29: void lldb_private::lldb_assert(bool, const char *, const char *, const char *, unsigned int): Assertion `false && "lldb_assert failed"' failed.

With symbols it FAILs:
  lldb-test: .../lldb/tools/lldb-test/lldb-test.cpp:1086: int opts::assert::lldb_assert(lldb_private::Debugger &): Assertion `false && "lldb-test assert"' failed.

Differential Revision: https://reviews.llvm.org/D99462
2021-03-29 08:16:43 +02:00
Jonas Devlieghere 7f76c70d85 [lldb] Fix capitalization in CMake status message
s/LLDB Tests/LLDB tests/
2021-03-27 21:39:39 -07:00
Jonas Devlieghere 38edd23b8c [lldb] Fix TestAppleSimulatorOSType for older watchOS SDKs
Older watchOS SDKs *only* support i386 so we can't use x86_64/arm64
unconditionally.
2021-03-26 20:28:42 -07:00
Jonas Devlieghere df0f9e0447 [lldb] Stop using i386 for the watchOS simulator
This keeps breaking on my machine. It's time to move on.
2021-03-26 17:09:45 -07:00
Pavel Labath 5c3aed98af [lldb] Skip TestVSCode_launch.test_progress_events on linux
It's flaky everywhere, not just arm.
2021-03-26 17:26:44 +01:00
Pavel Labath 21589d0766 [lldb] XFAIL TestGdbRemote_vContThreads on macos
It seems debugserver does not implement these packets.
2021-03-26 17:26:44 +01:00
Pavel Labath 22e2d117d3 [lldb] Really fix dwarf5-debug_line-file-index.s
It's not enough the change the comment -- one has to actually change the
constant before it. :/
2021-03-26 17:26:44 +01:00
Muhammad Omair Javaid 73cf85e527 [LLDB] Skip TestVSCode_disconnect.test_launch arm/linux
TestVSCode_disconnect.test_launch hangs in tear down and times out
Arm linux. I am marking it skipped for the buildbot while looking
into failure.
2021-03-26 15:54:42 +05:00
Muhammad Omair Javaid c3152536fd [LLDB] Skip TestVSCode_launch.test_progress_events arm/linux
TestVSCode_launch.test_progress_events is mysteriously failing on arm
linux. I am marking it skipped for the buildbot while looking into
failure.
2021-03-26 04:38:31 +05:00
Raphael Isemann d90b1230ea [lldb] Fix TestVSCode.test_progress_events on Linux due to vdso
This currently fails when we get the module for `[vdso]` which doesn't have
any parsing event associated with it as it's just created from memory.
2021-03-25 10:48:58 +01:00
Med Ismail Bennani fad34da7fd Revert "[lldb/Plugins] Add ScriptedProcess Process Plugin"
Reverting commit b09d44b6ae, since it breaks
the windows bots: https://lab.llvm.org/buildbot/#/builders/83/builds/4993

It seems to crash the `TestIRMemoryMapWindows.test` test.
2021-03-24 21:31:16 +01:00
Greg Clayton e122877f10 Add a progress class that can track long running operations in LLDB.
LLDB can often appear deadlocked to users that use IDEs when it is indexing DWARF, or parsing symbol tables. These long running operations can make a debug session appear to be doing nothing even though a lot of work is going on inside LLDB. This patch adds a public API to allow clients to listen to debugger events that report progress and will allow UI to create an activity window or display that can show users what is going on and keep them informed of expensive operations that are going on inside LLDB.

Differential Revision: https://reviews.llvm.org/D97739
2021-03-24 12:58:13 -07:00
Jim Ingham 3fd7d0d281 Disable the tests except on Darwin.
The commit passes the tests on Darwin.  The failure on linux shows
that this change was not sufficient to get this setting to work on linux,
but the behavior is the same as before the patch & test, and it caused
no new failures.

So marking the tests as Darwin only till someone can debug the Linux
issue.
2021-03-24 12:19:18 -07:00
Jim Ingham c8faa8c266 Make the stop-on-sharedlibrary-events setting work.
The StopInfoBreakpoint::PerformAction was overriding the synchronous
breakpoint's ShouldStop report.  Fix that and add a test.

This fixes two bugs in the original submission:
1) Actually generate both dylibs by including the second one in the Makefile
2) Don't ask synchronous callbacks for their opinion on whether to stop
   in the async context, that info is taken care of by recording the m_should_stop
   on entry to PerformAction.

Differential Revision: https://reviews.llvm.org/D98914
2021-03-24 11:15:11 -07:00
Med Ismail Bennani b09d44b6ae [lldb/Plugins] Add ScriptedProcess Process Plugin
This patch introduces Scripted Processes to lldb.

The goal, here, is to be able to attach in the debugger to fake processes
that are backed by script files (in Python, Lua, Swift, etc ...) and
inspect them statically.

Scripted Processes can be used in cooperative multithreading environments
like the XNU Kernel or other real-time operating systems, but it can
also help us improve the debugger testing infrastructure by writting
synthetic tests that simulates hard-to-reproduce process/thread states.

Although ScriptedProcess is not feature-complete at the moment, it has
basic execution capabilities and will improve in the following patches.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-24 19:10:58 +01:00
David Zarzycki 952bc6c92e Revert "[lldb/Plugins] Add ScriptedProcess Process Plugin"
This reverts commit dd391e1ef7.

This patch causes 17 LLDB test regressions on Fedora 33 (x86-64).
2021-03-24 07:07:22 -04:00
Raphael Isemann c68a645acb [lldb] Add llgs_test decorator back to TestAutoInstallMainExecutable
This got removed in 68bb51acd5 and this enabled
the test on macOS (where it just causes lldb-server to crash). Re-adding the
decorator to get the tests passing again.
2021-03-24 10:36:01 +01:00
Med Ismail Bennani dd391e1ef7 [lldb/Plugins] Add ScriptedProcess Process Plugin
This patch introduces Scripted Processes to lldb.

The goal, here, is to be able to attach in the debugger to fake processes
that are backed by script files (in Python, Lua, Swift, etc ...) and
inspect them statically.

Scripted Processes can be used in cooperative multithreading environments
like the XNU Kernel or other real-time operating systems, but it can
also help us improve the debugger testing infrastructure by writting
synthetic tests that simulates hard-to-reproduce process/thread states.

Although ScriptedProcess is not feature-complete at the moment, it has
basic execution capabilities and will improve in the following patches.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-23 18:24:47 +01:00
Med Ismail Bennani f3176f5fed [lldb/bindings] Add Python ScriptedProcess base class to lldb module
In order to facilitate the writting of Scripted Processes, this patch
introduces a `ScriptedProcess` python base class in the lldb module.

The base class holds the python interface with all the - abstract -
methods that need to be implemented by the inherited class but also some
methods that can be overwritten.

This patch also provides an example of a Scripted Process with the
`MyScriptedProcess` class.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-23 18:24:47 +01:00
Jonas Devlieghere eb26afbafe Re-land "[lldb] Make the API, Shell and Unit tests independent lit test suites"
The commit got reverted because the tests were being run twice because
of the overlapping test_exec_root. Pavel has since fixed that in
8248dd91d7.
2021-03-22 14:36:43 -07:00
Jonas Devlieghere 683590a203 [lldb] config.test_exec_root is set by lit.cfg.py
Don't configure `test_exec_root` in lit.site.cfg.py. It always gets
overwritten by lit.cfg.py based on `lldb_obj_root`.
2021-03-22 14:36:43 -07:00
Pavel Labath d9643af119 [lldb] Re-disable dwarf5-debug_line-file-index.s
The fix in 10d54e2f did not work.
2021-03-22 16:29:06 +01:00
Pavel Labath 10d54e2f8d [lldb] Attempt to fix dwarf5-debug_line-file-index.s
The file contained bogus input - the DIE list was not properly
terminated. This should not cause a crash, but it seems it was crashing
at least on linux arm and x86 windows.
2021-03-22 15:27:25 +01:00
Pavel Labath 8248dd91d7 [lldb] Fix test_exec_root of API tests
lit has grown a feature where it stores the runtimes of all tests.
Normally, these times should be stored in the build directory, but
because our API tests have set test_exec_root to point to the source
tree, it has ended up polluting our checkout and led to the
.lit_test_times.txt being committed to the repository.

Delete this file, and adjust the exec root of API tests. I've also
needed to adjust the root of Shell tests, in order to avoid the two
overlapping.
2021-03-22 15:15:48 +01:00
Muhammad Omair Javaid 89aab750b0 [LLDB] XFAIL dwarf5-debug_line-file-index.s on arm-linux
Tests dwarf5-debug_line-file-index.s fails on arm-linux-gnueabihf.
Bug # 49678 has been filed against it.
2021-03-22 17:06:53 +05:00
Kim-Anh Tran 68dafe40a6 [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF
SymbolFileDWARF::ResolveSymbolContext is currently unaware that in DWARF5 the primary file is specified at file index 0. As a result it misses to correctly resolve the symbol context for the primary file when DWARF5 debug data is used and the primary file is only specified at index 0.

This change makes use of CompileUnit::ResolveSymbolContext to resolve the symbol context. The ResolveSymbolContext in CompileUnit has been previously already updated to reflect changes in DWARF5
and contains a more readable version. It can resolve more, but will also do a bit more work than
SymbolFileDWARF::ResolveSymbolContext (getting the Module, and going through SymbolFileDWARF::ResolveSymbolContextForAddress), however, it's mostly directed by $resolve_scope
what will be resolved, and ensures that code is easier to maintain if there's only one path.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D98619
2021-03-22 08:44:16 +01:00
Jonas Devlieghere e76b86642f Revert "[lldb] Make the API, Shell and Unit tests independent lit test suites"
This reverts commit 6c52d4fd4c.
2021-03-19 17:57:26 -07:00
Vedant Kumar 4bd2bfb6ec [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY (reapply)
In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

This was previously committed as cb8c1ee269 and reverted due to
unknown failures on the Linux bots. This version adds additional asserts
to check that the shared objects are where we expect them & that calling
f1() from libt1 produces the expected value. The Linux failure is
tracked by https://bugs.llvm.org/show_bug.cgi?id=49656.

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

Differential Revision: https://reviews.llvm.org/D98879
2021-03-19 16:06:00 -07:00
Vedant Kumar d8d5ef2e9d Revert "[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY"
This reverts commit cb8c1ee269. The test
is failing on Debian for unknown reasons.

https://lab.llvm.org/buildbot/#/builders/68/builds/8990
2021-03-19 15:26:16 -07:00
Vedant Kumar cb8c1ee269 [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY
In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

Differential Revision: https://reviews.llvm.org/D98879
2021-03-19 15:13:43 -07:00
Jonas Devlieghere cdac60107d [lldb] Update assert.test to be less strict
Be less strict when checking for the assert substring.
2021-03-19 14:31:56 -07:00
Jonas Devlieghere e089b5e9e1 [lldb] Call os_log_fault on lldb_assert
Call `os_log_fault` when an lldb assert fails. We piggyback off
`LLVM_SUPPORT_XCODE_SIGNPOSTS`, which also depends on `os_log`, to avoid
having to introduce another CMake check and corresponding define.

This patch also adds a small test using lldb-test that verifies we abort
with a "regular" assertion when asserts are enabled.

Differential revision: https://reviews.llvm.org/D98987
2021-03-19 14:23:50 -07:00
Jim Ingham 9d081a7ffe Revert "Make the stop-on-sharedlibrary-events setting work."
This reverts commit 9406d43138.

I messed up a test, and when I got it right it was failing.  The changed logic
doesn't work quite right (now the async callback called at sync time is
forcing us to stop.  I need to be a little more careful about that.
2021-03-19 12:38:41 -07:00
Jim Ingham e8e07b3a5e Revert "Skip all the tests for Windows."
This reverts commit a8d62fc8ff.
2021-03-19 12:38:23 -07:00
Jim Ingham a8d62fc8ff Skip all the tests for Windows. 2021-03-19 12:05:16 -07:00
Jim Ingham 9406d43138 Make the stop-on-sharedlibrary-events setting work.
We weren't taking into account the "m_should_stop" setting that the
synchronous breakpoint callback had already set when we did PerformAction
in the StopInfoBreakpoint.  So we didn't obey its instructions when it
told us to stop.  Fixed that and added some tests both for when we
just have the setting, and when we have the setting AND other breakpoints
at the shared library load notification breakpoint address.

Differential Revision: https://reviews.llvm.org/D98914
2021-03-19 12:02:16 -07:00
Jonas Devlieghere 6c52d4fd4c [lldb] Make the API, Shell and Unit tests independent lit test suites
Make the API, Shell and Unit tests independent lit test suites. This
allows us to specify different dependencies and skip rebuilding all the
unit test (which is particularly expensive) when running check-lldb-api
or check-lldb-shell.

This does not change the autogenerated targets such as
check-lldb-shell-driver or the top level check-lldb target, which all
continue to work as before.

Differential revision: https://reviews.llvm.org/D98842
2021-03-19 11:13:46 -07:00
Muhammad Omair Javaid 7dd76cccca [LLDB] Skip TestExitDuringExpression on aarch64/linux buildbot
TestExitDuringExpression test_exit_before_one_thread_unwind fails
sporadically on both Arm and AArch64 linux buildbots.
This seems like a thread timing issue. I am marking it skip for now.
2021-03-19 15:30:10 +05:00
Jim Ingham 71c4da83b6 Don't assume that stepping out of a function will land on the next line.
For instance, some recent clang emits this code on x86_64:

    0x100002b99 <+57>: callq  0x100002b40               ; step_out_of_here at main.cpp:11
->  0x100002b9e <+62>: xorl   %eax, %eax
    0x100002ba0 <+64>: popq   %rbp
    0x100002ba1 <+65>: retq

and the "xorl %eax, %eax" is attributed to the same line as the callq.  Since
step out is supposed to stop just on returning from the function, you can't guarantee
it will end up on the next line.  I changed the test to check that we were either
on the call line or on the next line, since either would be right depending on the
debug information.
2021-03-18 17:44:17 -07:00
Jonas Devlieghere 36335fe753 [lldb] Move Apple simulators test targets under API
Move the Apple simulators test targets as they only matter for the API
tests.

Differential revision: https://reviews.llvm.org/D98880
2021-03-18 13:55:37 -07:00
Pavel Labath 0c208d1f42 [lldb] Fix flakyness in TestGdbRemote_vContThreads
The cause is the non-async-signal-safety printf function (et al.). If
the test managed to interrupt the process and inject a signal before the
printf("@started") call returned (but after it has actually written the
output), that string could end up being printed twice (presumably,
because the function did not manage the clear the userspace buffer, and
so the print call in the signal handler would print it once again).

This patch fixes the issue by replacing the printf call in the signal
handler with a sprintf+write combo, which should not suffer from that
problem (though I wouldn't go as far as to call it async signal safe).
2021-03-18 20:41:55 +01:00
Pavel Labath 68bb51acd5 [lldb] Fix TestAutoInstallMainExecutable.py
Fix the test to account for recent test infrastructure changes, and make
it run locally to increase the chances of it continuing to work in the
future.
2021-03-18 15:20:44 +01:00
Michał Górny 76c8a016a1 [lldb] [test] Skip vCont tests on Windows 2021-03-17 19:22:58 +01:00
Michał Górny 9cf21da776 [lldb] [test] Fix TestGdbRemote_vContThreads.py logic
The TestGdbRemote_vContThreads.py were introduced to test NetBSD process
plugin's capability of sending per-thread and per-process signals.
However, at some point the tests started failing.  From retrospective,
it is possible that they were relying on some bug in the plugin's
original signal handling.

Fix the tests not to expect the process to terminate after receiving
the signals.  Instead, scan for output indicating that the signals were
received and match thread IDs in it.  Enable 'signal to all threads'
test everywhere as it works fine on Linux.  Add a new test for vCont
packet without specific thread IDs.  Introduce a helper function
to cover the common part of tests.

While this does not fix all the problems on NetBSD, it enables a subset
of the tests on other systems.  I am planning to add more tests
to the group while implementing multiprocess extension for vCont.

Differential Revision: https://reviews.llvm.org/D98749
2021-03-17 17:30:28 +01:00
Walter Erquinigo b5657d1fbf Fix 34885bffdf
It failed https://lab.llvm.org/buildbot/#/builders/17/builds/5262 and
the fix is simply to relax a regex expression in a test.
2021-03-15 16:36:32 -07:00
Walter Erquinigo 34885bffdf [lldb-vscode] Handle request_evaluate's context attribute
Summary:
The request "evaluate" supports a "context" attribute, which is sent by VSCode. The attribute is defined here https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Evaluate

The "clipboard" context is not yet supported by lldb-vscode, so we can forget about it for now. The 'repl' (i.e. Debug Console) and 'watch' (i.e. Watch Expression) contexts must use the expression parser in case the frame's variable path is not enough, as the user expects these expressions to never fail. On the other hand, the 'hover' expression is invoked whenever the user hovers on any keyword on the UI and the user is fine with the expression not being fully resolved, as they know that the 'repl' case is the fallback they can rely on.

Given that the 'hover' expression is invoked many many times without the user noticing it due to it being triggered by the mouse, I'm making it use only the frame's variable path functionality and not the expression parser. This should speed up tremendously the responsiveness of a debug session when the user only sets source breakpoints and inspect local variables, as the entire debug info is not needed to be parsed.

Regarding tests, I've tried to be as comprehensive as possible considering a multi-file project. Fortunately, the results from the "hover" case are enough most of the times.

Differential Revision: https://reviews.llvm.org/D98656
2021-03-15 15:09:23 -07:00
Muhammad Omair Javaid 0df28acffb [LLDB] Skip TestExitDuringExpression on arm/linux buildbot
TestExitDuringExpression test_exit_before_one_thread_unwind fails
sporadically on arm/linux. This seems like a thread timing issue.
I am marking it skip for now.
2021-03-15 16:03:06 +05:00
Pavel Labath 463863fffe [lldb] Move PlatformPOSIX::ConnectToWaitingProcesses to RemoteAwarePlatform
The functionality is not posix specific. Also force the usage of the
gdb-remote process plugin in the gdb platform class.

This is not sufficient to make TestPlatformConnect pass on windows (it
seems it suffers from module loading issues, unrelated to this test),
but it at least makes it shut down correctly, so I change the skip to an
xfail.
2021-03-14 22:43:52 +01:00
Raphael Isemann aada8984e6 [lldb] Add missing debugserver dependency to check-lldb
D96202 removes the test dependency on debugserver which is causing a bunch of
tests to fail on a clean build.

This patch re-adds the dependency. I decided to not add the dependency in the
`test/API` folder as we actually need it in all kinds of tests (we have shell,
API and a few unit tests such as the LLDBServerTests that depend on the
debugserver binary). lldb-server is also handled in the same way.

Reviewed By: JDevlieghere, labath

Differential Revision: https://reviews.llvm.org/D98196
2021-03-11 15:55:43 +01:00
Pavel Labath 3d47f1f9b8 [lldb] Remove implicit_const_form_support.test
It is superseded by dwarf5-implicit-const.s (added in D98197), which tests it more thoroughly.
2021-03-11 10:47:06 +01:00
Michał Górny f47a84bc33 [lldb] [test] Update XFAILs for FreeBSD/aarch64 2021-03-10 18:36:19 +01:00
Jonas Devlieghere cc52ea3001 [lldb] Update crashlog script for JSON changes
Update the crashlog script for changes to the JSON schema.

rdar://75122914

Differential revision: https://reviews.llvm.org/D98219
2021-03-09 10:44:34 -08:00
Jonas Devlieghere c2d2adbce9 [lldb] Propagate XDG_CACHE_HOME environment variable to tests
This variable is used to reducing the likelihood of hitting module cache
issues in CI where different branches can potentially run on the same
machine.
2021-03-09 10:44:34 -08:00
Jonas Devlieghere 080ded7445 [lldb] Use lit.with_system_environment to propagate env variables
Use lit's with_system_environment function to propagate environment
variables to the tests. Include the usual suspects, as well as the
variables already explicitly forwarded.
2021-03-09 10:44:34 -08:00
Stefan Gränitz 2ff533cba1 [lldb][JITLoaderGDB] Test debug support in JITLink
LLVM OrcJIT is shifting from RuntimeDyld to JITLink. Starting with D96627 I am planning to add debug support. It would be great to have test coverage for it in LLDB early on.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D96634
2021-03-09 14:10:52 +01:00
Jan Kratochvil cf806d91d5 [lldb] Fix DWARF-5 DW_FORM_implicit_const (used by GCC)
Differential Revision: https://reviews.llvm.org/D98197
2021-03-09 10:23:05 +01:00
Jan Kratochvil 63abbeb6a8 [nfc] [lldb] [testsuite] Cleanup of recently added dwarf5-line-strp.s 2021-03-08 17:41:56 +01:00
Med Ismail Bennani c964741996 [lldb/API] Add CommandInterpreter::{Get,Set}PrintErrors to SBAPI (NFC)
This patch exposes the getter and setter methods for the command
interpreter `print_errors` run option.

rdar://74816984

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-05 19:33:33 +01:00
Med Ismail Bennani 36eab4634f [lldb/Interpreter] Add `interpreter.repeat-previous-command` setting
This patch introduces a new interpreter setting to prevent LLDB from
re-executing the previous command when passing an empty command.

This can be very useful when performing actions that requires a long
time to complete.

To preserve the original behaviour, the setting defaults to `true`.

rdar://74983516

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-05 19:33:32 +01:00
Pavel Labath bf3ac994c4 [lldb] Apply gdb-remote timeout to platform connections as well
We have a plugin.process.gdb-remote.packet-timeout setting, which can be
used to control how long the lldb client is willing to wait before
declaring the server side dead. Our test suite makes use of this
feature, and sets the setting value fairly high, as the low default
value can cause flaky tests, particularly on slower bots.

After fixing TestPlatformConnect (one of the few tests exercising the
remote platform capabilities of lldb) in 4b284b9ca, it immediately
started being flaky on the arm bots. It turns out this is because the
packet-timeout setting is not being applied to platform connections.

This patch makes the platform connections also respect the value of this
setting. It also adds a test which checks that the timeout value is
being honored.

Differential Revision: https://reviews.llvm.org/D97769
2021-03-04 14:46:02 +01:00
Andy Yankovsky 3b47bd32f9 [lldb] Fix handling of `DW_AT_decl_file` according to D91014 (attempt #2)
Apply changes from https://reviews.llvm.org/D91014 to other places where DWARF entries are being processed.

Test case is provided by @jankratochvil.
The test is marked to run only on x64 and exclude Windows and Darwin, because the assembly is not OS-independent.

(First attempt https://reviews.llvm.org/D96778 broke the build bots)

Reviewed By: jankratochvil

Differential Revision: https://reviews.llvm.org/D97765
2021-03-03 10:27:35 +01:00
Jan Kratochvil 4096ae06f4 [lldb] Support DWARF-5 DW_FORM_line_strp (used by GCC)
LLDB has been failing on binaries produced by new GCC 11.0 with -gdwarf-5.

Differential Revision: https://reviews.llvm.org/D97721
2021-03-02 15:17:23 +01:00
Muhammad Omair Javaid 536783170f Support GDB remote g packet partial read
GDB remote protocol does not specify length of g packet for register read. It depends on remote to include all or exclude certain registers from g packet. In case a register or set of registers is not included as part of g packet then we should fall back to p packet for reading all registers excluded from g packet by remote. This patch adds support for above feature and adds a test-case for the same.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D97498
2021-03-02 17:21:48 +05:00
Pavel Labath a63daf693c [lldb] Remote leftover _llgs from TestGdbRemoteConnection.py
the suffix will be added when the test is instantiated for llgs and
debugserver.
2021-03-02 10:59:25 +01:00
Med Ismail Bennani 36254f1a0f
[lldb] Revert ScriptedProcess patches
This patch reverts the following commits:
- 5a9c34918b
- 46796762af
- 2cff3dec11
- 182f0d1a34
- d62a53aaf1

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-01 23:23:27 +00:00
Med Ismail Bennani 46796762af [lldb/Plugins] Add ScriptedProcess Process Plugin
This patch introduces Scripted Processes to lldb.

The goal, here, is to be able to attach in the debugger to fake processes
that are backed by script files (in Python, Lua, Swift, etc ...) and
inspect them statically.

Scripted Processes can be used in cooperative multithreading environments
like the XNU Kernel or other real-time operating systems, but it can
also help us improve the debugger testing infrastructure by writting
synthetic tests that simulates hard-to-reproduce process/thread states.

Although ScriptedProcess is not feature-complete at the moment, it has
basic execution capabilities and will improve in the following patches.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-01 21:13:32 +01:00
Med Ismail Bennani 2cff3dec11 [lldb/bindings] Add Python ScriptedProcess base class to lldb module
In order to facilitate the writting of Scripted Processes, this patch
introduces a `ScriptedProcess` python base class in the lldb module.

The base class holds the python interface with all the - abstract -
methods that need to be implemented by the inherited class but also some
methods that can be overwritten.

This patch also provides an example of a Scripted Process with the
`MyScriptedProcess` class.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-01 21:13:32 +01:00
Jan Kratochvil 011e7bcaa3 Revert "[lldb] Fix handling of `DW_AT_decl_file` according to D91014"
This reverts commit 7ec7876fed.

Non-x86_64 non-Linux bots broke by the testcase.
2021-03-01 20:45:30 +01:00
Michał Górny 95a1305fb4 [lldb] [test] Skip AVX lldb-server test on non-x86 architectures
Skip the AVX-related lldb-server test on non-x86 architectures, as they
do not support AVX.  While technically the test worked on Linux because
the AVX check would simply return false, other platforms do not provide
such a straightforward way of checking for AVX (especially remotely),
and the results of such check may need to be interpreted specially
for the platform in question.

Differential Revision: https://reviews.llvm.org/D97450
2021-03-01 16:23:36 +01:00
Michał Górny 15f067f1c7 [lldb] [test] Workaround symlink-related test failures
Use realpath() when spawning the executable create_after_attach
to workaround a FreeBSD plugin (and possibly others) problem.
If the executable is started via a path containing a symlink, it is
added to the module list twice -- via the real and apparent path.
This in turn cases the requested breakpoint to resolve twice.

Use realpath() for main program path in lldb-vscode breakpoint tests
to workaround a similar problem.  If the passed path does not match
the realpath, lldb-vscode does not report the breakpoints as verified
and causes tests to fail.

Since the underlying problems are non-trivial to fix and the purpose
of these tests is not to reproduce symlink problems, let's apply
trivial workarounds to make them pass.

Differential Revision: https://reviews.llvm.org/D97230
2021-03-01 16:23:36 +01:00
Andy Yankovsky 7ec7876fed [lldb] Fix handling of `DW_AT_decl_file` according to D91014
Apply changes from https://reviews.llvm.org/D91014 to other places where DWARF entries are being processed.

Differential Revision: https://reviews.llvm.org/D96778
2021-03-01 16:01:11 +01:00
Tatyana Krasnukha f0f183ee4a [lldb/Interpreter] Fix deep copying for OptionValue classes
Some implementations of the DeepCopy function called the copy constructor that copied m_parent member instead of setting a new parent. Others just leaved the base class's members (m_parent, m_callback, m_was_set) empty.
One more problem is that not all classes override this function, e.g. OptionValueArgs::DeepCopy produces OptionValueArray instance, and Target[Process/Thread]ValueProperty::DeepCopy produces OptionValueProperty. This makes downcasting via static_cast invalid.

The patch implements idiom "virtual constructor" to fix these issues.
Add a test that checks DeepCopy for correct copying/setting all data members of the base class.

Differential Revision: https://reviews.llvm.org/D96952
2021-02-28 19:23:25 +03:00
Dave Lee 3a677b29a3 [lldb] Add deref support to libc++ unique_ptr synthetic
Add frame variable dereference suppport to libc++ `std::unique_ptr`.

This change allows for commands like `v *thing_up` and `v thing_up->m_id`. These commands now work the same way they would with raw pointers, and as they would with expression. This is done by adding an unaccounted for child member named `$$dereference$$`.

Without this change, the command would have to be written as `v *thing_up.__value_` or v thing_up.__value_->m_id` which exposes internal structure and is more clumsy to type.

Additionally, the existing tests were updated. See also https://reviews.llvm.org/D97165 which added deref support for `std::shared_ptr`.

Differential Revision: https://reviews.llvm.org/D97524
2021-02-26 07:39:01 -08:00
Med Ismail Bennani b889ef4214 [lldb/Core] Change large function threshold variable into a setting.
This patch replaces the static large function threshold variable with a
global debugger setting (`stop-disassembly-max-size`).

The default threshold is now set to 32KB (instead of 8KB) and can be modified.

rdar://74726362

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-02-25 22:35:04 +01:00
Raphael Isemann 6201017d54 [lldb] Prevent double new lines behind errors/warning/messages from LLDB commands
The current API for printing errors/warnings/messages from LLDB commands
sometimes adds newlines behind the messages for the caller. However, this
happens unconditionally so when the caller already specified a trailing newline
in the error message (or is trying to print a generated error message that ends
in a newline), LLDB ends up printing both the automatically added newline and
the one that was in the error message string. This leads to all the randomly
appearing new lines in error such as:

```
(lldb) command a
error: 'command alias' requires at least two arguments
(lldb) apropos a b
error: 'apropos' must be called with exactly one argument.

(lldb) why is there an empty line behind the second error?
```

This code adds a check that only appends the new line if the passed message
doesn't already contain a trailing new line.

Also removes the AppendRawWarning which had only one caller and doesn't serve
any purpose now.

Reviewed By: #lldb, mib

Differential Revision: https://reviews.llvm.org/D96947
2021-02-24 14:42:01 +01:00
Jorge Gorbe Moya 979ca1c05f Defer the decision whether to use the CU or TU index until after reading the unit header.
In DWARF v4 compile units go in .debug_info and type units go in
.debug_types. However, in v5 both kinds of units are in .debug_info.
Therefore we can't decide whether to use the CU or TU index just by
looking at which section we're reading from. We have to wait until we
have read the unit type from the header.

Differential Revision: https://reviews.llvm.org/D96194
2021-02-23 13:26:11 -08:00
Dave Lee 0ac42fd26d [lldb] Add deref support and tests to shared_ptr synthetic
Add `frame variable` dereference suppport to libc++ `std::shared_ptr`.

This change allows for commands like `v *thing_sp` and `v thing_sp->m_id`. These
commands now work the same way they do with raw pointers. This is done by adding an
unaccounted for child member named `$$dereference$$`.

Also, add API tests for `std::shared_ptr`, previously there were none.

Differential Revision: https://reviews.llvm.org/D97165
2021-02-23 09:03:46 -08:00
Michał Górny 6c06b0aa5a [lldb] [test] Un-XFAIL TestBuiltinTrap on FreeBSD/aarch64 2021-02-23 14:35:34 +01:00
Michał Górny 2f75363a9e [lldb] [test] Un-XFAIL a test that no longer fail on FreeBSD 2021-02-23 14:35:34 +01:00
Richard Howell 389955c69a [lldb] add check for libcxx runtime
When enabling LLDB tests with `LLVM_ENABLE_RUNTIMES=libcxx` CMake will
fail with:

```
LLDB test suite requires libc++, but it is currently disabled.
```

The issue is that the targets in LLVM_ENABLE_RUNTIMES are configured
after the targets in LLVM_ENABLE_PROJECTS, so at this point the check
for the `cxx` target will fail. CMake will add a dependency for a target
that does not exist yet however, so by first checking for `libcxx` in
LLVM_ENABLE_RUNTIMES we ensure that the `cxx` target will be present at
build time.

Tested with:
```
% cmake -G Ninja \
    -C ~/local/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake \
    -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_ENABLE_RUNTIMES="libcxx" \
    -DLIBCXX_INCLUDE_TESTS=NO ~/local/llvm-project/llvm
% ninja check-lldb
```

Reviewed By: smeenai, JDevlieghere

Differential Revision: https://reviews.llvm.org/D97227
2021-02-22 17:53:54 -08:00
Shafik Yaghmour 50542d504d Modify TypePrinter to differentiate between anonymous struct and unnamed struct
Currently TypePrinter lumps anonymous classes and unnamed classes in one group "anonymous" this is not correct and can be confusing in some contexts.

Differential Revision: https://reviews.llvm.org/D96807
2021-02-22 14:16:43 -08:00
António Afonso 878d82c4f2 Revert "[lldb-vscode] Emit the breakpoint changed event on location resolved"
This reverts commit 1f21d488bd.
2021-02-21 13:08:06 -08:00
Pavel Labath 3ca7b2d03c Reapply "[lldb/test] Automatically find debug servers to test"
This reapplies 7df4eaaa93/D96202, which was reverted due to issues on
windows. These were caused by problems in the computation of the liblldb
directory, which was fixed by D96779.

The original commit message was:
Our test configuration logic assumes that the tests can be run either
with debugserver or with lldb-server. This is not entirely correct,
since lldb server has two "personalities" (platform server and debug
server) and debugserver is only a replacement for the latter.

A consequence of this is that it's not possible to test the platform
behavior of lldb-server on macos, as it is not possible to get a hold of
the lldb-server binary.

One solution to that would be to duplicate the server configuration
logic to be able to specify both executables. However, that seems
excessively redundant.

A well-behaved lldb should be able to find the debug server on its own,
and testing lldb with a different (lldb-|debug)server does not seem very
useful (even in the out-of-tree debugserver setup, we copy the server
into the build tree to make it appear "real").

Therefore, this patch deletes the configuration altogether and changes
the low-level server retrieval functions to be able to both lldb-server
and debugserver paths. They do this by consulting the "support
executable" directory of the lldb under test.

Differential Revision: https://reviews.llvm.org/D96202
2021-02-21 20:47:47 +01:00
António Afonso b19d3b092d Revert "Make sure the interpreter module was loaded before making checks against it"
This reverts commit a83a825e99.
2021-02-21 10:38:25 -08:00
António Afonso 1f21d488bd [lldb-vscode] Emit the breakpoint changed event on location resolved
VSCode was not being informed whenever a location had been resolved (after being initated as non-resolved), so even though it was actually resolved, the IDE would show a hollow dot (instead of a red dot) because it didn't know about the change.

Differential Revision: https://reviews.llvm.org/D96680
2021-02-21 09:46:29 -08:00
António Afonso a83a825e99 Make sure the interpreter module was loaded before making checks against it
This issue was introduced in https://reviews.llvm.org/D92187.
The guard I'm changing were is supposed to act when linux is loading the linker for the second time (due to differences in paths like symlinks).
This is done by checking `module_sp != m_interpreter_module.lock()` however this will be true when `m_interpreter_module` wasn't initialized, making linux unload the linker module (the most visible result here is that lldb will stop getting notified about new modules loaded by the process, because it can't set the rendezvous breakpoint again after the stepping over it once).
The `m_interpreter_module` is not getting initialize when it goes through this path: dbfdb139f7/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (L332), which happens when lldb was able to read the address from the dynamic section of the executable.

What I'm not sure about though, is if when we go through this path if we still load the linker twice on linux. If that's the case then it means we need to somehow set the m_interpreter_module instead of the fix I provide here. I've only tested this on Android.

Differential Revision: https://reviews.llvm.org/D96637
2021-02-21 09:28:04 -08:00
Shafik Yaghmour 9068dab1fd Revert "Modify TypePrinter to differentiate between anonymous struct and unnamed struct"
I missed clangd test suite and may need some time to get those working, so reverting for now.

This reverts commit ecb90b5545.
2021-02-18 18:17:24 -08:00
Shafik Yaghmour 080ba851c6 Revert "Fix for Modify TypePrinter to differentiate between anonymous struct and unnamed struct"
I missed clangd test suite and may need some time to get those working, so reverting for now.

This reverts commit 1e08193956.
2021-02-18 18:17:24 -08:00
Shafik Yaghmour 1e08193956 Fix for Modify TypePrinter to differentiate between anonymous struct and unnamed struct
One of the lldb tests needed additional fixes.
2021-02-18 17:57:40 -08:00
Shafik Yaghmour ecb90b5545 Modify TypePrinter to differentiate between anonymous struct and unnamed struct
Currently TypePrinter lumps anonymous classes and unnamed classes in one group "anonymous" this is not correct and can be confusing in some contexts.

Differential Revision: https://reviews.llvm.org/D96807
2021-02-18 17:44:45 -08:00
Pavel Labath 1b8d2ec071 [lldb] Un-XFAIL TestFormatters on windows
The test passes after D96779.
2021-02-18 18:47:20 +01:00
Pavel Labath 004a264f8c [lldb] Fix shared library directory computation on windows
Our code for locating the shared library directory works via dladdr (or
the windows equivalent) to locate the path of an address known to reside
in liblldb. This works great for C++ programs, but there's a catch.

When (lib)lldb is used from python (like in our test suite), this dladdr
call will return a path to the _lldb.so (or such) file in the python
directory. To compensate for this, we have code which attempts to
resolve this symlink, to ensure we get the canonical location. However,
here's the second catch.

On windows, this file is not a symlink (but a copy), so this logic
fails. Since most of our other paths are derived from the liblldb
location, all of these paths will be wrong, when running the test suite.
One effect of this was the failure to find lldb-server in D96202.

To fix this issue, I add some windows-specific code to locate the
liblldb directory. Since it cannot rely on symlinks, it works by
manually walking the directory tree -- essentially doing the opposite of
what we do when computing the python directory.

To avoid python leaking back into the host code, I implement this with
the help of a callback which can be passed to HostInfo::Initialize in
order to assist with the directory location. The callback lives inside
the python plugin.

I also strenghten the existing path test to ensure the returned path is
the right one.

Differential Revision: https://reviews.llvm.org/D96779
2021-02-18 15:37:52 +01:00
Jonas Devlieghere d6e80578fc [lldb] Improve error message for modules with dots or dashes
LLDB does not like to import Python files with dashes or dots in their
name. While the former are technically allowed, it is discouraged. Dots
are allowed for subpackages but not in module names. This patch improves
the user experience by printing a useful error.

Before this patch:

  error: module importing failed: SyntaxError('invalid syntax',
  ('<string>', 1, 11, 'import foo-bar\n'))

After this patch:

  error: module importing failed: Python discourages dashes in module
  names: foo-bar

rdar://74263511

[1] https://www.python.org/dev/peps/pep-0008/#package-and-module-names

Differential revision: https://reviews.llvm.org/D96833
2021-02-17 10:00:29 -08:00
Raphael Isemann f88b502d9b [FileCollector] Fix that the file system case-sensitivity check was inverted
real_path returns an `std::error_code` which evaluates to `true` in case an
error happens and `false` if not. This code was checking the inverse, so
case-insensitive file systems ended up being detected as case sensitive.

Tested using an LLDB reproducer test as we anyway need a real file system and
also some matching logic to detect whether the respective file system is
case-sensitive (which the test is doing via some Python checks that we can't
really emulate with the usual FileCheck logic).

Fixes rdar://67003004

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D96795
2021-02-16 20:21:32 +01:00
Pavel Labath 85f025e5b3 [lldb/test] Test lldb-server named pipe functionality on windows
lldb-server can use a named pipe to communicate the port number it is
listening on. This windows bits of this are already implemented, but we
did not have a test for that, most likely because python does not have
native pipe functionality.

This patch implements the windows bits necessary to test this. I'm using
the ctypes package to call the native APIs directly to avoid a
dependency to non-standard python packages. This introduces some amount
of boilerplate, but our named pipe use case is fairly limited, so we
should not end up needing to wrap large chunks of windows APIs.

Surprisingly to changes to lldb-server were needed to make the test
pass.

Differential Revision: https://reviews.llvm.org/D96260
2021-02-16 15:47:39 +01:00
Muhammad Omair Javaid c2123a82cd [LLDB] Skip TestMultipleTargets.py on Arm/AArch64 Linux
TestMultipleTargets.py fails randomly on Arm/AArch64 Linux buildbot with
no reasonable clues. I am marking it skipped for avoiding LLDB buildbot
failures due to this test.
2021-02-16 01:28:16 +05:00
Fangrui Song 135d07fb0d [lldb][test] Fix Shell/SymbolFile/symbol-binding.test 2021-02-13 11:10:29 -08:00
Raphael Isemann 0c118831a3 [lldb] Let TestPExpectTest test the right test class
This test supposed to check the test base we are using for pexpect tests, but instead it used the normal TestBase
class we use for all other tests. TestBase already had the substrs type check since D88792 so this
test was passing because of that.

This just changes the test base of the test to the pexpect one so that the `expect` calls find their intended
target function. Also moves the check to the very start so that we can check the argument without
actually having to start a terminal and all that jazz.

(I found this by accident as D88792 got somehow reverted in a downstream branch so this test started
failing).

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D96556
2021-02-12 09:56:43 +01:00
Jonas Devlieghere 4d3a061c32 [lldb] Fix 'r' and 'run' aliases on Apple Silicon
The 'r' and 'run' aliases were different based on the target
architecture. I suspect the intention was to disable shell expansion on
embedded devices. This fixes TestCustomShell.test on AS.
2021-02-11 20:23:53 -08:00
Peter Collingbourne c314f5ede8 ObjectFileELF: Test whether reloc_header is non-null instead of asserting.
It is possible for the GetSectionHeaderByIndex lookup to fail because
the previous FindSectionContainingFileAddress lookup found a segment
instead of a section. This is possible if the binary does not have
a PLT (which means that lld will in some circumstances set DT_JMPREL
to 0, which is typically an address that is part of the ELF headers
and not in a section) and may also be possible if the section headers
have been stripped. To handle this possibility, replace the assert
with an if.

Differential Revision: https://reviews.llvm.org/D93438
2021-02-11 15:05:18 -08:00
Jonas Devlieghere 876e7714dc [lldb] Disable x86-multithread-write.test with reproducers
This test is failing on GreenDragon. Disabling it until I have bandwidth
to investigate why the register values are different during replay.
2021-02-11 13:17:30 -08:00
Pavel Labath 3cad308ce5 Revert "[lldb/test] Automatically find debug servers to test"
The commit 7df4eaaa93 appears to
break the windows bot. Revert while I investigate.
2021-02-11 20:26:05 +01:00
Stella Stamenova ed98676fa4 Support multi-configuration generators correctly in several config files
Multi-configuration generators (such as Visual Studio and Xcode) allow the specification of a build flavor at build time instead of config time, so the lit configuration files need to support that - and they do for the most part. There are several places that had one of two issues (or both!):

1) Paths had %(build_mode)s set up, but then not configured, resulting in values that would not work correctly e.g. D:/llvm-build/%(build_mode)s/bin/dsymutil.exe
2) Paths did not have %(build_mode)s set up, but instead contained $(Configuration) (which is the value for Visual Studio at configuration time, for Xcode they would have had the equivalent) e.g. "D:/llvm-build/$(Configuration)/lib".

This seems to indicate that we still have a lot of fragility in the configurations, but also that a number of these paths are never used (at least on Windows) since the errors appear to have been there a while.

This patch fixes the configurations and it has been tested with Ninja and Visual Studio to generate the correct paths. We should consider removing some of these settings altogether.

Reviewed By: JDevlieghere, mehdi_amini

Differential Revision: https://reviews.llvm.org/D96427
2021-02-11 09:32:20 -08:00
Raphael Isemann 71536fd031 [lldb] Fix that running a top level expression without a process fails with a cryptic error
Right now when running `expr --top-level -- void foo() {}`, LLDB just prints a cryptic
`error: Couldn't find $__lldb_expr() in the module` error. The reason for that is
that if we don't have a running process, we try to set our execution policy to always use the
IR interpreter (ExecutionPolicyNever) which works even without a process. However
that code didn't consider the special ExecutionPolicyTopLevel which we use for
top-level expressions. By changing the execution policy to ExecutionPolicyNever,
LLDB thinks we're actually trying to interpret a normal expression inside our
`$__lldb_expr` function and then fails when looking for it.

This just adds an exception for top-level expressions to that code and a bunch of tests.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D91723
2021-02-11 17:07:11 +01:00
Raphael Isemann 19b4d3ce27 [lldb] Don't emit a warning when using Objective-C getters in expressions
Clang emits a warning when accessing an Objective-C getter but not using the result.
This gets triggered when just trying to print a getter value in the expression parser (where
Clang just sees a normal expression like `obj.getter` while parsing).

This patch just disables the warning in the expression parser (similar to what we do with
the C++ equivalent of just accessing a member variable but not doing anything with it).

Reviewed By: kastiglione

Differential Revision: https://reviews.llvm.org/D94307
2021-02-11 16:48:41 +01:00
Pavel Labath 7df4eaaa93 [lldb/test] Automatically find debug servers to test
Our test configuration logic assumes that the tests can be run either
with debugserver or with lldb-server. This is not entirely correct,
since lldb server has two "personalities" (platform server and debug
server) and debugserver is only a replacement for the latter.

A consequence of this is that it's not possible to test the platform
behavior of lldb-server on macos, as it is not possible to get a hold of
the lldb-server binary.

One solution to that would be to duplicate the server configuration
logic to be able to specify both executables. However, that seems
excessively redundant.

A well-behaved lldb should be able to find the debug server on its own,
and testing lldb with a different (lldb-|debug)server does not seem very
useful (even in the out-of-tree debugserver setup, we copy the server
into the build tree to make it appear "real").

Therefore, this patch deletes the configuration altogether and changes
the low-level server retrieval functions to be able to both lldb-server
and debugserver paths. They do this by consulting the "support
executable" directory of the lldb under test.

Differential Revision: https://reviews.llvm.org/D96202
2021-02-11 14:43:53 +01:00
Pavel Labath d77b04e4ed [lldb/test] Move and improve TestPlatformProcessConnect.py
Although it is located under tools/lldb-server, this test is very
different that other lldb-server tests. The most important distinction
is that it does not test lldb-server directly, but rather interacts with
it through the lldb client. It also tests the relevant client
functionality (the platform connect command, which is even admitted in
the test name). The fact that this test is structured as a lldb-server
test means it cannot access most of the goodies available to the
"normal" lldb tests (the runCmd function, which it reimplements; the
run_break_set_by_symbol utility function; etc.).

This patch makes it a full-fledged lldb this, and rewrites the relevant
bits to make use of the standard features. I also move the test into the
"commands" subtree to better reflect its new status.
2021-02-10 21:01:26 +01:00