Commit Graph

24339 Commits

Author SHA1 Message Date
Jan Kratochvil a233d72f0e [lldb/Docs] Update docs with new buildbot URLs 2021-03-17 20:09:03 +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
David Spickett 96927bafa4 [lldb] Correct unsigned decimal argument check in memory write
getAsInteger returns false when it succeeds.

Before:
(lldb) memory write 0x00007ffff7dd3000 99 -f "unsigned decimal"
error: '99' is not a valid unsigned decimal string value.

After:
(lldb) memory write 0x00007ffff7dd3000 99 -f "unsigned decimal"
(lldb) memory read 0x00007ffff7dd3000 0x00007ffff7dd3001
0x7ffff7dd3000: 63                                               c
2021-03-17 16:08:54 +00:00
David Spickett 4b513b2458 [lldb] Correct typo in memory read error
Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D98770
2021-03-17 10:38:31 +00:00
Vassil Vassilev 0cb7e7ca0c Make iteration over the DeclContext::lookup_result safe.
The idiom:
```
DeclContext::lookup_result R = DeclContext::lookup(Name);
for (auto *D : R) {...}
```

is not safe when in the loop body we trigger deserialization from an AST file.
The deserialization can insert new declarations in the StoredDeclsList whose
underlying type is a vector. When the vector decides to reallocate its storage
the pointer we hold becomes invalid.

This patch replaces a SmallVector with an singly-linked list. The current
approach stores a SmallVector<NamedDecl*, 4> which is around 8 pointers.
The linked list is 3, 5, or 7. We do better in terms of memory usage for small
cases (and worse in terms of locality -- the linked list entries won't be near
each other, but will be near their corresponding declarations, and we were going
to fetch those memory pages anyway). For larger cases: the vector uses a
doubling strategy for reallocation, so will generally be between half-full and
full. Let's say it's 75% full on average, so there's N * 4/3 + 4 pointers' worth
of space allocated currently and will be 2N pointers with the linked list. So we
break even when there are N=6 entries and slightly lose in terms of memory usage
after that. We suspect that's still a win on average.

Thanks to @rsmith!

Differential revision: https://reviews.llvm.org/D91524
2021-03-17 08:59:04 +00: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
Jason Molenda 22e9753271 Don't load kexts/kernels without dSYMs present
One of the backup schemes I use for finding kexts and kernels
on the local filesystem is to load a solitary binary when I don't
find any with a dSYM.  This usually is a more confusing behavior
than helpful; people expect to get no binary loaded, or a binary
with debug information.  This change stops loading kexts and
kernels that do not have an associated dSYM.

rdar://74291888
2021-03-12 17:20:44 -08:00
Dave Lee f3b07f9c5d [lldb] Remove unused StackFrame::TrackGlobalVariable
Last used by the Go plugin which was removed in https://reviews.llvm.org/D54057.
2021-03-12 08:51:25 -08:00
Raphael Isemann 75f97cdafe [lldb] Fix the man page build
In D94489 we changed the way we build the docs and now have some additional
dependencies to generate the Python API docs. As the same sphinx project is
generating the man pages for LLDB it should have in theory the same setup code
that sets up the mocked LLDB module.

However, as we don't have that setup code the man page generation just fails as
there is no mocked LLDB module and the Python API generation errors out.

The man page anyway doesn't cover the Python API so I don't think there is any
point of going through the whole process (and requiring the sphinx plugins) just
to generate the (eventually unused) Python docs.

This patch just skips the relevant Python API generation when we are building
the man page.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D98441
2021-03-11 19:51:47 +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
Jan Kratochvil 08d33aa680 [nfc] [lldb] Remove variable ranges_base in DWARFUnit::AddUnitDIE 2021-03-10 23:36:07 +01:00
Dave Lee daf3699869 [lldb] Ignore linkage diagnostic for LLDBSwigPythonBreakpointCallbackFunction (NFC)
Ignore `-Wreturn-type-c-linkage` diagnostics for `LLDBSwigPythonBreakpointCallbackFunction`.

The function is defined in `python-wrapper.swig` which uses `extern "C" { ... }` blocks.
The declaration of this function in `ScriptInterpreterPython.cpp` already uses these
same pragmas to silence the warning there.

This prevents `-Werror` builds from failing.

Differential Revision: https://reviews.llvm.org/D98368
2021-03-10 14:15:54 -08:00
Vedant Kumar ac29c35207 [lldb/Platform] Skip very slow xcrun queries for simulator platforms, NFC
GetXcodeSDK() consistently takes over 1 second to complete if the
queried SDK is missing, because `xcrun` doesn't cache negative lookups.

Because there are multiple simulator platforms, this can add 4+ seconds
to `lldb -b some_object_file.o`.

To work around this, skip the call to GetXcodeSDK() when setting up
simulator platforms if the specified arch doesn't have what looks like a
simulator triple.

Some other ways to fix this:
- Fix caching in xcrun (rdar://74882205)
- Test for arch compat before calling SomePlatform::CreateInstance() (much
  larger change)

Differential Revision: https://reviews.llvm.org/D98272
2021-03-10 13:57:10 -08:00
Dave Lee 354d10530d [lldb] Fix PushPlan to set subplan to private
Call `SetPrivate(true)` for subplans pushed via `PushPlan()`, as described in its
docstring.

Differential Revision: https://reviews.llvm.org/D96916
2021-03-10 11:05:33 -08:00
Michał Górny f47a84bc33 [lldb] [test] Update XFAILs for FreeBSD/aarch64 2021-03-10 18:36:19 +01:00
Michał Górny 771c4c9cf6 [lldb] [Process/FreeBSD] Introduce aarch64 hw break/watchpoint support
Split out the common base of Linux hardware breakpoint/watchpoint
support for AArch64 into a Utility class, and use it to implement
the matching support on FreeBSD.

Differential Revision: https://reviews.llvm.org/D96548
2021-03-10 18:36:19 +01:00
Jason Molenda ea659ea101 Log in SetPrivateState when unwind logging enabled
It is easier to read the unwind logging when you can see
when the inferior resumes / stops and we're doing new unwinds.
2021-03-09 16:22:46 -08:00
Jordan Rupprecht b4825a6d9c [lldb][gui] Fix uninitialized variable in SourceFileWindowDelegate.
After 5419b67137 (which is `[SimplifyCFG] Update FoldTwoEntryPHINode to handle and/or of select and binop equally`), this uninitialized value is detected by msan.
2021-03-09 10:57:00 -08: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
Pavel Labath 2e826088b9 [lldb] Fix a bug in D96779 (shared lib directory logic)
This function would fail in debug builds, as the two usages of the
LLDB_PYTHON_RELATIVE_LIBDIR macro would expand to two distinct strings.
The path iterator macros don't support that.

Use a temporary variable to ensure everything points to a single string.
2021-03-09 15:15:45 +01: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
Dave Lee 1200f85818 [lldb] Remove duplicated ThreadPlanStepOverBreakpoint comment
This comment was present twice in the function.
2021-03-08 22:34:56 -08:00
Jan Kratochvil fe7333174f [nfc] [lldb] Removed unused operator== for DWARFAbbreviationDeclaration and DWARFAttribute
Also DWARFAttribute::operator== was buggy as it was ignoring its `m_value`.
2021-03-08 19:18:48 +01:00
Jan Kratochvil 63abbeb6a8 [nfc] [lldb] [testsuite] Cleanup of recently added dwarf5-line-strp.s 2021-03-08 17:41:56 +01:00
Raphael Isemann dc4ca9b0d4 [lldb][NFC] Code style fixes for ClangModulesDeclVendor
Doxygenify comments and remove {} around one line if's.
2021-03-08 17:28:05 +01:00
Jan Kratochvil addbc9b34d [nfc] [lldb] Remove unused function DWARFAttribute::set 2021-03-08 17:04:35 +01:00
Andy Yankovsky 1b7e5d461a [lldb] Fix error message in IRInterpreter
`memory_read_error` -> `memory_write_error`

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D98170
2021-03-08 16:46:38 +01:00
Raphael Isemann 6f3778d31a [lldb][NFC] std::set -> DenseSet in ClangModulesDeclVendor
ModuleID is just an integer so let's use a DenseSet.
2021-03-08 13:13:35 +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
Dave Lee e7361c8ecc [lldb] Rename QueueFundamentalPlan to QueueBasePlan (NFC)
Minor change for naming consistency.

Differential Revision: https://reviews.llvm.org/D97985
2021-03-04 21:46:49 -08:00
Med Ismail Bennani c16fef19f6 [lldb/Interpreter] Make OptionGroupPythonClassWithDict options non-required
When using `OptionGroupPythonClassWithDict` options in an `OptionGroup`
with other `Options`, it can happen that the combinaison of some options
of each group makes the command invalid.

To solve that issue, this patch adds a bitmask argument to the
`OptionGroupPythonClassWithDict` constuctor that is used to mark each
option as required (or not).

If the `required_options` bitmask isn't passed to the constructor, the
class will keep its default behaviour, making the `--script-class` and
`--python-function` required.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-04 20:24:26 +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
Jonas Devlieghere 3dcbfa27d4 [debugserver] Fix more compiler warnings on arm64
This fixes the following two warnings in code that's only compiled on
arm64:

 - warning: cast from 'const void *' to 'unsigned char *' drops const
   qualifier [-Wcast-qual]
 - warning: embedding a directive within macro arguments has undefined
   behavior [-Wembedded-directive]
2021-03-03 23:12:12 -08:00
Jason Molenda 266bb78f7d LanguageRuntime for 0th frame unwind, simplify getting pc-for-symbolication
Add calls into LanguageRuntime when finding the unwind method to
use out of the 0th (currently executing) stack frame.

Allow for the LanguageRuntimes to indicate if this stack frames
should be treated like a zeroth-frame -- symbolication should be
done based on the saved pc address, not decremented like normal ABI
function calls.

Add methods to RegisterContext and StackFrame to get a pc value
suitable for symbolication, to reduce the number of places in lldb
where we decrement the saved pc values before symbolication.

<rdar://problem/70398009>
Differential Revision: https://reviews.llvm.org/D97644
2021-03-03 19:29:40 -08:00
Raphael Isemann 820a846609 [lldb][NFC] Delete unused AddressResolverName
That's all just dead code that hasn't been changed in years.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D97760
2021-03-03 13:30: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
Jonas Devlieghere db8b1598b7 [lldb] Inline objc_opt->version >= 14 to avoid dealing with bool type 2021-03-02 16:41:44 -08:00
Jonas Devlieghere c85d47f7b8 [lldb] Add more logging to __lldb_apple_objc_v2_get_dynamic_class_info 2021-03-02 16:24:59 -08:00
Jonas Devlieghere f46a441b1c [lldb] Extend Python convenience variable table with equivalent APIs
Add a column to the table of convenience variables with the equivalent
API to get to the current debugger, target, process, etc.

We often get asked to make convenience variables available outside of
the interactive interpreter. After explaining why that's not possible, a
common complaint is that it's hard to find out how to get to these
variables in a non-interactive context, for example how to get to the
current frame when given a thread. This patch aims to alleviate that by
including the APIs to navigate between these instances in the table.

Differential revision: https://reviews.llvm.org/D97778
2021-03-02 16:13:55 -08:00
Neal (nealsid) 5826aa48f0 Migrate to llvm::unique_function instead of static member functions for callbacks
A few cleanups suggested in another patch review's comments:

1. Use llvm:unique_function for storing & invoking callbacks from
   Editline to IOHandler
2. Change return type of one of the callback setters from bool to void,
   since it's return value was never used
3. Moved the callback setters inline & made them nonstatic, since that's
   more consistent with other setter definitions
4. Removed the baton parameter since we no longer need it anymore

Differential revision: https://reviews.llvm.org/D50299
2021-03-02 16:13:54 -08:00
Adrian Prantl 14ccba26bd Promote scalars to load addresses when dereferencing them.
This is a follow-up to 188b0747c1. This
is a very narrow fix to a more general problem. LLDB should be better
at distinguishing between implict and memory location descriptions.

rdar://74902042
2021-03-02 14:30:39 -08:00