30753 Commits

Author SHA1 Message Date
Kazu Hirata
a01d7df090
[lldb] Avoid repeated map lookups (NFC) (#112823) 2024-10-18 10:40:13 -07:00
Jay Foad
922992a22f
Fix typo "instrinsic" (#112899) 2024-10-18 15:58:33 +01:00
Michael Buch
3bc765dbbf
[lldb][test] Add test for ASTImporter's name conflict resolution (#112566)
This is a reduced test case from a crash we've observed in the past. The
assertion that this test triggers is:
```
Assertion failed: ((Pos == ImportedDecls.end() || Pos->second == To) && "Try to import an already imported Decl"), function MapImported, file ASTImporter.cpp, line 10494.
```

In a non-asserts build we crash later on in the ASTImporter. The root
cause is, as the assertion above points out, that we erroneously replace
an existing `From->To` decl mapping with a `To` decl that isn't
complete. Then we try to complete it but it has no definition and we
dereference a nullptr.

The reason this happens is basically what's been described in
https://reviews.llvm.org/D67803?id=220956#1676588

The dylib contains a definition of `Service` which is different to the
one in the main executable. When we start dumping the children of the
variable we're printing, we start completing it's members,
`ASTImport`ing fields in the process. When the ASTImporter realizes
there's been a name conflict (i.e., a structural mismatch on the
`Service` type) it would usually report back an error. However, LLDB
uses `ODRHandlingType::Liberal`, which means we create a new decl for
the ODR'd type instead of re-using the previously mapped decl.
Eventually this leads us to crash.

Ideally we'd be using `ODRHandlingType::Conservative` and warn/error,
though LLDB relies on this in some cases (particularly for
distinguishing template specializations, though maybe there's better a
way to deal with those).

We should really warn the user when this happens and not crash. To avoid
the crash we'd need to know to not create a decl for the ODR violation,
and instead re-use the definition we've previously seen. Though I'm not
yet sure that's viable for all of LLDB's use-cases (where ODR violations
might legimiately occur in a program, e.g., with opaque definitions,
etc.).
2024-10-18 14:19:42 +01:00
Benjamin Kramer
8e6abf526e Fix -Wswitch after 508fd966fb00428ccd1dd7ddeb636fb7393029ec 2024-10-18 12:30:16 +02:00
Jason Molenda
9c6f85f57a [lldb][NFC] fix two small typeos in aarch64-linxu.md 2024-10-17 19:46:08 -07:00
Jacob Lalonde
5033ea73bb
[LLDB][Minidump] Add breakpoint stop reasons to the minidump. (#108448)
Recently my coworker @jeffreytan81 pointed out that Minidumps don't show
breakpoints when collected. This was prior blocked because Minidumps
could only contain 1 exception, now that we support N signals/sections
we can save all the threads stopped on breakpoints.
2024-10-17 15:26:05 -07:00
Pavel Labath
98b419ca76
[lldb] Don't exit the main loop when in runs out of things to listen on (#112565)
This behavior made sense in the beginning as the class was completely
single threaded, so if the source count ever reached zero, there was no
way to add new ones. In https://reviews.llvm.org/D131160, the class
gained the ability to add events (callbacks) from other threads, which
means that is no longer the case (and indeed, one possible use case for
this class -- acting as a sort of arbiter for multiple threads wanting
to run code while making sure it runs serially -- has this class sit in
an empty Run call most of the time). I'm not aware of us having a use
for such a thing right now, but one of my tests in another patch turned
into something similar by accident.

Another problem with the current approach is that, in a
distributed/dynamic setup (multiple things using the main loop without a
clear coordinator), one can never be sure whether unregistering a
specific event will terminate the loop (it depends on whether there are
other listeners). We had this problem in lldb-platform.cpp, where we had
to add an additional layer of synchronization to avoid premature
termination. We can remove this if we can rely on the loop terminating
only when we tell it to.
2024-10-17 17:29:38 +02:00
Jonas Devlieghere
4897fc44a9
[lldb] Narrow scope of -Wno-deprecated-declarations (NFC) (#112276)
Currently all of LLDB is being compiled with
-Wno-deprecated-declarations. That's not desirable, especially as part
of the LLVM monorepo, as we miss deprecation warnings from LLVM and
clang.

According to the git history, this was first introduced to suppress
warnings related to auto_ptr. Since then, other things have been
deprecated and gone unnoticed. This patch limits the flag to Host.mm
which uses a handful of LSApplication headers that have no replacement.

rdar://112040718
2024-10-17 08:22:56 -07:00
Jonas Devlieghere
8c7f80f775
[lldb] Disable warning about codecvt_utf8 deprecation (NFC) (#112446)
Disable -Wdeprecated-declarations for codecvt_utf8 in Editline. This is
in preparation for #112276 which narrows the scope of
-Wno-deprecated-declarations for building LLDB.
2024-10-17 08:19:58 -07:00
Kazu Hirata
9173fd7739
[lldb] Avoid repeated map lookups (NFC) (#112655) 2024-10-17 07:45:50 -07:00
Luke Drummond
9d98acb196 Renormalize line endings whitespace only after dccebddb3b80
Line ending policies were changed in the parent, dccebddb3b80. To make
it easier to resolve downstream merge conflicts after line-ending
policies are adjusted this is a separate whitespace-only commit. If you
have merge conflicts as a result, you can simply `git add --renormalize
-u && git merge --continue` or `git add --renormalize -u && git rebase
--continue` - depending on your workflow.
2024-10-17 14:49:26 +01:00
David Spickett
2882bb192b [lldb][docs] Add link to LoongArch tracking issue
https://github.com/llvm/llvm-project/issues/112693 will be
tracking the overall state of LoongArch support.

This means anyone can check without having to track down
an expert.
2024-10-17 12:48:03 +01:00
Benjamin Kramer
9c80eb7c83 Silence -Wswitch after cb43021e5726a4462f28a999fb66a8dc20dc354b
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4885:13: warning: enumeration value 'SveMFloat8' not handled in switch [-Wswitch]
 4885 |     switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
      |
2024-10-17 13:15:05 +02:00
Nikita Popov
255a99c29f
[APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (#80309)
This fixes all the places that hit the new assertion added in
https://github.com/llvm/llvm-project/pull/106524 in tests. That is,
cases where the value passed to the APInt constructor is not an N-bit
signed/unsigned integer, where N is the bit width and signedness is
determined by the isSigned flag.

The fixes either set the correct value for isSigned, set the
implicitTrunc flag, or perform more calculations inside APInt.

Note that the assertion is currently still disabled by default, so this
patch is mostly NFC.
2024-10-17 08:48:08 +02:00
Jonas Devlieghere
90767bc41b
[lldb] Remove more mentions of ASLLogCallback (#112639) 2024-10-16 17:33:12 -07:00
John Harrison
c5c11f3404
[lldb-dap] Creating an API for sending dap events from a script in lldb-dap. (#112384)
Custom DAP events can be detected using
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent.

This API allows an lldb python script to send events to the DAP
client to allow extensions to handle these custom events.
2024-10-16 17:19:51 -07:00
Haowei
8f683b552d
[lldb] Use system c++ lib for LLDB STL tests (#112598)
This change partially reverts #112357 to avoid test failures on machines
which do not have gcc installed.
2024-10-16 16:34:02 -07:00
Brooks Davis
ad5e2bf6e9
[llbd] Finish Turn lldb_private::Status into a value type. (#10616) (#112420)
Fix a few bare Status() invocations that were missed in the conversion.
This is sufficent to build lldb on FreeBSD/aaarch64.

Fixes: 0642cd768b80
2024-10-16 20:41:38 +01:00
Adrian Prantl
8046f15dfa
[lldb] Fix offset calculation when printing diagnostics in multiple ranges (#112466)
depends on https://github.com/llvm/llvm-project/pull/112451
2024-10-16 09:46:35 -07:00
Adrian Prantl
889e6ad24b
[lldb] Fix a crash when two diagnostics are on the same column or in … (#112451)
…reverse order

The second inner loop (only) was missing the check for offset > column.
Also this patch sorts the diagnostics before printing them.
2024-10-16 09:45:39 -07:00
Dmitry Vasilyev
87f126243b
[lldb][test] Skip Test*FromStdModule tests on Linux for now (#112530)
This is the alternative to #98701.
See for more details:
https://reviews.llvm.org/D139361
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
2024-10-16 17:52:16 +04:00
Michael Buch
4e6fa78f4d
[lldb][test] Explicitly add target triple to no_unique_address Shell tests (#112523)
Follow up to https://github.com/llvm/llvm-project/pull/111902.

Makes sure all the `no_unique_address` tests are in the same place and
we don't rely on the host target triple (which means we don't need to
account for `[[msvc::no_unique_address]]` on Windows).

Now that we don't compile with the host compiler, this patch also adds
`-c` to the compilation command since we don't actually need the linked
binary in the test anyway (and on Darwin linking through Clang requires
the `xcrun` prefix to set up the SDK paths, etc.). We already do this in
`no_unique_address-with-bitfields.cpp` anyway.
2024-10-16 13:43:36 +01:00
Stefan Gränitz
3ef630ac33
[lldb] Support tests with nested make invocations on Windows 2/2 (#112360)
Following up from https://github.com/llvm/llvm-project/pull/112342, we
roll out the fix and quote nested `make` invocations in all API tests.
2024-10-16 13:07:02 +02:00
Kazu Hirata
282ab2f189
[lldb] Avoid repeated hash lookups (NFC) (#112471) 2024-10-15 23:11:30 -07:00
Muhammad Omair Javaid
69f7758ddb Revert "[lldb] Fix command-expr-diagnostics.test for Windows (#112109)"
This reverts commit eca3206d29e7ce97dd6336deaa3da96be37f8277.

This broke LLDB Linux bot for no apparent reason. I ll post a more
suitable fix later. Disabled command-expr-diagnostics.test on
windows for now.
2024-10-16 06:08:13 +05:00
Muhammad Omair Javaid
eca3206d29 [lldb] Fix command-expr-diagnostics.test for Windows (#112109)
This adds a minor change to command-expr-diagnostics.test to make
it pass on windows. Clang produces PDB on windows by default which
was ignoring main symbol due to optimization. The problem is fixed
by adding -gdwarf to commandline, making sure dwarf debug info gets
generated on both Windows and Linux.
2024-10-16 05:33:27 +05:00
Jonas Devlieghere
cc13d4fb4a
[lldb] Make the system log a NOOP on non-Darwin platforms
As discussed in #111911, we have consensus that as it stands, the system
log is only meaningful on Darwin and that by default it should be a NOOP
on other platforms.
2024-10-15 16:13:42 -07:00
Dmitrii Galimzianov
5f2cf99e14
DynamicLoaderDarwin load images in parallel with preload (#110646)
This change enables `DynamicLoaderDarwin` to load modules in parallel
using the thread pool. This new behavior is controlled by a new setting
`plugin.dynamic-loader.darwin.experimental.enable-parallel-image-load`,
which is enabled by default. When disabled, DynamicLoaderDarwin will
load modules sequentially as before.
2024-10-15 13:25:01 -07:00
Dmitry Vasilyev
de7f7ea884
[lldb][test] Fix TestStdCXXDisassembly test (#112357)
The patch #98694 was not enough. This test is still failed on the
buildbot https://lab.llvm.org/staging/#/builders/195/builds/4438
Use `USE_LIBSTDCPP := 1` instead for non Darwin OS and skip the test if
libstdc++.so is missing.
2024-10-16 00:08:58 +04:00
John Harrison
224f62de9e
[lldb-dap] Improving the naming consistency of startDebugging reverse request. (#112396)
Adjusting the name from `lldb-dap startDebugging` to `lldb-dap
start-debugging` to improve consistency with other names for commands in
lldb/lldb-dap.
2024-10-15 12:19:21 -07:00
Jonas Devlieghere
74eb079e06
[lldb] Use BasicBlock::iterator instead of InsertPosition (NFC) (#112307)
InsertPosition has been deprecated in favor of using
BasicBlock::iterator. (See #102608)
2024-10-15 08:25:28 -07:00
Kazu Hirata
a7b7af7ad5
[lldb] Avoid repeated map lookups (NFC) (#112315) 2024-10-15 07:37:00 -07:00
Vy Nguyen
4d78881406
[LLDB]Provide clearer error message for invalid commands. (#111891)
Sometimes users (esp. gdb-longtime users) accidentally use GDB syntax,
such as `breakpoint foo`, and they would get an error message from LLDB
saying simply `Invalid command "breakpoint foo"`, which is not very
helpful.

This change provides additional suggestions to help correcting the
mistake.
2024-10-15 10:14:48 -04:00
Stefan Gränitz
a4367d2d13
[lldb] Support tests with nested make invocations on Windows 1/2 (#112342)
In recent PR https://github.com/llvm/llvm-project/pull/111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
2024-10-15 14:22:12 +02:00
Vladislav Dzhidzhoev
f035d9f061
[lldb][test] Fix TestStdCXXDisassembly test for case when tests are linked with libc++ statically (#98694)
This is to fix buildbot failure
https://lab.llvm.org/staging/#/builders/195/builds/4255.

The test expects 'libstdc++' or 'libc++' SO module in the module list.
In case when static linking with libc++ is on by default, none of them
may be present.

Thus, USE_SYSTEM_STDLIB is added to ensure the presence of any of them.

---------

Co-authored-by: Vladimir Vereschaka <vvereschaka@accesssoftek.com>
2024-10-15 14:22:59 +04:00
Kazu Hirata
bad04dc6da
[lldb] Avoid repeated hash lookups (NFC) (#112301) 2024-10-14 21:34:13 -07:00
Vladislav Dzhidzhoev
1cb8314780
[lldb][test] Remove objcopy detection from API tests' CMakeLists.txt (#111977)
This commit essentially reverts https://reviews.llvm.org/D30453.

In #109961, objcopy util search code was added to dotest.py. dotest.py
should use llvm-X by default if no path to a utility X is provided
externally.

However, it doesn't work out for llvm-objcopy, since objcopy path is
always overridden with the lines being removed here. It causes a problem
with cross-platform testing when objcopy used by cmake doesn't support
targets/executable file formats other than native.

I suppose these lines are unnecessary after #109961, so they can be
safely removed.
2024-10-14 17:35:55 -07:00
Jonas Devlieghere
8225938a73
[lldb] Remove ASL (Apple System Log) support from debugserver (NFC) (#112260)
Remove support for ASL (Apple System Log) which has been deprecated
since macOS 10.12. Fixes the following warnings:

warning: 'asl_new' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
warning: 'asl_set' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
warning: 'asl_vlog' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
2024-10-14 17:06:02 -07:00
Jonas Devlieghere
6539481c8e
[lldb] Account for DWARF 5 sections in TestCTF.py
Update the TestCTF Makefile to remove the DWARF 5 sections.
2024-10-14 16:57:33 -07:00
Adrian Prantl
9eddc8b9bf
[lldb] Expose structured command diagnostics via the SBAPI. (#112109)
This allows IDEs to render LLDB expression diagnostics to their liking
without relying on characterprecise ASCII art from LLDB. It is exposed
as a versioned SBStructuredData object, since it is expected that this
may need to be tweaked based on actual usage.
2024-10-14 16:29:26 -07:00
Shubham Sandeep Rastogi
d8de2391eb Revert "[lldb] Improve unwinding for discontinuous functions (#111409)"
This reverts commit a89e01634fe2e6ce0b967ead24280b6693b523dc.

This is being reverted because it broke the test:

Unwind/trap_frame_sym_ctx.test

/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test:21:10: error: CHECK: expected string not found in input
 CHECK: frame #2: {{.*}}`main
2024-10-14 15:27:05 -07:00
Jonas Devlieghere
9cc6e6f71c
[lldb] Use CFPropertyListCreateData in debugserver (NFC) (#112262)
CFPropertyListCreateXMLData has been deprecated since macOS 10.10. Use
CFPropertyListCreateData instead.
2024-10-14 14:30:32 -07:00
Pavel Labath
a89e01634f
[lldb] Improve unwinding for discontinuous functions (#111409)
Currently, our unwinder assumes that the functions are continuous (or at
least, that there are no functions which are "in the middle" of other
functions). Neither of these assumptions is true for functions optimized
by tools like propeller and (probably) bolt.

While there are many things that go wrong for these functions, the
biggest damage is caused by the unwind plan caching code, which
currently takes the maximalist extent of the function and assumes that
the unwind plan we get for that is going to be valid for all code inside
that range. If a part of the function has been moved into a "cold"
section, then the range of the function can be many megabytes, meaning
that any function within that range will probably fail to unwind.

We end up with this maximalist range because the unwinder asks for the
Function object for its range. This is only one of the strategies for
determining the range, but it is the first one -- and also the most
incorrect one. The second choice would is asking the eh_frame section
for the range of the function, and this one returns something reasonable
here (the address range of the current function fragment) -- which it
does because each fragment gets its own eh_frame entry (it has to,
because they have to be continuous).

With this in mind, this patch moves the eh_frame (and debug_frame) to
the front of the queue. I think that preferring this range makes sense
because eh_frame is one of the unwind plans that we return, and some
others (augmented eh_frame) are based on it. In theory this could break
some functions, where the debug info and eh_frame disagree on the extent
of the function (and eh_frame is the one who's wrong), but I don't know
of any such scenarios.
2024-10-14 18:56:37 +02:00
Jonas Devlieghere
3dedcab6d9
[lldb] Make the system log a NOOP on Windows (#112052)
Windows doesn't have a built-in system log. Previously we got away with
writing to stdout and stderr because it was used only sporadically. As
we're trying to make the system log more useful on the other platforms,
the increased use become a concern. Make it a NOOP until someone figures
out a reasonable alternative.
2024-10-14 15:02:02 +01:00
David Spickett
d4ea08687f
[lldb] Replace Code Owners with Maintainers (#111686)
To align with the new policy:
https://llvm.org/docs/DeveloperPolicy.html#maintainers

I've assumed that Jonas will be the "Lead Maintainer" as he was the
default Code Owner.

I know the past Code Owners weren't "Maintainers" but it's the same
energy so I've changed it there too.

See also: https://github.com/llvm/llvm-project/pull/107384 /
https://discourse.llvm.org/t/rfc-proposing-changes-to-the-community-code-ownership-policy/80714
2024-10-14 09:09:48 +01:00
Adrian Prantl
c2750807ba
[lldb] Rename CommandReturnObject::Get.*Data -> Get.*String (#112062)
In a later commit, I want to add a method to access diagnostics as
actual structured data, which will make these function names rather
confusing.
2024-10-12 13:36:33 -07:00
Adrian Prantl
089227feaf
Support inline diagnostics in CommandReturnObject (#110901)
and implement them for dwim-print (a.k.a. `p`) as an example.

The next step will be to expose them as structured data in
SBCommandReturnObject.
2024-10-11 09:08:52 -07:00
David Spickett
a2bd5db00d
[lldb] Fix finding make tool for tests (#111980)
Fixes 0e913237871e8c9290e82be30be8b3484952eee0 /
https://github.com/llvm/llvm-project/pull/111531

For reasons I can't explain, a clean build works fine for me, and all
the bots are working fine. But if I rebuild in some way the make tool
becomes None.

Looking at the other variables, they had these extra lines so I've added
those for make and it seems to solve the problem.
2024-10-11 14:14:04 +01:00
David Spickett
d941254da9 [lldb][test] Fix var name typo in TestProcessSaveCoreMinidump 2024-10-11 11:00:07 +00:00
Dmitry Vasilyev
b222f31930
[lldb][test] Fixed the test no_unique_address-with-bitfields (#111902)
Fixed the error `unable to create target: 'No available targets are
compatible with triple "x86_64-apple-macosx10.4.0"'` running `clang
--target=x86_64-apple-macosx -c -gdwarf -o %t %s`.
2024-10-11 12:56:42 +04:00