Commit Graph

4959 Commits

Author SHA1 Message Date
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