Commit Graph

1278 Commits

Author SHA1 Message Date
Felipe de Azevedo Piovezan
28156539a9 [lldb] Disable test using GetControlFlowKind on arm 2025-05-08 13:14:40 -07:00
Jonas Devlieghere
45cd708184 [lldb] Change the statusline format to print "no target" (#139021)
Change the default statusline format to print "no target" when lldb is
launched without a target. Currently, the statusline is empty, which
looks rather odd.
2025-05-08 09:09:46 -07:00
Felipe de Azevedo Piovezan
cb0b9614f8 [lldb] Disable test using GetControlFlowKind on arm
This is only implemented for x86.
Originally introduced in: https://github.com/llvm/llvm-project/pull/137904
2025-05-08 08:11:17 -07:00
Ely Ronnen
4132141681 [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (#137904)
Expose `QueueThreadPlanForStepSingleInstruction` function to
SBThreadPlan
2025-05-08 14:01:42 +02:00
Jacob Lalonde
c50cba6275 [LLDB][SBSaveCore] Sbsavecore subregions bug (#138206)
Custom regions in Process::GetUserSpecifiedCoreFileSaveRanges originally
used `FindEntryThatContains`. This made sense on my first attempt, but
what we really want are *intersecting* regions. This is so the user can
specify arbitrary memory, and if it's available we output it to the core
(Minidump or MachO).
2025-05-05 11:04:55 -07:00
Felipe de Azevedo Piovezan
f784fa7275 [lldb] Disable TestExitDuringExpression on asan
This test is trying to exercise code running constructors with
interrupts. While we should fix this, this is creating noise on the
bots.
2025-04-29 12:38:51 -07:00
Michael Buch
9147569c7f [lldb][test] Rename reverse-execution/TestReverseContinueNotSupported.py
Otherwise `lldb-dotest` fails with:
```
Traceback (most recent call last):
  File "/Users/jonas/Git/llvm-worktrees/llvm-project/lldb/test/API/dotest.py", line 8, in <module>
    lldbsuite.test.run_suite()
  File "/Users/jonas/Git/llvm-worktrees/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", line 1063, in run_suite
    visit("Test", dirpath, filenames)
  File "/Users/jonas/Git/llvm-worktrees/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", line 701, in visit
    raise Exception("Found multiple tests with the name %s" % name)
Exception: Found multiple tests with the name TestReverseContinueNotSupported.py
```
2025-04-25 14:26:50 +01:00
Jonas Devlieghere
3ccfbc8a00 [lldb] Make sure changing the separator takes immediate effect (#136779)
The setter is only used when changing the setting programmatically. When
using the settings command, we need to monitor SetPropertyValue.
2025-04-22 22:38:28 -07:00
Adrian Prantl
6f1adbdb2b [lldb] Make the statusline separator configurable (#136611)
And use this functionality to replace the ASCII "|" with the same
full-geight line-drawing character used in diagnostics rendering on a
color terminal.
2025-04-22 12:59:46 -07:00
Shubham Sandeep Rastogi
1042d99887 disable test on older compilers (#136186) 2025-04-17 12:33:30 -07:00
Jonas Devlieghere
8311620933 [lldb] Fix lock inversion between statusline mutex and output mutex (#135956)
Fix a deadlock between the statusline mutex (in Debugger) and the output
file mutex (in LockedStreamFile). The deadlock occurs when the main
thread is calling the statusline callback while holding the output mutex
in Editline, while the default event thread is trying to update the
statusline.

Extend the uncritical section so we can redraw the statusline there.
The loop in Editline::GetCharacter should be unnecessary. It would only
loop if we had a successful read with length zero, which shouldn't be
possible or when we can't convert a partial UTF-8 character, in which
case we bail out.

rdar://149251156
2025-04-17 17:57:00 +02:00
Michael Buch
dfed3d235f [lldb][test] TestDataFormatterLibcxxInvalidVectorSimulator.py: fix inline namespace warnings
Fixes:
```
/Users/ec2-user/jenkins/workspace/apple-llvm-project-pr-macos/branch-swift/release/6.2/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp:5:11: warning: inline namespace reopened as a non-inline namespace [-Winline-namespace-reopened-noninline]
    5 | namespace __1 {
      |           ^
```

Drive-by: compile test as C++20 (in an attempt to fix another buildbot issue)
2025-04-17 06:39:44 +02:00
Shubham Sandeep Rastogi
9dbe107219 disable test on older compilers (#136037) 2025-04-16 14:41:20 -07:00
Michael Buch
419fa1b06a [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (#135944)
When the data-formatters happen to break (e.g., due to layout changes in
libc++), there's no clear indicator of them failing from a user's
perspective. E.g., for `std::vector`s we would just show:
```
(std::vector<int>) v = size=0 {}
```
which is highly misleading, especially if `v.size()` returns a non-zero
size.

This patch surfaces the various errors that could occur when calculating
the number of children of a vector.

rdar://146964266
2025-04-16 17:57:51 +02:00
Michael Buch
1e153b782e [lldb][Format] Display only the inlined frame name in backtraces if available (#135343)
When a frame is inlined, LLDB will display its name in backtraces as
follows:
```
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.3
  * frame #0: 0x0000000100000398 a.out`func() [inlined] baz(x=10) at inline.cpp:1:42
    frame #1: 0x0000000100000398 a.out`func() [inlined] bar() at inline.cpp:2:37
    frame #2: 0x0000000100000398 a.out`func() at inline.cpp:4:15
    frame #3: 0x00000001000003c0 a.out`main at inline.cpp:7:5
    frame #4: 0x000000026eb29ab8 dyld`start + 6812
```
The longer the names get the more confusing this gets because the first
function name that appears is the parent frame. My assumption (which may
need some more surveying) is that for the majority of cases we only care
about the actual frame name (not the parent). So this patch removes all
the special logic that prints the parent frame.

Another quirk of the current format is that the inlined frame name does
not abide by the `${function.name-XXX}` format variables. We always just
print the raw demangled name. With this patch, we would format the
inlined frame name according to the `frame-format` setting (see the
test-cases).

If we really want to have the `parentFrame [inlined] inlinedFrame`
format, we could expose it through a new `frame-format` variable (e..g.,
`${function.inlined-at-name}` and let the user decide where to place
things.
2025-04-13 23:21:52 +01:00
Jason Molenda
df28c81f5a [lldb][debugserver] Fix an off-by-one error in watchpoint identification (#134314)
debugserver takes the address of a watchpoint exception and calculates
which watchpoint was responsible for it. There was an off-by-one error
in the range calculation which causes two watchpoints on consecutive
ranges to not correctly identify hits to the second watchpoint. The
result is that lldb wouldn't show the second watchpoint as ever being
hit.

Re-landing this test with a modification to only require two
watchpoints in the test, instead of four.  If four watchpoints can
be set, it will test them.

rdar://145107575
2025-04-07 13:50:31 -07:00
Jason Molenda
369c7739d0 Revert "[lldb][debugserver] Fix an off-by-one error in watchpoint identification (#134314)"
This reverts commit 21d912121c.

Failure on the aarch64 ubuntu bot when setting the 4th watchpoint;
may be a hardware limitation on that bot.  I thought creating four
watchpoints would be generally safe, but I don't need to do that
for my test, will re-land without it.
2025-04-07 11:21:58 -07:00
Jason Molenda
21d912121c [lldb][debugserver] Fix an off-by-one error in watchpoint identification (#134314)
debugserver takes the address of a watchpoint exception and calculates
which watchpoint was responsible for it. There was an off-by-one error
in the range calculation which causes two watchpoints on consecutive
ranges to not correctly identify hits to the second watchpoint. The
result is that lldb wouldn't show the second watchpoint as ever being
hit.

rdar://145107575
2025-04-07 11:11:31 -07:00
Julian Lettner
4b90f24db8 [LLDB] Add integration test for libsanitizers trace collection (#134323)
Add integration test for libsanitizers trace collection
(`SanitizersAllocationTraces=all`).
    
rdar://144244084
2025-04-07 08:33:27 -07:00
Jonas Devlieghere
5f99e0d4b9 [lldb] Use the "reverse video" effect when colors are disabled. (#134203)
When you run lldb without colors (`-X`), the status line looks weird
because it doesn't have a background. You end up with what appears to be
floating text at the bottom of your terminal.

This patch changes the statusline to use the reverse video effect, even
when colors are off. The effect doesn't introduce any new colors and
just inverts the foreground and background color.

I considered an alternative approach which changes the behavior of the
`-X` option, so that turning off colors doesn't prevent emitting
non-color related control characters such as bold, underline, and
reverse video. I decided to go with this more targeted fix as (1) nobody
is asking for this more general change and (2) it introduces significant
complexity to plumb this through using a setting and driver flag so that
it can be disabled when running the tests.

Fixes #134112.
2025-04-03 13:51:17 -07:00
Adrian Prantl
a3ac318e5f [lldb] Skip test with older version of clang 2025-04-02 10:31:44 -07:00
Pavel Labath
b82fd71109 [lldb] Adjust skips on reverse continue tests (#133240)
The x86-specific issue has been fixed with #132122. Watchpoint tests
fail on aarch64 with macos<15.0 due to a kernel bug.
2025-03-28 09:41:56 +00:00
Jonas Devlieghere
9c18edc621 [lldb] Implement a statusline in LLDB (#121860)
Add a statusline to command-line LLDB to display information about the
current state of the debugger. The statusline is a dedicated area
displayed at the bottom of the screen. The information displayed is
configurable through a setting consisting of LLDB’s format strings.

Enablement
----------

The statusline is enabled by default, but can be disabled with the
following setting:

```
(lldb) settings set show-statusline false
```

Configuration
-------------

The statusline is configurable through the `statusline-format` setting.
The default configuration shows the target name, the current file, the
stop reason and any ongoing progress events.

```
(lldb) settings show statusline-format
statusline-format (format-string) = "${ansi.bg.blue}${ansi.fg.black}{${target.file.basename}}{ | ${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ | {${progress.count} }${progress.message}}"
```

The statusline supersedes the current progress reporting implementation.
Consequently, the following settings no longer have any effect (but
continue to exist to not break anyone's `.lldbinit`):

```
show-progress             -- Whether to show progress or not if the debugger's output is an interactive color-enabled terminal.
show-progress-ansi-prefix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately before the progress message.
show-progress-ansi-suffix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the progress message.
```

Format Strings
--------------

LLDB's format strings are documented in the LLDB documentation and on
the website: https://lldb.llvm.org/use/formatting.html#format-strings.
The current implementation is relatively limited but various
improvements have been discussed in the RFC.

One such improvement is being to display a string when a format string
is empty. Right now, when launching LLDB without a target, the
statusline will be empty, which is expected, but looks rather odd.

RFC
---

The full RFC can be found on Discourse:
https://discourse.llvm.org/t/rfc-lldb-statusline/83948
2025-03-26 14:41:05 -07:00
jimingham
870463519b Fix the managing of the session dictionary when you have nested wrappers (#132846)
Since the inner wrapper call might have removed one of the entries from
the global dict that the outer wrapper ALSO was going to delete, make
sure that we check that the key is still in the global dict before
trying to act on it.
2025-03-25 09:56:58 -07:00
Robert O'Callahan
f89a7fa319 [lldb] Ignore registers that the debugserver fails to read (#132122)
On Mac x86-64, the debugserver reports a register ('ds' at least) but
returns an error when we try to read it. Just skip storing such
registers in snapshots so we won't try to restore them.
2025-03-21 10:10:54 +01:00
Pavel Labath
861efd4b3f [lldb] Skip reverse continue tests on x86_64-darwin
Tests are failing because some registers (at least `ds`) are unreadable.
2025-03-19 13:35:14 +01:00
Dave Lee
57288136fe [lldb] Fix TestBreakpointLocations (#131890) 2025-03-18 22:57:35 -07:00
Pavel Labath
6d38dbf6eb [lldb] Skip reverse continue tests on macos<15.0
They're failing for unknown reasons.
2025-03-18 17:52:36 +01:00
Dave Lee
6d2b8285b3 [lldb] Support ordered patterns in lldbtest.expect (#131475)
Change `lldbtest.expect` to require the regexes in `patterns` be found in order – when the
`ordered` parameter is true. This matches the behavior of `substrs`.

The `ordered` parameter is true by default, so this change also fixes tests by either
tweaking the patterns to work in order, or by setting `ordered=False`.

I have often wanted to test with `patterns` and also verify the order. This change
allows that.
2025-03-17 14:30:39 -07:00
Pavel Labath
1b237198dc Reapply "[lldb] Implement basic support for reverse-continue (#125242)" (again) (#128156)
This reverts commit
87b7f63a11,
reapplying

7e66cf74fb
with a small (and probably temporary)
change to generate more debug info to help with diagnosing buildbot
issues.
2025-03-17 16:06:25 +01:00
Michael Buch
6a9df5b4dd Revert "[lldb][asan] Add temporary logging to ReportRetriever"
This reverts commit 39a4da20d8.

We skipped the failing tests in `6cc8b0bef07f4270303bec0fc203f251a2fde262`.
2025-03-10 11:37:13 +00:00
Greg Clayton
8ac359ba0d Add complete ObjectFileJSON support for sections. (#129916)
Sections now support specifying:
- user IDs
- file offset/size
- alignment
- flags
- bool values for fake, encrypted and thread specific sections
2025-03-07 15:34:27 -08:00
Michael Buch
6cc8b0bef0 [lldb][test] Skip libsanitizers tests for now (#130305)
These are macOS tests only and are currently failing on the x86_64 CI
and on arm64 on recent versions of macOS/Xcode.

The tests are failing because we're stopping in:
```
Process 17458 stopped
* thread #1: tid = 0xbda69a, 0x00000002735bd000
  libsystem_malloc.dylib`purgeable_print_self.cold.1, stop reason = EXC_BREAKPOINT (code=1, subcode=0x2735bd000)
```
instead of the libsanitizers library. This seems to be related to
`-fsanitize-trivial-abi` support

Skip these for now until we figure out the root cause.
2025-03-07 21:04:24 +00:00
Michael Buch
39a4da20d8 [lldb][asan] Add temporary logging to ReportRetriever
`TestReportData.py` is failing on the macOS CI with:
```
Traceback (most recent call last):
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1784, in test_method
    return attrvalue(self)
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 148, in wrapper
    return func(*args, **kwargs)
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/API/functionalities/asan/TestReportData.py", line 28, in test_libsanitizers_asan
    self.asan_tests(libsanitizers=True)
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/API/functionalities/asan/TestReportData.py", line 60, in asan_tests
    self.expect(
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2490, in expect
    self.fail(log_msg)
AssertionError: Ran command:
"thread list"

Got output:
Process 3474 stopped
* thread #1: tid = 0x38b5e9, 0x00007ff80f563b52 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT

Expecting sub string: "stopped" (was found)
Expecting sub string: "stop reason = Use of deallocated memory" (was not found)
Process should be stopped due to ASan report
```

There isn't much to go off of in the log, so adding more to help us debug this.
2025-03-07 07:09:18 +00:00
Greg Clayton
27901cec0e Add subsection and permissions support to ObjectFileJSON. (#129801)
This patch adds the ability to create subsections in a section and
allows permissions to be specified.
2025-03-04 16:19:20 -08:00
Greg Clayton
7b596ce362 [lldb] Fix ObjectFileJSON to section addresses. (#129648)
ObjectFileJSON sections didn't work, they were set to zero all of the
time. Fixed the bug and fixed the test to ensure it was testing real
values.
2025-03-04 14:35:42 -08:00
Felipe de Azevedo Piovezan
11b9466c04 [lldb] Add ability to inspect backing threads with thread info (#129275)
When OS plugins are present, it can be helpful to query information
about the backing thread behind an OS thread, if it exists. There is no
mechanism to do so prior to this commit.

As a first step, this commit enhances `thread info` with a
`--backing-thread` flag, causing the command to use the backing thread
of the selected thread, if it exists.
2025-02-28 16:13:12 -08:00
Eisuke Kawashima
24abf2c728 [lldb] fix(lldb/**.py): fix invalid escape sequences (#94034)
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-02-28 14:59:35 +00:00
rchamala
2ff3b18554 Allow option to ignore module load errors in ScriptedProcess (#127153)
Current state in scripted process expects [all the
modules](912b154f3a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp (L498))
passed into "get_loaded_images" to load successfully else none of them
load. Even if a module loads fine, [but has already been
appended](912b154f3a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp (L495))
it still fails. This is restrictive and does not help our usecase.

**Usecase**: We have a parent scripted process using coredump +
tombstone.

1) Scripted process uses child elf-core process to read memory dump

2) Uses tombstones to pass thread names and modules.

We do not know whether the modules will be successfully downloaded
before creating the scripted process. We use [python module
callbacks](a57e58dbfa/lldb/source/Target/Platform.cpp (L1593))
to download a module from symbol server at LLDB load time when the
scripted process is being created. The issue is that if one of the
symbol is not found from the list specified in tombstone, none of the
modules load in scripted process. Even if we ensure symbols are present
in symbol server before creating the scripted process, if the load
address is wrong or if the module is already appended, all module loads
are skipped.

**Solution**: Pass in a custom boolean option arg for every module from
python scripted process plugin which will indicate whether to ignore the
module load error. This will provide the flexibility to user for loading
the successfully fetched modules into target while ignoring the failed
ones

---------

Co-authored-by: rchamala <rachamal@fb.com>
2025-02-23 00:51:43 -08:00
Pavel Labath
917ed99d81 [lldb] Fix "in function" detection in "thread until" (#123622)
The implementation has an optimization which detects the range of line
table entries covered by the function and then only searches for a
matching line between them.

This optimization was interfering with the logic for detecting whether a
line belongs to the function because the first call to FindLineEntry was
made with exact=false, which meant that if the function did not contain
any exact matches, we would just pick the closest line number in that
range, even if it was very far away.

This patch fixes that by first attempting an inexact search across the
entire line table, and then use the (potentially inexact) result of that
for searching within the function. This makes the optimization a less
effective, but I don't think we can differentiate between a line that
belongs to the function (but doesn't have any code) and a line outside
the function without that.

The patch also avoids the use of (deprecated) Function::GetAddressRange
by iterating over the GetAddressRanges result to find the full range of
line entries for the function.
2025-02-21 13:17:36 +01:00
wanglei
89e80abbc5 [lldb][LoongArch] Complete register alias name in AugmentRegisterInfo
Fixes: https://github.com/llvm/llvm-project/issues/123903

Reviewed By: DavidSpickett, SixWeining

Pull Request: https://github.com/llvm/llvm-project/pull/124059
2025-02-21 10:59:27 +08:00
kper
c48e0c182c [lldb][RISC-V] Extended if conditions to support alias names for registers (#124475)
Extending the conditionals in `AugmentRegisterInfo` to support
alternative names for lldb.

Fixes #124023

There is an exception with register `X8` which is not covered here but
more details can be found in the issue
https://github.com/llvm/llvm-project/issues/127900.
2025-02-20 16:23:53 +00:00
Pavel Labath
58571c82ef [lldb] Un-XFAIL TestDeadStrip.py on windows
I suspect it was fixed by #127059. aarch64 is the only windows bot we have now, so it's can't be certain it's fixed everywhere, but also I have no reason to believe otherwise.

Fixes #43774.
2025-02-20 13:23:03 +01:00
Jonas Devlieghere
f62f13d5db [lldb] Store the return SBValueList in the CommandReturnObject (#127566)
There are a lot of lldb commands whose result is really one or more
ValueObjects that we then print with the ValueObjectPrinter. Now that we
have the ability to access the SBCommandReturnObject through a callback
(#125006), we can store the resultant ValueObjects in the return object,
allowing an IDE to access the SBValues and do its own rich formatting.

rdar://143965453
2025-02-19 15:17:35 -08:00
Jason Molenda
b666ac3b63 [lldb] Change lldb's breakpoint handling behavior, reland (#126988)
lldb today has two rules: When a thread stops at a BreakpointSite, we
set the thread's StopReason to be "breakpoint hit" (regardless if we've
actually hit the breakpoint, or if we've merely stopped *at* the
breakpoint instruction/point and haven't tripped it yet). And second,
when resuming a process, any thread sitting at a BreakpointSite is
silently stepped over the BreakpointSite -- because we've already
flagged the breakpoint hit when we stopped there originally.

In this patch, I change lldb to only set a thread's stop reason to
breakpoint-hit when we've actually executed the instruction/triggered
the breakpoint. When we resume, we only silently step past a
BreakpointSite that we've registered as hit. We preserve this state
across inferior function calls that the user may do while stopped, etc.

Also, when a user adds a new breakpoint at $pc while stopped, or changes
$pc to be the address of a BreakpointSite, we will silently step past
that breakpoint when the process resumes. This is purely a UX call, I
don't think there's any person who wants to set a breakpoint at $pc and
then hit it immediately on resuming.

One non-intuitive UX from this change, butt is necessary: If you're
stopped at a BreakpointSite that has not yet executed, you `stepi`, you
will hit the breakpoint and the pc will not yet advance. This thread has
not completed its stepi, and the ThreadPlanStepInstruction is still on
the stack. If you then `continue` the thread, lldb will now stop and
say, "instruction step completed", one instruction past the
BreakpointSite. You can continue a second time to resume execution.

The bugs driving this change are all from lldb dropping the real stop
reason for a thread and setting it to breakpoint-hit when that was not
the case. Jim hit one where we have an aarch64 watchpoint that triggers
one instruction before a BreakpointSite. On this arch we are notified of
the watchpoint hit after the instruction has been unrolled -- we disable
the watchpoint, instruction step, re-enable the watchpoint and collect
the new value. But now we're on a BreakpointSite so the watchpoint-hit
stop reason is lost.

Another was reported by ZequanWu in
https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282 we
attach to/launch a process with the pc at a BreakpointSite and
misbehave. Caroline Tice mentioned it is also a problem they've had with
putting a breakpoint on _dl_debug_state.

The change to each Process plugin that does execution control is that

1. If we've stopped at a BreakpointSite that has not been executed yet,
we will call Thread::SetThreadStoppedAtUnexecutedBP(pc) to record that.
When the thread resumes, if the pc is still at the same site, we will
continue, hit the breakpoint, and stop again.

2. When we've actually hit a breakpoint (enabled for this thread or
not), the Process plugin should call
Thread::SetThreadHitBreakpointSite(). When we go to resume the thread,
we will push a step-over-breakpoint ThreadPlan before resuming.

The biggest set of changes is to StopInfoMachException where we
translate a Mach Exception into a stop reason. The Mach exception codes
differ in a few places depending on the target (unambiguously), and I
didn't want to duplicate the new code for each target so I've tested
what mach exceptions we get for each action on each target, and
reorganized StopInfoMachException::CreateStopReasonWithMachException to
document these possible values, and handle them without specializing
based on the target arch.

I first landed this patch in July 2024 via
https://github.com/llvm/llvm-project/pull/96260

but the CI bots and wider testing found a number of test case failures
that needed to be updated, I reverted it. I've fixed all of those issues
in separate PRs and this change should run cleanly on all the CI bots
now.

rdar://123942164
2025-02-13 11:30:10 -08:00
Jason Molenda
cbb4e99f36 [lldb] Update ThreadPlanStepOut to handle new breakpoint behavior (#126838)
I will be changing breakpoint hitting behavior soon, where currently
lldb reports a breakpoint as being hit when a thread is *at* a
BreakpointSite, but possibly has not executed the breakpoint instruction
and trapped yet, to having lldb only report a breakpoint hit when the
breakpoint instruction has actually been executed.

One corner case bug with this change is that when you are stopped at a
breakpoint (that has been hit) on the last instruction of a function,
and you do `finish`, a ThreadPlanStepOut is pushed to the thread's plan
stack to put a breakpoint on the return address and resume execution.
And when the thread is asked to resume, it sees that it is at a
BreakpointSite that has been hit, and pushes a
ThreadPlanStepOverBreakpoint on the thread.   The StepOverBreakpoint
plan sees that the thread's state is eStateRunning (not eStateStepping),
so it marks itself as "auto continue" -- so once the breakpoint has
been stepped over, we will execution on the thread.

With current lldb stepping behavior ("a thread *at* a BreakpointSite is
said to have stopped with a breakpoint-hit stop reason, even if the
breakpoint hasn't been executed yet"),
`ThreadPlanStepOverBreakpoint::DoPlanExplainsStop` has a special bit of
code which detects when the thread stops with a eStopReasonBreakpoint.
It first checks if the pc is the same as when we started -- did our
"step instruction" not actually step? -- says the stop reason is
explained. Otherwise it sets auto-continue to false (because we've hit
an *unexpected* breakpoint, and we have advanced past our original pc,
and returns false - the stop reason is not explained.

So we do the "finish", lldb instruction steps, we stop *at* the
return-address breakpoint and lldb sets the thread's stop reason to
breakpoint-hit. ThreadPlanStepOverBreakpoint sees an
eStopReasonBreakpoint, sets its auto-continue to false, and says we
stopped for osme reason other than this plan. (and it will also report
`IsPlanStale()==true` so it will remove itself) Meanwhile the
ThreadPlanStepOut sees that it has stopped in the StackID it wanted to
run to, and return success.

This all changes when stopping at a breakpoint site doesn't report
breakpoint-hit until we actually execute the instruction. Now the
ThraedPlanStepOverBreakpoint looks at the thread's stop reason, it's
eStopReasonTrace (we've instruction stepped), and so it leaves its
auto-continue to `true`. ThreadPlanStepOut sees that it has reached its
goal StackID, removes its breakpoint, and says it is done.
Thread::ShouldStop thinks the auto-continue == yes vote from
ThreadPlanStepOverBreakpoint wins, and we lose control of the process.

This patch changes ThreadPlanStepOut to require that *both* (1) we are
at the StackID of the caller function, where we wanted to end up, and
(2) we have actually hit the breakpoint that we inserted.

This in effect means that now lldb instruction-steps over the breakpoint
in the callee function, stops at the return address of the caller
function. StepOverBreakpoint has completed. StepOut is still running,
and we continue the thread again. We immediatley hit the breakpoint
(that we're sitting at), and now ThreadPlanStepOut marks itself as
completed, and we return control to the user.

Jim suggests that ThreadPlanStepOverBreakpoint is a bit unusual because
it's not something pushed on the stack by a higher-order thread plan
that "owns" it, it is inserted by the Thread as it is about to resume,
if we're at a BreakpointSite. It has no connection to the thread plans
above it, but tries to set the auto-continue mode based on the state of
the thread when it is inserted (and tries to detect an unexpected
breakpoint and unset that auto-continue it previously decided on,
because it now realizes it should not influence execution control any
more). Instead maybe the
ThreadPlanStepOverBreakpoint should be inserted as a child plan of
whatever the lowest plan is on the stack at the point it is added.

I added an API test that will catch this bug in the new thread
breakpoint algorithm.
2025-02-12 13:48:01 -08:00
Felipe de Azevedo Piovezan
b8002933e9 [lldb] Add missing return statements in ThreadMemory (#126128)
These prevented ThreadMemory from correctly returning the
Name/Queue/Info of the backing thread.

Note about testing: this test only finds regressions if the system sets
a name or queue for the backing thread. While this may not be true
everywhere, it still provides coverage in some systems, e.g. in Apple
platforms.
2025-02-06 15:59:43 -08:00
Jason Molenda
8b65411b00 [lldb][NFC] Remove old skipIfOutOfTreeDebugserver's (#126144)
When a test depends on a new debugserver feature/fix, the API test must
be marked @skipIfOutOfTreeDebugserver because the macOS CI bots test
using the latest Xcode release debugserver. But over time all of these
fixes & new features are picked up in the Xcode debugserver and these
skips can be removed.

We may see unexpected test failures from removing all of these 1+ year
old skips, but that's likely a separate reason the test is failing that
is being papered over by this skip.
2025-02-06 14:50:09 -08:00
Jacob Lalonde
ce7bca7691 [LLDB][Save Core Options] Custom ranges should follow the same safety checks as everyone else (#125323)
I encountered a `qMemoryRegionInfo not supported` error when capturing a
Minidump. This was surprising, and I started looking around I found
@jasonmolenda's fix in #115963 and then realized I was not validated
anything from the custom ranges.
2025-02-03 19:22:01 -08:00
Zequan Wu
e269c2b5fa [lldb] Show value for libcxx and libstdcxx summary and remove pointer value in libcxx container summary (#125294)
This has two changes:
1. Set show value for libcxx and libstdcxx summary provider. This will
print the pointer value for both pointer type and reference type.
2. Remove pointer value printing in libcxx container summary.

Discussion:

https://discourse.llvm.org/t/lldb-hides-raw-pointer-value-for-libcxx-and-libstdcxx-pointer-types-in-summary-string/84226
2025-02-03 14:34:20 -05:00