Commit Graph

27046 Commits

Author SHA1 Message Date
Michael Buch 09f608fda5 [lldb][ClangExpression] Remove storage-class check when creating AsmLabel
This check was put in place to prevent static functions
from translation units outside the one that the current
expression is evaluated from taking precedence over functions
in the global namespace. However, this is really a different
bug. LLDB lumps functions from all CUs into a single AST and
ends up picking the file-static even when C++ context rules
wouldn't allow that to happen.

This patch removes the check so we apply the AsmLabel to all
FunctionDecls we create from DWARF if we have a linkage name
available. This makes the code-path easier to reason about and
allows calling static functions in contexts where we previously
would've chosen the wrong function.

We also flip the XFAILs in the API test to reflect what effect
this change has.

**Testing**

* Fixed API tests and added XFAIL

Differential Revision: https://reviews.llvm.org/D132231
2022-08-22 13:22:20 +01:00
Michael Buch 6f19f98710 [lldb][Test] Replace expect() with expect_expr() in TestNamespaceLookup.py
This will be useful in preparation for some reshuffling
of assertions in this file since we won't have to
adjust the persitent variable names during the process.

sed commands:
```
s/expect("expr -- /expect_expr("/g
s/startstr="(int) [$0-9]* = /result_type="int", result_value="/g
```

**Testing**

* API tests still pass

Differential Revision: https://reviews.llvm.org/D132271
2022-08-22 13:22:19 +01:00
Martin Storsjö b21de9b38f [lldb] Silence a GCC warning about missing returns after a fully covered switch. NFC. 2022-08-22 14:53:29 +03:00
Emmmer 65f6a8c23b [LLDB] Fix: make m_target_arch private
Using GetTargetArchitecture() instead of m_target_arch, and set m_target_arch to private.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D132353
2022-08-22 18:01:44 +08:00
Kazu Hirata ec5eab7e87 Use range-based for loops (NFC) 2022-08-20 21:18:32 -07:00
Kazu Hirata 258531b7ac Remove redundant initialization of Optional (NFC) 2022-08-20 21:18:28 -07:00
Kazu Hirata ce377df57e Ensure newlines at the end of files (NFC) 2022-08-20 21:18:23 -07:00
John Ericson 3adda398ce [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro
Use this instead of `*_LIBDIR_SUFFIX`, from which it is computed.

This gets us ready for D130586, in which `*_LIBDIR_SUFFIX` is
deprecated.

Differential Revision: https://reviews.llvm.org/D132300
2022-08-20 12:52:21 -04:00
Kazu Hirata 347c462e97 [lldb] Use Any::has_value instead of ANy::hasValue (NFC) 2022-08-20 07:28:06 -07:00
Michał Górny d92f49fc4b Reland "[lldb] [test] Disable new CommunicationTests on Windows"
This change was wrongly reverted and re-broke the Windows buildbot.

Sponsored by: The FreeBSD Foundation
2022-08-20 08:32:55 +02:00
Michał Górny 2f50883c13 [lldb] [gdb-remote] Include PID in vCont packets if multiprocess
Try to always send vCont packets and include the PID in them if running
multiprocess.  This is necessary to ensure that with the upcoming full
multiprocess support always resumes the correct process without having
to resort to the legacy Hc packets.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D131758
2022-08-20 08:21:32 +02:00
Kazu Hirata c38bc421b1 [lldb] Use Optional::value instead of Optional::getValue (NFC) 2022-08-19 21:40:48 -07:00
Kazu Hirata 2b46625516 [lldb] Use Optional::transform instead of Optional::map (NFC) 2022-08-19 21:40:47 -07:00
Jonas Devlieghere cc0b5ebf7f
[lldb] Support specifying a custom libcxx for the API tests
This patch combines D129166 (to always pick the just-built libc++) and
D132257 (to allow customizing the libc++ for testing). The common goal
is to avoid picking up an unexpected libc++ for testing.

Differential revision: https://reviews.llvm.org/D132263
2022-08-19 15:20:41 -07:00
Michael Buch 1dc8fcff0e Revert "[lldb] [gdb-remote] Include PID in vCont packets if multiprocess" - Part 2
This reverts commit ccb9d4d4ad.

Reverts the associated tests
2022-08-19 19:31:14 +01:00
Michael Buch 5517401f93 Revert "[lldb] [gdb-remote] Include PID in vCont packets if multiprocess"
This reverts commit ccb9d4d4ad.

https://reviews.llvm.org/D131758

Differential Revision: https://reviews.llvm.org/D132250
2022-08-19 18:05:41 +01:00
Adrian Prantl fe0f72d5c5 Revert "[lldb] [test] Add synchronization to TestContinue"
This reverts commit 7aadecae40.

I'm reverting this commit because it appears to break the green dragon
incremental LLDB bot.

https://reviews.llvm.org/D131758

See LLDB Incremental buildbot: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/46215/execution/node/70/log/
2022-08-19 09:23:18 -07:00
Adrian Prantl 00c4852561 Revert "[lldb] [test] Disable new CommunicationTests on Windows"
This reverts commit d38985a36b.
because I'm also reverting D131758.
2022-08-19 09:23:17 -07:00
Michał Górny d38985a36b [lldb] [test] Disable new CommunicationTests on Windows
Sponsored by: The FreeBSD Foundation
2022-08-19 16:23:39 +02:00
Michał Górny 7aadecae40 [lldb] [test] Add synchronization to TestContinue
Sponsored by: The FreeBSD Foundation
2022-08-19 15:49:35 +02:00
Michał Górny d6e1e01da9 [lldb] [Core] Harmonize Communication::Read() returns w/ thread
Harmonize the status and error values of Communication::Read() when
running with and without read thread.  Prior to this change, Read()
would return eConnectionStatusSuccess if read thread was enabled
and the read timed out or reached end-of-file, rather than
the respective states that are returned if read thread was disabled.
Now, it correctly returns eConnectionStatusTimedOut
and eConnectionStatusEndOfFile, and sets the error respectively.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D132217
2022-08-19 15:36:03 +02:00
Pavel Labath c74c17f37a [lldb] Use WSAEventSelect for MainLoop polling on windows
This patch switches the MainLoop class to use the WSAEventSelect
mechanism to wait for multiple sockets to become readable. The
motivation for doing that is that this allows us to wait for other kinds
of events as well (as long as they can be converted to WSAEvents). This
will allow us to avoid (abstract away) pipe-based multiplexing
mechanisms in the generic code, since pipes cannot be combined with
sockets on windows.

Since the windows implementation will now look completely different than
the posix (file descriptor-based) implementations, I have split the
MainLoop class into two (MainLoopPosix and MainLoopWindows), with the
common code going into MainLoopBase.

Differential Revision: https://reviews.llvm.org/D131159
2022-08-19 13:25:25 +02:00
Michał Górny 8b50ffe9fd [lldb] [test] Remove test_step_multiprocess, it's unreliable
Sponsored by: The FreeBSD Foundation
2022-08-19 10:08:11 +02:00
Michał Górny 58157087b0 [lldb] [test] Skip step packet test on non-amd64
Sponsored by: The FreeBSD Foundation
2022-08-19 09:48:13 +02:00
Michał Górny ccb9d4d4ad [lldb] [gdb-remote] Include PID in vCont packets if multiprocess
Try to always send vCont packets and include the PID in them if running
multiprocess.  This is necessary to ensure that with the upcoming full
multiprocess support always resumes the correct process without having
to resort to the legacy Hc packets.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D131758
2022-08-19 09:02:20 +02:00
John Ericson e941b031d3 Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too"
This reverts commit f7a33090a9.

Unfortunately this causes a number of failures that didn't show up in my
local build.
2022-08-18 22:46:32 -04:00
John Ericson f7a33090a9 [cmake] Use `CMAKE_INSTALL_LIBDIR` too
We held off on this before as `LLVM_LIBDIR_SUFFIX` conflicted with it.
Now we return this.

`LLVM_LIBDIR_SUFFIX` is kept as a deprecated way to set
`CMAKE_INSTALL_LIBDIR`. The other `*_LIBDIR_SUFFIX` are just removed
entirely.

I imagine this is too potentially-breaking to make LLVM 15. That's fine.
I have a more minimal version of this in the disto (NixOS) patches for
LLVM 15 (like previous versions). This more expansive version I will
test harder after the release is cut.

Reviewed By: sebastian-ne, ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D130586
2022-08-18 15:33:35 -04:00
Jim Ingham 33722848fc Use a SmallPtrSet rather than a SmallVector in ClusterManager.
The m_objects store in this class is only used to check whether
this ClusterManager already owns this pointer.  With a SmallVector
the is_contained call was non-linear in number of children, and for
instance printing all the elements of a 16M element std::vector
didn't complete in the time I was willing to wait for it (hours).

Since we are only doing insert & contains, some kind of set is a
better data structure.  In this patch I used SmallPtrSet.  With
that, the same array prints out in 30 seconds.  I also tried a
std::unordered_set but that was slightly slower and used a fair bit
more memory.

Other than performance, this is NFC.

Differential Revision: https://reviews.llvm.org/D131996
2022-08-18 09:34:28 -07:00
Slava Gurevich 5a197772ee [LLDB][NFC] Suppress spurious static inspection warnings
Suppress coverity false positives.
This diff contains comments only, including the hints for Coverity static code inspection
to suppress the warning originating at the next line after the comment.

Differential Revision: https://reviews.llvm.org/D131998
2022-08-17 16:12:42 -07:00
Zequan Wu 71d778f33e [LLDB][NativePDB] Switch to use DWARFLocationList.
Before, NativePDB uses scoped range as a workaround for value range, that causes
problems (e.g. a variable's value can only have one range, but usually a
variable's value is located at different address ranges, each at different
locations, in optimized build).
This patch let NativePDB switch to DWARFLocationList so a variable's value can
be described at multiple non-overlapped address ranges and each range maps to a
location.
Because overlapping ranges exists, here's peference when choosing ranges:
1. Always prefer whole value locations. Suppose a variable size is 8 bytes, one record is that for range [1, 5) first 4 bytes is at ecx, and another record is that for range [2, 8) the 8 bytes value is at rdx. This results: [1, 2) has first 4 bytes at ecx, [2, 8) has the whole value at rdx.
2. Always prefer the locations parsed later. Suppose first record is that for range [1, 5) value is at ecx, second record is that for range [2, 6) value is at eax. This results: [1, 2) -> ecx, [2, 6) -> eax.

Differential Revision: https://reviews.llvm.org/D130796
2022-08-17 13:37:13 -07:00
Slava Gurevich 1633190709 [LLDB][NFC] Fix optons parsing and misc. reliability in CommandObjectThread
* Fix broken option parsing in SetOptionValue()

Differential Revision: https://reviews.llvm.org/D131983
2022-08-17 12:20:10 -07:00
Chelsea Cassanova 9525015c1b [lldb][tests] Test queue-specific breakpoints
This commit adds tests to ensure that queue-specific breakpoints
work as expected, as this feature wasn't being tested before.

Differential Revision: https://reviews.llvm.org/D131605
2022-08-17 12:46:04 -04:00
Michael Buch 33833c8611 [lldb][Tests] Skip static-only tests in TestConstStaticIntegralMember.py for dsym variant
This test fails for Clang versions < 14.0 for `dsym` variants.
`dsymutil` strips debug info for classes with only static members.
Thus move the failing assertions into the XFAIL test case.

Differential Revision: https://reviews.llvm.org/D132004
2022-08-17 15:39:21 +01:00
David Spickett fe4a58214f [LLDB][ARM] Remove expected failure from AnonTypedef test
Thanks to ff9efe240c this test
is now passing.

https://lab.llvm.org/buildbot/#/builders/17/builds/26270
2022-08-17 08:52:58 +00:00
Michael Buch 88d3c1db45 [lldb][ClangExpression] Add asm() label to all FunctionDecls we create from DWARF
When resolving symbols during IR execution, lldb makes a last effort attempt
to resolve external symbols from object files by approximate name matching.
It currently uses `CPlusPlusNameParser` to parse the demangled function name
and arguments for the unresolved symbol and its candidates. However, this
hand-rolled C++ parser doesn’t support ABI tags which, depending on the demangler,
get demangled into `[abi:tag]`. This lack of parsing support causes lldb to never
consider a candidate mangled function name that has ABI tags.

The issue reproduces by calling an ABI-tagged template function from the
expression evaluator. This is particularly problematic with the recent
addition of ABI tags to numerous libcxx APIs.

The issue stems from the fact that `clang::CodeGen` emits function
function calls using the mangled name inferred from the `FunctionDecl`
LLDB constructs from DWARF. Debug info often lacks information for
us to construct a perfect FunctionDecl resulting in subtle mangled
name inaccuracies.

This patch side-steps the problem of inaccurate `FunctionDecl`s by
attaching an `asm()` label to each `FunctionDecl` LLDB creates from DWARF.
`clang::CodeGen` consults this label to get the mangled name as one of
the first courses of action when emitting a function call.

LLDB already does this for C++ member functions as of
[675767a591](https://reviews.llvm.org/D40283)

**Testing**

* Added API tests

Differential Revision: https://reviews.llvm.org/D131974
2022-08-17 09:02:43 +01:00
Pavel Kosov ff9efe240c [LLDB][JIT] Set processor for ARM architecture
Patch sets ARM cpu, before compiling JIT code. This enables FastISel for armv6 and higher CPUs and allows using hardware FPU

~~~

OS Laboratory. Huawei RRI. Saint-Petersburg

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D131783
2022-08-17 09:10:21 +03:00
David Blaikie 9fc65658f5 fold assert-only variable into assert to address non-assert -Wunused-variable 2022-08-17 04:10:59 +00:00
Stella Stamenova 0cbaed3e14 Revert "[LLDB][NFC] Fix optons parsing and misc. reliability in CommandObjectThread"
This very much non-NFC change broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/22557

This reverts commit 461b410159.
2022-08-16 18:11:28 -07:00
Jonas Devlieghere b706f56133
[lldb] Automatically unwrap parameter packs in template argument accessors
When looking at template arguments in LLDB, we usually care about what
the user passed in his code, not whether some of those arguments where
passed as a variadic parameter pack.

This patch extends all the C++ APIs to look at template parameters to
take an additional 'expand_pack' boolean that automatically unwraps the
potential argument packs. The equivalent SBAPI calls have been changed
to pass true for this parameter.

A byproduct of the patch is to also fix the support for template type
that have only a parameter pack as argument (like the OnlyPack type in
the test). Those were not recognized as template instanciations before.

The added test verifies that the SBAPI is able to iterate over the
arguments of a variadic template.

The original patch was written by Fred Riss almost 4 years ago.

Differential revision: https://reviews.llvm.org/D51387
2022-08-16 18:10:14 -07:00
Zequan Wu 9fd54cf5c9 [LLDB][NativePDB] Add nullptr checking. 2022-08-16 17:01:47 -07:00
Slava Gurevich 461b410159 [LLDB][NFC] Fix optons parsing and misc. reliability in CommandObjectThread
* Improve reliability by checking return results for calls to FindLineEntryByAddress()
* Fix broken option parsing in SetOptionValue()

Differential Revision: https://reviews.llvm.org/D131983
2022-08-16 15:30:25 -07:00
Slava Gurevich 1fe72001e8 [LLDB][NFC] Fix memory leak in IntstumentationRuntimeTSan.cpp
ConvertToStructuredArray() relies on its caller to deallocate the heap-allocated object pointer it returns. One of its call-sites, in GetRenumberedThreadIds(), fails to deallocate causing a memory/resource leak. Fix the memory leak by converting the return type to shared_ptr, and clean up the rest of the file to use the typedef-ed shared_ptr types for StructuredData for safety and consistency.

Differential Revision: https://reviews.llvm.org/D131900
2022-08-16 14:34:50 -07:00
Kazu Hirata 50630dcc4c [lldb] Fix warnings
This patch fixes:

  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h:34:5:
  error: default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

and:

  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp:194:21:
  error: comparison of integers of different signs: 'int' and 'size_t'
  (aka 'unsigned long') [-Werror,-Wsign-compare]
2022-08-16 12:33:21 -07:00
Zequan Wu 7ebbef2b30 [LLDB][NativePDB] Add nullptr checking. 2022-08-16 09:59:09 -07:00
Emmmer 4fc7e9cba2 [LLDB][RISCV] Make software single stepping work
Add:
- `EmulateInstructionRISCV`, which can be used for riscv32 and riscv64.
- Add unittests for EmulateInstructionRISCV.

Note: Compressed instructions set (RVC) was still not supported in this patch.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D131759
2022-08-16 23:44:50 +08:00
Emmmer 8ed3e75c96 [LLDB] Handle possible resume thread error
In this switch case we didn't handle possible errors in `ResumeThread()`, it's hard to get helpful information when it goes wrong.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D131946
2022-08-16 23:43:28 +08:00
Emmmer 95e2949a53 [LLDB] Fix possible nullptr exception
Some architectures do not have a flag register (like riscv).
In this case, we should set it to `baton.m_register_values.end()` to avoid nullptr exception.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D131945
2022-08-16 23:41:00 +08:00
David Spickett 662c1c2881 [LLDB][ARM] Remove unused LoadPseudoRegistersFromFrame function
https://reviews.llvm.org/D131658 identified a bug in this and
turns out it's not used anywhere.

Reviewed By: JDevlieghere, clayborg

Differential Revision: https://reviews.llvm.org/D131664
2022-08-16 08:28:50 +00:00
Jonas Devlieghere 11f45f36dc
[lldb] Fetching symbols in the background with dsymForUUID
On macOS, LLDB uses the DebugSymbols.framework to locate symbol rich
dSYM bundles. [1] The framework uses a variety of methods, one of them
calling into a binary or shell script to locate (and download) dSYMs.
Internally at Apple, that tool is called dsymForUUID and for simplicity
I'm just going to refer to it that way here too, even though it can be
be an arbitrary executable.

The most common use case for dsymForUUID is to fetch symbols from the
network. This can take a long time, and because the calls to the
DebugSymbols.framework are blocking, it takes a while to launch the
process. This is expected and therefore many people don't use this
functionality, but instead use add-dsym when they want symbols for a
given frame, backtrace or module. This is a little faster because you're
only fetching symbols for the module you care about, but it's still a
slow, blocking operation.

This patch introduces a hybrid approach between the two. When
symbols.enable-background-lookup is enabled, lldb will do the equivalent
of add-dsym in the background for every module that shows up in the
backtrace but doesn't have symbols for. From the user's perspective
there is no slowdown, because the process launches immediately, with
whatever symbols are available. Meanwhile, more symbol information is
added over time as the background fetching completes.

[1] https://lldb.llvm.org/use/symbols.html

rdar://76241471

Differential revision: https://reviews.llvm.org/D131328
2022-08-15 17:57:24 -07:00
Jonas Devlieghere 8d36a82d0a
[lldb] Flush the global thread pool in Debugger::Terminate
Use the Initialize/Terminate pattern for the global thread pool to make
sure it gets flushed during teardown.

Differential revision: https://reviews.llvm.org/D131407
2022-08-15 17:57:23 -07:00