1454 Commits

Author SHA1 Message Date
nerix
44fefe70e4
[LLDB][NativePDB] Estimate symbol sizes (#165727)
In #165604, a test was skipped on Windows, because the native PDB plugin
didn't set sizes on symbols. While the test isn't compiled with debug
info, it's linked with `-gdwarf`, causing a PDB to be created on
Windows. This PDB will only contain the public symbols (written by the
linker) and section information. The symbols themselves don't have a
size, however the DIA SDK sets a size for them.
It seems like, for these data symbols, the size given from DIA is the
distance to the next symbol (or the section end).

This PR implements the naive approach for the native plugin. The main
difference is in function/code symbols. There, DIA searches for a
corresponding `S_GPROC32` which have a "code size" that is sometimes
slightly smaller than the difference to the next symbol.
2025-10-31 10:33:37 +01:00
Raul Tambre
21041c9292
[NFCI][lldb][test] Fix mismatched C/C++ substitutions (#165773)
Most of the cases were where a C++ file was being compiled with the C substitution.
There were a few cases of the opposite though.

LLDB seems to be the only real culprit in the LLVM codebase for these mismatches.
Rest of the LLVM presumably sticks at least language-specific options in the common substitutions
making the mistakes immediately apparent.

I found these by using Clang frontend configuration files containing language-specific options for
both C and C++ (e.g. `-std=c2y` and `-std=c++26`).
2025-10-30 23:18:32 +02:00
Michael Buch
128f850af4 [lldb][test] Fix libc++ API tests on older Clang versions
Both of these fail on our Clang-19 macOS bots.
2025-10-30 15:08:08 +00:00
nerix
17c6c8da56
[LLDB] Skip TestMultipleSlides.py on Windows (#165604)
After the default PDB plugin changed to the native one (#165363), this
test failed, because it uses the size of public symbols and the native
plugin sets the size to 0 (as PDB doesn't include this information
explicitly). A PDB was built because the final executable in that test
was linked with `-gdwarf`.
2025-10-29 18:48:33 +00:00
Daniel Sanders
e903494967
[lldb] Fix TestVTableValue.py test_overwrite_vtable test (#164910)
Some machines have read-only vtables but this test expects to overwrite
them. Use -no_data_const to ensure the vtable is writable
2025-10-27 10:25:58 -07:00
Igor Kudrin
64df8f83fe
[lldb][test] Fix TestEmptyFuncThreadStepOut.py (#161788)
The test did not work as intended when the empty function `done()`
contained prologue/epilogue code, because a breakpoint was set before
the last instruction of the function, which caused the test to pass even
with the fix from #126838 having been reverted.

The test is intended to check a case when a breakpoint is set on a
return instruction, which is the very last instruction of a function.
When stepping out from this breakpoint, there is interaction between
`ThreadPlanStepOut` and `ThreadPlanStepOverBreakpoint` that could lead
to missing the stop location in the outer frame; the detailed
explanation can be found in #126838.

On `Linux/AArch64`, the source is compiled into:
```
> objdump -d main.o
0000000000000000 <done>:
   0:   d65f03c0        ret
```
So, when the command `bt set -n done` from the original test sets a
breakpoint to the first instruction of `done()`, this instruction
luckily also happens to be the last one.

On `Linux/x86_64`, it compiles into:
```
> objdump -d main.o
0000000000000000 <done>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   5d                      pop    %rbp
   5:   c3                      ret
```
In this case, setting a breakpoint by function name means setting it
several instructions before `ret`, which does not provoke the
interaction between `ThreadPlanStepOut` and
`ThreadPlanStepOverBreakpoint`.
2025-10-21 20:01:08 -07:00
Daniel Sanders
f188c97cc1
[lldb] Add bidirectional packetLog to gdbclientutils.py (#162176)
While debugging the tests for #155000 I found it helpful to have both
sides
of the simulated gdb-rsp traffic rather than just the responses so I've
extended
the packetLog in MockGDBServerResponder to record traffic in both
directions.
Tests have been updated accordingly
2025-10-21 09:38:24 +01:00
jimingham
c9124a1b08
Fix a potential use-after-free in StopInfoBreakpoint. (#163471)
StopInfoBreakpoint keeps a BreakpointLocationCollection for all the
breakpoint locations at the BreakpointSite that was hit. It is also
lives through the time a given thread is stopped, so there are plenty of
opportunities for one of the owning breakpoints to get deleted.

But BreakpointLocations don't keep their owner Breakpoints alive, so if
the BreakpointLocationCollection can live past when some code gets a
chance to delete an owner breakpoint, and then you ask that location for
some breakpoint information, it will access freed memory.

This wasn't a problem before PR #158128 because the StopInfoBreakpoint
just kept the BreakpointSite that was hit, and when you asked it
questions, it relooked up that list. That was not great, however,
because if you hit breakpoints 5 & 6, deleted 5 and then asked which
breakpoints got hit, you would just get 6. For that and other reasons
that PR changed to storing a BreakpointLocationCollection of the
breakpoints that were hit. That's better from a UI perspective but
caused this potential problem.

I fix it by adding a variant of the BreakpointLocationCollection that
also holds onto a shared pointer to the Breakpoints that own the
locations that were hit, thus keeping them alive till the
StopInfoBreakpoint goes away.

This fixed the ASAN assertion. I also added a test that works harder to
cause trouble by deleting breakpoints during a stop.
2025-10-20 16:46:25 -07:00
Jason Molenda
8706ef474c [lldb] Remove obsolete comment in TestCortexMExceptionUnwind 2025-10-13 18:50:21 -07:00
Jason Molenda
8d29a3bb6f [lldb][API test] TestCortexMExceptionUnwind needs ARM llvm target
Finally figured out the issue with TestCortexMExceptionUnwind.py
failing on some CI.  When the llvm is configured without the ARM
target enabled, the ARM ABI plugins will not be initialized in lldb,
and the unwind engine won't backtrace more than one stack frame.
This test requires that the ARM target be enabled in the llvm cmake.
Update the decorator to specify that; should be the end of these
mysterious fails.
2025-10-13 10:32:41 -07:00
nerix
15cde999d4
[LLDB] Check type before creating std::atomic synthetic children (#163176)
From
https://github.com/llvm/llvm-project/pull/163077#issuecomment-3396435083:
Currently, `std::atomic<T>` will always use the MSVC STL synthetic
children and summary. When inspecting types from other STLs, the output
would not show any children.

This PR adds a check that `std::atomic` contains `_Storage` to be
classified as coming from MSVC's STL.
2025-10-13 19:25:26 +02:00
Jason Molenda
190886ddc9 [lldb][NFC] enable unwind logging in TestCortexMExceptionUnwind
Still seeing a failure on a CI bot with this test that
I cannot reproduce locally, but luckily this one CI bot is giving
me trace output from the tests.  Turn on the unwind log when tracing
is enabled, migth get a better hint what's up with this test fail.
2025-10-10 13:50:45 -07:00
Jason Molenda
47d3c5f3cb [lldb] Cortex-M exception unwind API test cleanup
This test, with a corefile created via yaml2macho-core plus an
ObjectFileJSON binary with symbol addresses and ranges, was failing
on some machines/CI because the wrong ABI was being picked.

The bytes of the functions were not included in the yaml or .json
binary.  The unwind falls back to using the ABI plugin default
unwind plans.  We have two armv7 ABIs - the Darwin ABI that always
uses r7 as the frame pointer, and the AAPCS ABI which uses r11 code.
In reality, armv7 code uses r11 in arm mode, r7 in thumb code.  But
the ABI ArchDefaultUnwindPlan doesn't have any access to the Target's
ArchSpec or Process register state, to determine the correct processor
state (arm or thumb).  And in fact, on Cortex-M targets, the
instructions are always thumb, so the arch default unwind plan
(hardcoded r11) is always wrong.

The corefile doesn't specify a vendor/os, only a cpu.
The object file json specifies the armv7m-apple-* triple, which will
select the correct ABI plugin, and the test runs.

In some cases, it looks like the Process ABI was fetched after
opening the corefile, but before the binary.json was loaded and
corrected the Target's ArchSpec.  And we never re-evaluate the ABI
once it is set, in a Process.  When we picked the AAPCS armv7 ABI,
we would try to use r11 as frame pointer, and the unwind would stop
after one stack frame.

I'm stepping around this problem by (1) adding the register bytes of
the prologues of every test function in the backtrace, and (2)
shortening the function ranges (in binary.json) to specify that the
functions are all just long enough for the prologue where execution
is stopped.  The instruction emulation plugin will fail if it can't
get all of the bytes from the function instructions, so I hacked
the function sizes in the .json to cover the prologue plus one and
changed the addresses in the backtrace to fit within those ranges.

[ updated this commit to keep the @skipIfRemote on the API test
because two remote CI bots are failing for reasons I don't quite
see. ]
2025-10-09 19:10:42 -07:00
jimingham
36bce68b97
Add a scripted way to re-present a stop location (#158128)
This patch adds the notion of "Facade" locations which can be reported
from a ScriptedResolver instead of the actual underlying breakpoint
location for the breakpoint. Also add a "was_hit" method to the scripted
resolver that allows the breakpoint to say which of these "Facade"
locations was hit, and "get_location_description" to provide a
description for the facade locations.

I apologize in advance for the size of the patch. Almost all of what's
here was necessary to (a) make the feature testable and (b) not break
any of the current behavior.

The motivation for this feature is given in the "Providing Facade
Locations" section that I added to the python-reference.rst so I won't
repeat it here.

rdar://152112327
2025-10-09 08:37:21 -07:00
Igor Kudrin
64ed3903bb
[lldb] Fix stepping out if the return address is not allowed to stop at (#161982)
When a thread reaches a breakpoint at the return address set by
`ThreadPlanStepOut`, `ThreadPlanStepOut::ShouldStop()` calls
`ThreadPlanShouldStopHere::InvokeShouldStopHereCallback()`, and if it
returns `false`, `ThreadPlanShouldStopHere::QueueStepOutFromHerePlan()`
is called to queue a new plan to skip the corresponding range. Once the
new plan finishes, `ThreadPlanStepOut::ShouldStop()` should recheck the
stop condition; however, there is no code path in the method that sets
`done` to `true`. Before #126838, if `done` was `false`, the method checked
if a suitable frame had been reached. After the patch, the check is only
performed at a breakpoint; thus, the execution continues.

This patch causes `ThreadPlanStepOut::ShouldStop()` to recheck the stop
condition when `m_step_out_further_plan_sp` completes.
2025-10-08 16:30:24 -07:00
Vladislav Dzhidzhoev
f8ba5343ae
Revert "[lldb] Cortex-M exception unwind API test cleanup" (#162520)
This reverts commit 01a8f9b81870ac9bfe26d80fa3313d56cb8cbe13.

The reason is "lldb-remote-linux-win" buildbot breakage
(https://lab.llvm.org/buildbot/#/builders/197/builds/9625).
2025-10-08 20:17:54 +02:00
Jason Molenda
01a8f9b818 [lldb] Cortex-M exception unwind API test cleanup
This test, with a corefile created via yaml2macho-core plus an
ObjectFileJSON binary with symbol addresses and ranges, was failing
on some machines/CI because the wrong ABI was being picked.

The bytes of the functions were not included in the yaml or .json
binary.  The unwind falls back to using the ABI plugin default
unwind plans.  We have two armv7 ABIs - the Darwin ABI that always
uses r7 as the frame pointer, and the AAPCS ABI which uses r11 code.
In reality, armv7 code uses r11 in arm mode, r7 in thumb code.  But
the ABI ArchDefaultUnwindPlan doesn't have any access to the Target's
ArchSpec or Process register state, to determine the correct processor
state (arm or thumb).  And in fact, on Cortex-M targets, the
instructions are always thumb, so the arch default unwind plan
(hardcoded r11) is always wrong.

The corefile doesn't specify a vendor/os, only a cpu.
The object file json specifies the armv7m-apple-* triple, which will
select the correct ABI plugin, and the test runs.

In some cases, it looks like the Process ABI was fetched after
opening the corefile, but before the binary.json was loaded and
corrected the Target's ArchSpec.  And we never re-evaluate the ABI
once it is set, in a Process.  When we picked the AAPCS armv7 ABI,
we would try to use r11 as frame pointer, and the unwind would stop
after one stack frame.

I'm stepping around this problem by (1) adding the register bytes of
the prologues of every test function in the backtrace, and (2)
shortening the function ranges (in binary.json) to specify that the
functions are all just long enough for the prologue where execution
is stopped.  The instruction emulation plugin will fail if it can't
get all of the bytes from the function instructions, so I hacked
the function sizes in the .json to cover the prologue plus one and
changed the addresses in the backtrace to fit within those ranges.
2025-10-07 17:03:17 -07:00
Michael Buch
86ba1986a2 [lldb][test] Un-XFAIL TestDataFormatterStdUnorderedMap.py for older Clang versions
Fixed in https://github.com/llvm/llvm-project/pull/156033
2025-10-02 13:30:43 +01:00
Georgiy Samoylov
b181c22c54
[lldb][RISCV] Fixed TestSymbolFileJSON for RISC-V (#161497)
This test failed during testing on the RISC-V target because we couldn't
strip the main label from the binary. main is dynamically linked when
the -fPIC flag is enabled. The RISC-V ABI requires that executables
support loading at arbitrary addresses to enable shared libraries and
secure loading (ASLR). In PIC mode, function addresses cannot be
hardcoded in the code. Instead, code is generated to load addresses from
the GOT/PLT tables, which are initialized by the dynamic loader. The
reference to main thus ends up in .dynsym and is dynamically bound. We
cannot strip main or any other dynamically linked functions because
these functions are referenced indirectly via dynamic linking tables
(.plt and .got). Removing these symbols would break the dynamic linking
mechanism needed to resolve function addresses at runtime, causing the
executable to fail to correctly call them.
2025-10-01 15:40:42 -07:00
Jacob Lalonde
b66dfa7273
[LLDB] Add load core time to target metrics (#161581)
This patch adds a load core time, right now we don't have much insight
into the performance of load core, especially for large coredumps. To
start collecting information on this I've added some minor
instrumentation code to measure the two call sites of `LoadCore`.

I've also added a test to validate the new metric is output in
statistics dump
2025-10-01 21:14:23 +00:00
David Spickett
bafcc3e3b3
[lldb][test] Refactor and expand TestMemoryRegionDirtyPages.py (#156035)
This started as me being annoyed that I got loads of this when
inspecting memory regions on Mac:
Modified memory (dirty) page list provided, 0 entries.

So I thought I should test the existing behaviour, which led me to
refactor the existing test to run the same checks on all regions.

In the process I realised that the output is not wrong. There is a
difference between knowing that no pages are dirty and not knowing
anything about dirty pages. We print that there are 0 entries so the
user knows that difference.

The test case now checks "memory region" output as well as API use.
There were also some checks only run on certain regions, like page size,
which now run for all of them.
2025-09-25 10:58:19 +01:00
David Peixotto
44a1f7e7ca
[lldb] Fix unsafe map mutation in ProcessElfCore::FindModuleUUID (#159444)
The `ProcessElfCore::FindModuleUUID` function can be called by multiple
threads at the same time when `target.parallel-module-load` is true. We
were using the `operator[]` to lookup the UUID which will mutate the map
when the key is not present. This is unsafe in a multi-threaded contex
so we now use a read-only `find` operation and explicitly return an
invalid UUID when the key is not present.

The `m_uuids` map can follow a create-then-query pattern. It is
populated in the `DoLoadCore` function which looks like it is only
called in a single-threaded context so we do not need extra locking as
long as we keep the other accesses read-only.

Other fixes I considered

* Use a lock to protect access - We don't need to modify the map after
creation so we can allow concurrent read-only access.
* Store the map in a const pointer container to prevent accidental
mutation in other places.
     - Only accessed in one place currently so just added a comment.
* Store the UUID in the NT_FILE_Entry after building the mapping
correctly in `UpdateBuildIdForNTFileEntries`. - The map lets us avoid a
linear search in `FindModuleUUID`.

This commit also reverts the temporary workaround from #159395 which
disabled parallel module loading to avoid the test failure.

Fixes #159377
2025-09-18 08:20:09 -07:00
David Spickett
d0bdc5d945
[lldb][test] Disable parallel module loading for TestNetBSDCore.py (#159395)
Since #157170 this test has been flakey on several LLDB buildbots. I
suspect it's to do with mutli-threading, there are more details in
#159377.

Disable parallel loading for now so we are not spamming people making
unrelated changes.
2025-09-17 17:40:36 +01:00
Sirraide
9b95e10d5e
[LLDB] [Tests] Downgrade -Wincompatible-pointer-types to a warning in some tests (#158756)
These no longer compile because the warning now defaults to an error
after #157364, so downgrade the error to a warning for now; I’m not
familiar enough with either LLDB or MacOS to fix these warnings properly
(assuming they’re unintended).
2025-09-16 02:02:01 +02:00
Sirraide
b24769855d
[Clang] [Sema] Make -Wincompatible-pointer-types an error by default (#157364)
GCC 14 also made this an error by default, so we’re following suit.

Fixes #74605
2025-09-15 16:55:00 +00:00
Ebuka Ezike
5e118eca93
[lldb][test] Fix unordered-map test. (#158286)
The build step is overidden so it uses `libstdc++` instead of `libc++`
on linux
2025-09-15 15:21:56 +01:00
Jason Molenda
20e55f359d [lldb][NFC] Mark API test skipIfRemote to avoid a bot
The lldb-remote-linux-ubuntu bot (and only this bot) is still failing
for TestCortexMExceptionUnwind.py because the Target triple is
somehow inheriting a non-Darwin OS.  I marked this API test
skipUnlessDarwin but this bot can be identified more specifically
by a skipIfRemote test.  There's no benefit to running this test
remotely anyway; it doesn't execute any code.
2025-09-11 14:19:44 -07:00
Jason Molenda
6a71938770 Revert "[lldb][NFC] Force some logging on to TestCortexMExceptionUnwind.py"
This reverts commit 336503c4e1cdb5eaefde0536a34f0a95bc0c57bf.
2025-09-10 22:58:30 -07:00
Jason Molenda
336503c4e1 [lldb][NFC] Force some logging on to TestCortexMExceptionUnwind.py
to possibly debug why this test fails on the
lldb-remote-linux-ubuntu CI bot.  I'm sure the Target ArchSpec is
somehow ending up _not_ armv7m-apple-* like it should be, but I'd
like to gather a little more info before I just give up on running
this test on linux systems.
2025-09-10 22:43:24 -07:00
Jason Molenda
21857ae337 Revert "[lldb][NFC] Try to adapt Cortex-M API test for an Unbuntu bot"
This reverts commit 4eadb45f83cef00165055f8038f179ca5c3e88ef.
2025-09-10 17:44:56 -07:00
Jason Molenda
4eadb45f83 [lldb][NFC] Try to adapt Cortex-M API test for an Unbuntu bot
When I added support for the Cortex-M exception return unwinding,
I got CI test failures on the lldb-remote-linux-ubuntu bot.  The
triple from my test `binary.json`, "armv7m-apple", was not being
used for the Target, so the incorrect SysV / AAPCS ABI was being
selected, and that ABI plugin has default unwind plans that hardcode
the arm-code r11 frame pointer behavior.  This is a Cortex-M
core, and r7 should be used.  The Darwin Arm ABI plugin uses r7 for
both arm and thumb, and behaves correctly.

Try getting the triple from `binary.json` in the API test, creating
the target with that triple explicitly before loading the corefile.
This may help prevent however we were losing the "-apple-" part of
the triple.  We'll see what the CI bot looks like with this added.
2025-09-10 17:15:02 -07:00
Ebuka Ezike
55e99efdf1
[lldb][test] skip test TestRerunAndExprDylib.py on remote (#157916) 2025-09-10 20:26:36 +01:00
Ebuka Ezike
f5315bd135
[lldb][test] Re-enable TestRerunAndExprDylib.py (#157872)
the `skipTestIfFn` requires a function that return a string to skip or
None to run the test. The `isUbuntu18_04` function returns a bool and
the test is skipped on all platforms.



25ebdfe0ab/lldb/packages/Python/lldbsuite/test/decorators.py (L145-L157)
2025-09-10 17:23:17 +01:00
Ebuka Ezike
a65aca6201
[lldb][test] StepUntil disable test for unsupported linkers. (#157474)
`INSERT BEFORE` keyword is not supported in current versions gold and
mold linkers. Since we cannot confirm accurately what linker and version
is available on the system and when it will be supported. We test it
with a sample program using the script keywords.
2025-09-10 17:18:43 +01:00
Jason Molenda
f3b7ad4859 [lldb][NFC] Update testsuite skip comment
to explain why the skip was added.
2025-09-09 16:47:26 -07:00
Jason Molenda
e320d9bdd3 [lldb] Skip TestCortexMExceptionUnwind except Darwin
I'm getting a failure on one linux CI, lldb-remote-linux-ubuntu,
where the test of assertEqual(thread.GetNumFrames(), 6) fails
because the unwinder only has one frame, most likely the
target triple is not set to armv7m-apple-* so ABISysV_arm is
being used instead of ABIMacOSX_arm and the architecture default
unwind plans behave differently.  Possibly the frame pointer
register, or possibly the way the arch default unwind plans are
structured.

Skipping on linux for now until I can debug further.  Can repo on
Darwin by changing the binary.json `"triple": "armv7m-apple"` to
armv7m-linux.
2025-09-09 15:32:33 -07:00
jimingham
2669fdeee2
NFC: SBThread should not be the one to compute StopReasonData. (#157577)
This is something the StopInfo class manages, so it should be allowed to
compute this rather than having SBThread do so. This code just moves the
computation to methods in StopInfo. It is mostly NFC. The one change
that I actually had to adjust the tests for was a couple of tests that
were asking for the UnixSignal stop info data by asking for the data at
index 1. GetStopInfoDataCount returns 1 and we don't do 1 based indexing
so the test code was clearly wrong. But I don't think it makes sense to
perpetuate handing out the value regardless of what index you pass us.
2025-09-09 15:31:55 -07:00
Jason Molenda
78dfbcaa7b [lldb][NFC] add comment to new TestCortexMExceptionUnwind 2025-09-09 14:27:25 -07:00
Jason Molenda
69511ae804
[lldb] Unwind through ARM Cortex-M exceptions automatically (#153922)
When a processor faults/is interrupted/gets an exception, it will stop
running code and jump to an exception catcher routine. Most processors
will store the pc that was executing in a system register, and the
catcher functions have special instructions to retrieve that & possibly
other registers. It may then save those values to stack, and the author
can add .cfi directives to tell lldb's unwinder where to find those
saved values.

ARM Cortex-M (microcontroller) processors have a simpler mechanism where
a fixed set of registers are saved to the stack on an exception, and a
unique value is put in the link register to indicate to the caller that
this has taken place. No special handling needs to be written into the
exception catcher, unless it wants to inspect these preserved values.
And it is possible for a general stack walker to walk the stack with no
special knowledge about what the catch function does.

This patch adds an Architecture plugin method to allow an Architecture
to override/augment the UnwindPlan that lldb would use for a stack
frame, given the contents of the return address register. It resembles a
feature where the LanguageRuntime can replace/augment the unwind plan
for a function, but it is doing it at offset by one level. The
LanguageRuntime is looking at the local register context and/or symbol
name to decide if it will override the unwind rules. For the Cortex-M
exception unwinds, we need to modify THIS frame's unwind plan if the
CALLER's LR had a specific value. RegisterContextUnwind has to retrieve
the caller's LR value before it has completely decided on the UnwindPlan
it will use for THIS stack frame.

This does mean that we will need one additional read of stack memory
than we currently do when unwinding, on Armv7 Cortex-M targets. The
unwinder walks the stack lazily, as stack frames are requested, and so
now if you ask for 2 stack frames, we will read enough stack to walk 2
frames, plus we will read one extra word of memory, the spilled LR value
from the stack. In practice, with 512-byte memory cache reads, this is
unlikely to be a real performance hit.

This PR includes a test with a yaml corefile description and a JSON
ObjectFile, incorporating all of the necessary stack memory and symbol
names from a real debug session I worked on. The architectural default
unwind plans are used for all stack frames except the 0th because
there's no instructions for the functions, and no unwind info. I may
need to add an encoding of unwind fules to ObjectFileJSON in the future
as we create more test cases like this.

This PR depends on the yaml2macho-core utility from
https://github.com/llvm/llvm-project/pull/153911 to run its API test.

rdar://110663219
2025-09-09 14:11:39 -07:00
David Spickett
157e886374
[lldb][test] Prevent TestqOffsets.py picking up host binaries (#157432)
Due to a fallback in GDBRemoteCommunicationClient.cpp, on Linux we will
assume a PID of 1 if the remote does not respond in some way that tells
us the real PID.

So if PID 1 happened to be a process that the current user could read,
we would try to debug that instead. On my current machine, PID 1 was
sshd run by root so we would ignore it. If I changed the fallback to
some process ID run by my user, the test would fail.

To prevent this, select the remote-linux platform before creating the
target. This means we won't attempt any host lookups.

Fixes #155895
2025-09-09 09:30:29 +01:00
Igor Kudrin
8ec4d87550
[lldb][elf-core][ARM] Add support for VFP registers (#155956)
This patch loads values of the VFP registers from the NT_ARM_VFP note.

Note that a CORE/NT_FPREGSET note is typically present in core dump
files and is used to store the FPA registers. The FPA unit is rare and
obsolete; however, Linux creates the note even if the unit is absent.
2025-09-08 14:55:54 -07:00
Michael Buch
5326b3b176 [lldb][test] Only assert function name is in user-code on Darwin platforms
The frame recognizer for the instrumentation runtimes (added in
https://github.com/llvm/llvm-project/pull/133079) only triggers on Darwin
for `libclang_rt`. Adjust the tests accordingly.
2025-09-08 22:48:34 +01:00
Michael Buch
bdf645bb9b [lldb][test] TestTsanBasic.py: fix function name assertion
Since https://github.com/llvm/llvm-project/pull/133079 we no longer stop
in the stanitizer library when hitting a sanitizer breakpoint. Adjust
the test accordingly.
2025-09-08 19:27:18 +01:00
Michael Buch
879f40ab04
[lldb][Instrumentation] Set selected frame to outside sanitizer libraries (#133079)
When hitting a sanitizer breakpoint, LLDB currently displays the frame
in the sanitizer dylib (which we usually don't have debug-info for),
which isn't very helpful to the user. A more helpful frame to display
would be the first frame not in the sanitizer library (we have a
[similar heuristic when we trap inside
libc++](https://github.com/llvm/llvm-project/pull/108825)). This patch
does just that, by implementing the `GetSuggestedStackFrameIndex` API

Depends on https://github.com/llvm/llvm-project/pull/133078
2025-09-08 17:03:31 +00:00
Michael Buch
4b362f152e
[lldb][DataFormatter] Allow std::string formatters to match against custom allocators (#156050)
This came up in https://github.com/llvm/llvm-project/issues/155691.

For `std::basic_string` our formatter matching logic required the
allocator template parameter to be a `std::allocator`. There is no
compelling reason (that I know of) why this would be required for us to
apply the existing formatter to the string. We don't check the
`allocator` parameter for other STL containers either. This meant that
`std::string` that used custom allocators wouldn't be formatted. This
patch relaxes the regex for `basic_string`.
2025-09-05 09:24:50 +01:00
Jonas Devlieghere
820f440274
[lldb] Correct style of error messages (#156774)
The LLVM Style Guide says the following about error and warning messages
[1]:

> [T]o match error message styles commonly produced by other tools,
> start the first sentence with a lowercase letter, and finish the last
> sentence without a period, if it would end in one otherwise.

I often provide this feedback during code review, but we still have a
bunch of places where we have inconsistent error message, which bothers
me as a user. This PR identifies a handful of those places and updates
the messages to be consistent.

[1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages
2025-09-04 16:37:41 -07:00
Med Ismail Bennani
84b56202fb
[lldb] Introduce ScriptedFrame affordance (#149622)
This patch introduces a new scripting affordance in lldb:
`ScriptedFrame`.

This allows user to produce mock stackframes in scripted threads and
scripted processes from a python script.

With this change, StackFrame can be synthetized from different sources:
- Either from a dictionary containing a load address, and a frame index,
  which is the legacy way.
- Or by creating a ScriptedFrame python object.

One particularity of synthezising stackframes from the ScriptedFrame
python object, is that these frame have an optional PC, meaning that
they don't have a report a valid PC and they can act as shells that just
contain static information, like the frame function name, the list of
variables or registers, etc. It can also provide a symbol context.

rdar://157260006

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-09-04 15:07:11 -07:00
Jonas Devlieghere
2498f0bcf5
[lldb] Add more command option mnemonics (#155705)
Add a bunch of mnemonics to the command options now that they're
highlighted in the help output. This uncovered two issues:

 - We had an instance where we weren't applying the ANSI formatting.
 - We had a place where we were now incorrectly computing the column
   width.

Both are fixed by this PR.
2025-09-04 13:21:24 -07:00
Med Ismail Bennani
6c10ab8a3c
[lldb] Mark scripted frames as synthetic instead of artificial (#153117)
This patch changes the way frames created from scripted affordances like
Scripted Threads are displayed. Currently, they're marked artificial
which is used usually for compiler generated frames.

This patch changes that behaviour by introducing a new synthetic
StackFrame kind and moves 'artificial' to be a distinct StackFrame
attribut.

On top of making these frames less confusing, this allows us to know
when a frame was created from a scripted affordance.

rdar://155949703

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-09-03 15:58:14 -07:00
Abdullah Mohammad Amin
599d353938
[lldb] Restrict TestVariableAnnotationsDisassembler.py to ELF x86_64 (skip on Windows/COFF) (#156026)
The `TestVariableAnnotationsDisassembler.py` test assembles
`d_original_example.s`,
which contains ELF-specific directives such as:

- `.ident`
- `.section ".note.GNU-stack", "", @progbits`
- `.section .debug_line, "", @progbits`

These directives are not understood by COFF on Windows, so the test
fails
on the lldb-remote-linux-win builder even when running on x86_64.

This patch adds a decorator to gate the test,
- `@skipUnlessPlatform(["linux", "freebsd", "netbsd", "android"])` — 
  runs only on ELF platforms

Follow-up to #155942.
2025-08-29 16:23:07 +01:00