18736 Commits

Author SHA1 Message Date
Pavel Labath
1c5ce2d74f Reapply "[lldb] ProcessGdbRemote header gardning"
This reverts commit 68ab45f0533f3bbfc1c96bddd53de7e769180219, reapplying
2fd860c1f559c0b0be66cc000e38270a04d0a1a3. The only change is keeping
"lldb/Host/Config.h", which I believe was the cause of the failures.
2025-04-13 09:52:30 +02:00
Pavel Labath
f4fba20726
[lldb] Remove vestigial remnants of reproducers (#135361)
Not touching the SB API.
2025-04-13 08:55:24 +02:00
Alexandre Ganea
e1d91ba06d [lldb] Fix erroneous return value
Found when building with MSVC on Windows, was seeing:
```
[2703/7138] Building CXX object tools\lldb\source\Plugins\Process\Utility\CMakeFiles\lldbPluginProcessUtility.dir\NativeRegisterContextDBReg.cpp.obj
C:\git\llvm-project\lldb\source\Plugins\Process\Utility\NativeRegisterContextDBReg.cpp(286): warning C4305: 'return': truncation from 'unsigned int' to 'bool'
```
2025-04-11 17:50:15 -04:00
Jonas Devlieghere
179d30f8c3
Revert "[lldb] Make sure the process is stopped when computing the symbol context (#134757)" (#135408)
This reverts commit e84a80408523a48d6eaacd795f1615e821ffb233 because on
Linux there seems to be a race around GetRunLock. See #134757 for more
context.
2025-04-11 11:50:42 -07:00
Felipe de Azevedo Piovezan
c2939b9bf6
Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (#135296)
This reapplies commit
232525f069.

The original commit triggered a sanitizer failure when `Target` was
destroyed. In `Target::Destroy`, `DeleteCurrentProcess` was called, but
it did not destroy the thread creation breakpoints for the underlying
`ProcessGDBRemote` because `ProcessGDBRemote::Clear` was not called in
that path.

`Target `then proceeded to destroy its breakpoints, which resulted in a
call to the destructor of a `std::vector` containing the breakpoints.
Through a sequence of complicated events, destroying breakpoints caused
the reference count of the underlying `ProcessGDBRemote` to finally
reach zero. This, in turn, called `ProcessGDBRemote::Clear`, which
attempted to destroy the breakpoints. To do that, it would go back into
the Target's vector of breakpoints, which we are in the middle of
destroying.

We solve this by moving the breakpoint deletion into
`Process:DoDestroy`, which is a virtual Process method that will be
called much earlier.
2025-04-11 11:46:22 -07:00
Jonas Devlieghere
68ab45f053
Revert "[lldb] ProcessGdbRemote header gardning"
This reverts commit 2fd860c1f559c0b0be66cc000e38270a04d0a1a3 as this is
causing a EXC_BAD_ACCESS on Darwin:

https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/23807/
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/11255/
2025-04-11 10:44:43 -07:00
Jonas Devlieghere
70627af91f
[lldb] Synchronize access to m_statusline in the Debugger (#134759)
Eliminate the potential for a race between the main thread, the default
event handler thread and the signal handling thread, when accessing the
m_statusline member.
2025-04-11 08:53:49 -07:00
Ebuka Ezike
dda53bef35
[lldb] Fix SBTarget::ReadInstruction with flavor (#134626)
When you call the `SBTarget::ReadInstructions` with flavor from lldb
crashes. This is because the wrong order of the `DisassemblyBytes`
constructor this fixes that

---------

Signed-off-by: Ebuka Ezike <yerimyah1@gmail.com>
2025-04-11 13:45:19 +01:00
Pavel Labath
2fd860c1f5 [lldb] ProcessGdbRemote header gardning
Remove unused headers, add used headers, remove declared-but-not-defined
entities.
2025-04-11 14:36:08 +02:00
Michael Buch
b656915d5a
[lldb][Format][NFCI] Refactor CPlusPlusLanguage::GetFunctionDisplayName into helpers and use LLVM style (#135331)
Same cleanup as in https://github.com/llvm/llvm-project/pull/135031. It
pretty much is the same code that we had to duplicate in the language
plugin. Maybe eventually we'll find a way of getting rid of the
duplication.
2025-04-11 11:01:27 +01:00
Pavel Labath
23c9cfcb74
[lldb] Small refactor of eh_frame parsing (#134806)
.. which prepares us for handling of discontinuous functions. The main
change there is that we can have multiple FDEs contributing towards an
unwind plan of a single function. This patch separates the logic for
parsing of a single FDE from the construction of an UnwindPlan (so that
another patch can change the latter to combine several unwind plans).

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-04-11 09:27:56 +02:00
Jonas Devlieghere
a62b9b387f
[lldb] Calling Debugger::SetStatuslineFormat should redraw the statusline 2025-04-10 16:55:59 -07:00
Jonas Devlieghere
2b984fd0e3
[lldb] Support programmatically setting the statusline format (NFC) (#135250)
Support programmatically setting the statusline format. I want to use
this API downstream, to change the statusline format for the Swift REPL.
2025-04-10 15:36:28 -07:00
Pavel Labath
cdb9c6190f
[lldb] Support negative function offsets in UnwindPlans (#134662)
These are needed for functions whose entry point is not their lowest
address.
2025-04-10 11:31:44 +02:00
Michael Buch
f030f6f3c5
[lldb][FormatEntity][NFCI] Refactor FunctionNameWithArgs into helper functions and use LLVM style (#135031)
I've always found this hard to read. Some upcoming changes make similar
computations, so I thought it's a good time to factor out this logic
into re-usable helpers and clean it up using LLVM's preferred
early-return style.
2025-04-10 09:39:58 +01:00
Jacob Lalonde
e98d1380a0
[NFC][LLDB] Clean up comments/some code in MinidumpFileBuilder (#134961)
I've recently been working on Minidump File Builder again, and some of
the comments are out of date, and many of the includes are no longer
used. This patch removes unneeded includes and rephrases some comments
to better fit with the current state after the read write chunks pr.
2025-04-09 10:55:30 -07:00
David Spickett
a29be9f28e
Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies" (#134995)
Reverts llvm/llvm-project#132274

Broke a test on LLDB Widows on Arm:
https://lab.llvm.org/buildbot/#/builders/141/builds/7726
```
FAIL: test_dwarf (lldbsuite.test.lldbtest.TestExternCSymbols.test_dwarf)
<...>
    self.assertTrue(self.res.Succeeded(), msg + output)

AssertionError: False is not true : Command 'expression -- foo()' did not return successfully

Error output:

error: Couldn't look up symbols:

  int foo(void)

Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler.
```
2025-04-09 13:16:23 +01:00
Pavel Labath
ea7dd70b53
[lldb] Remove unused UnwindPlan functions (#134630)
`GetLSDAAddress` and `GetPersonalityRoutinePtrAddress` are unused and
they create a bit of a problem for discontinuous functions, because the
unwind plan for these consists of multiple eh_frame descriptors and (at
least in theory) each of them could have a different value for these
entities.

We could say we only support functions for which these are always the
same, or create some sort of a Address2LSDA lookup map, but I think it's
better to leave this question to someone who actually needs this.
2025-04-09 11:04:45 +02:00
yingopq
8877b913ae
[LLDB][MIPS] Fix signal SIGBUS number mismatch error on mips target (#132688)
Now, because we do not support mips debugging, if we compile LLVM on
mips target, would report error `static assertion failed:Value mismatch
for signal number SIGBUS`, so add this condition to avoid error.
2025-04-09 10:53:47 +02:00
Pavel Labath
e348173bef
Reapply "[lldb] Remove UnwindPlan::Row shared_ptrs" (#134821)
This reverts commit
48864a52ef,
reapplying d7cea2b187.
It also fixes the dangling
pointers caused by the previous version by creating copies of the Rows
in x86AssemblyInspectionEngine.
2025-04-09 08:22:15 +02:00
Dmitry Vasilyev
fbc6241d3a
[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (#132274)
This patch addresses the issue #129543.
After this patch the size of lldb-server is reduced by 9MB.

Co-authored-by: @bulbazord Alex Langford
2025-04-09 09:11:56 +04:00
Jason Molenda
50e218ad9c Revert "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)"
This reverts commit 232525f06942adb3b9977632e38dcd5f08c0642d.

This change is causing test crashes while running
TestCompletion.py on Darwin systems, most of the CI runs
have failed since it has been merged in.
2025-04-08 21:05:50 -07:00
Jason Molenda
76d722732d [lldb][Minidump] Fix MAX_WRITE_CHUNK_SIZE type
MinidumpFileBuilder calls std::min(MAX_WRITE_CHUNK_SIZE,
func_returning_uint64_t) and on Darwin this errors out with
unsigned long long & unsigned long not being the same type.
2025-04-08 14:00:42 -07:00
cmtice
c4c0ff6865
[LLDB] Fix warnings in DIL. (#134778)
This fixes 3 warnings from compiling the DILParser:

DILParser.h:53:12: warning: returning address of local temporary object
[-Wreturn-stack-address]

DILParser.h:119:8: warning: private field 'm_fragile_ivar' is not used
[-Wunused-private-field]

DILParser.h:120:8: warning: private field 'm_check_ptr_vs_member' is not
used [-Wunused-private-field]
2025-04-08 11:37:54 -07:00
Dmitry Vasilyev
7e70d708a3
[LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (#134383)
It reduces the memory usage in lldb-server.
2025-04-08 22:24:59 +04:00
Jonas Devlieghere
e84a804085
[lldb] Make sure the process is stopped when computing the symbol context (#134757)
Make sure the process is stopped when computing the symbol context. Both
Adrian and Felipe reported a handful of crashes in GetSymbolContext
called from Statusline::Redraw on the default event thread.

Given that we're handling a StackFrameSP, it's not clear to me how that
could have gotten invalidated, but Jim points out that it doesn't make
sense to compute the symbol context for the frame when the process isn't
stopped.
2025-04-08 11:06:05 -07:00
Adrian Prantl
2721d50d87 Revert "[dsymutil] Avoid copying binary swiftmodules built from textual"
This reverts commit 39ace8a63012af7d6ad7bf065c233fd3d5df44a3.

while investigating Linux bot failures.
2025-04-08 09:49:36 -07:00
Jacob Lalonde
f869d6efee
[LLDB][Minidump]Update MinidumpFileBuilder to read and write in chunks (#129307)
I recently received an internal error report that LLDB was OOM'ing when
creating a Minidump. In my 64b refactor we made a decision to acquire
buffers the size of the largest memory region so we could read all of
the contents in one call. This made error handling very simple (and
simpler coding for me!) but had the trade off of large allocations if
huge pages were enabled.

This patch is one I've had on the back burner for awhile, but we can
read and write the Minidump memory sections in discrete chunks which we
already do for writing to disk.

I had to refactor the error handling a bit, but it remains the same. We
make a best effort attempt to read as much of the memory region as
possible, but fail immediately if we receive an error writing to disk. I
did not add new tests for this because our existing test suite is quite
good, but I did manually verify a few Minidumps couldn't read beyond the
red_zone.

```
(lldb) reg read $sp
     rsp = 0x00007fffffffc3b0
(lldb) p/x 0x00007fffffffc3b0 - 128
(long) 0x00007fffffffc330
(lldb) memory read 0x00007fffffffc330
0x7fffffffc330: 60 c3 ff ff ff 7f 00 00 60 cd ff ff ff 7f 00 00  `.......`.......
0x7fffffffc340: 60 c3 ff ff ff 7f 00 00 65 e6 26 00 00 00 00 00  `.......e.&.....
(lldb) memory read 0x00007fffffffc329
error: could not parse memory info (Success!)
```

I'm not sure how to quantify the memory improvement other than we would
allocate the largest size regardless of the size. So a 2gb unreadable
region would cause a 2gb allocation even if we were reading 4096 kb. Now
we will take the range size or the max chunk size of 128 mb.
2025-04-08 09:47:52 -07:00
Adrian Prantl
5615061445
[dsymutil] Avoid copying binary swiftmodules built from textual (#134719)
.swiftinterface files into the dSYM bundle. These typically come only
from the SDK (since textual interfaces require library evolution) and
thus are a waste of space to copy into the bundle.

The information about this is being parsed out of the control block,
which means duplicating 5 constants from the Swift frontend. If a file
cannot be parsed, dsymutil errs on the side of copying the file anyway.

rdar://138186524
2025-04-08 08:03:32 -07:00
Tom Yang
65813e0e94
Control Darwin parallel image loading with target.parallel-module-load (#134437)
A requested follow-up from
https://github.com/llvm/llvm-project/pull/130912 by @JDevlieghere to
control Darwin parallel image loading with the same
`target.parallel-module-load` that controls the POSIX dyld parallel
image loading. Darwin parallel image loading was introduced by
https://github.com/llvm/llvm-project/pull/110646.

This small change:
* removes
`plugin.dynamic-loader.darwin.experimental.enable-parallel-image-load`
and associated code.
* changes setting call site in
`DynamicLoaderDarwin::PreloadModulesFromImageInfos` to use the new
setting.

Tested by running `ninja check-lldb` and loading some targets.

Co-authored-by: Tom Yang <toyang@fb.com>
2025-04-07 16:33:48 -07:00
Felipe de Azevedo Piovezan
6272e1f37e
[lldb] Make RegisterContextThreadMemory thread safe (#134469)
The UpdateRegisterContext method can be called from multiple threads.
2025-04-04 18:43:31 -07:00
Jonas Devlieghere
5271dead61
[lldb] Add a {ObjectFile,SymbolFile}::GetObjectName method (#133370)
Add ObjectFile::GetObjectName and SymbolFile::GetObjectName to retrieve
the name of the object file, including the `.a` for static libraries.

We currently do something similar in CommandObjectTarget, but the code
for dumping this is a lot more involved than what's being offered by the
new method. We have options to print he full path, the base name, and
the directoy of the path and trim it to a specific width. 

This is motivated by #133211, where Greg pointed out that the old code
would print the static archive (the .a file) rather than the actual
object file inside of it.
2025-04-04 16:33:40 -07:00
Jonas Devlieghere
03604a7840
[lldb] Make lldbassert fire only once per instance (#134343)
The `lldbassert` macro in LLDB behaves like a regular `assert` when
assertions are enabled, and otherwise prints a pretty backtrace and
prompts the user to file a bug. By default, this is emitted as a
diagnostic event, but vendors can provide their own behavior, for
example pre-populating a bug report.

Recently, we ran into an issue where an `lldbassert` (in the Swift
language plugin) would fire excessively, to the point that it was
interfering with the usability of the debugger.

Once an `lldbasser` has fired, there's no point in bothering the user
over and over again for the same problem. This PR solves the problem by
introducing a static `std::once_flag` in the macro. This way, every
`lldbasser` will fire at most once per lldb instance.

rdar://148520448
2025-04-04 12:53:10 -07:00
Felipe de Azevedo Piovezan
232525f069
[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)
Currently, these breakpoints are being accumulated every time a new
process if created (e.g. through a `run`). Depending on the
circumstances, the old breakpoints are even left enabled, interfering
with subsequent processes. This is addressed by removing the breakpoints
in ProcessGDBRemote::Clear

Note that these breakpoints are more of a PlatformDarwin thing, so in
the future we should look into moving them there.
2025-04-04 10:05:44 -07:00
Vy Nguyen
a2e888f5b4
[LLDB][NFC]Fix stack-use-after free bug. (#134296)
Details: detailed_command_telemetry (bool) and command_id (int) could
already be freed when the dispatcher's dtor runs. So we should just copy
them into the lambda since they are cheap.
2025-04-04 08:00:46 -04:00
Pavel Labath
e4f76e3a33
Reapply "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders " (#134246)
This reverts commit 094904303d50e0ab14bc5f2586a602f79af95953, reapplying
d7afafdbc464e65c56a0a1d77bad426aa7538306 (#133247).

The failure ought to be fixed by
0509932bb6a291ba11253f30c465ab3ad164ae08.
2025-04-04 09:49:27 +02:00
cmtice
46e2c07fa2
[LLDB] Add DIL code for handling plain variable names. (#120971)
Add the Data Inspection Language (DIL) implementation pieces for
handling plain local and global variable names.

See https://discourse.llvm.org/t/rfc-data-inspection-language/69893 for
information about DIL.

This change includes the basic AST, Lexer, Parser and Evaluator pieces,
as well as some tests.
2025-04-03 21:39:30 -07:00
Jacob Lalonde
8e7d6baf0e
Revert "[LLDB] Expose checking if the symbol file exists/is loaded via SBModule" (#134341)
Reverts llvm/llvm-project#134163

Reverting while @clayborg and I come up with a better API
2025-04-03 20:45:55 -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
Felipe de Azevedo Piovezan
c14b6e90bd
[lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo (#134160)
This NFC patch simplifies the main loop in HandleProcessStateChanged
event by moving duplicated code into the StopInfo class, also allowing
StopInfo subclasses to override behavior.

More specifically, two functions are created:

* ShouldShow: should a Thread with such StopInfo should be printed when
the debugger stops? Currently, no StopInfo subclasses override this, but
a subsequent patch will fix a bug by making StopInfoBreakpoint check
whether the breakpoint is internal.

* ShouldSelect: should a Thread with such a StopInfo be selected? This
is currently overridden by StopInfoUnixSignal but will, in the future,
be overridden by StopInfoBreakpoint.
2025-04-03 07:41:29 -07:00
Pavel Labath
0509932bb6 [lldb] Initialize active_row pointer variable
It's value is not set on all control flow paths. I believe this should
fix the failure on some buildbots after #133247.
2025-04-03 15:15:09 +02:00
Michael Buch
554f4d1a57
[lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (#134097)
When using `SBFrame::EvaluateExpression` on a frame that's not the
currently selected frame, we would sometimes run into errors such as:
```
error: error: The context has changed before we could JIT the expression!
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```

During expression parsing, we call `RunStaticInitializers`. On our
internal fork this happens quite frequently because any usage of, e.g.,
function pointers, will inject ptrauth fixup code into the expression.
The static initializers are run using `RunThreadPlan`. The
`ExecutionContext::m_frame_sp` going into the `RunThreadPlan` is the
`SBFrame` that we called `EvaluateExpression` on. LLDB then tries to
save this frame to restore it after the thread-plan ran (the restore
occurs by unconditionally overwriting whatever is in
`ExecutionContext::m_frame_sp`). However, if the `selected_frame_sp` is
not the same as the `SBFrame`, then `RunThreadPlan` would set the
`ExecutionContext`'s frame to a different frame than what we started
with. When we `PrepareToExecuteJITExpression`, LLDB checks whether the
`ExecutionContext` frame changed from when we initially
`EvaluateExpression`, and if did, bails out with the error above.

One such test-case is attached. This currently passes regardless of the
fix because our ptrauth static initializers code isn't upstream yet. But
the plan is to upstream it soon.

This patch addresses the issue by saving/restoring the frame of the
incoming `ExecutionContext`, if such frame exists. Otherwise, fall back
to using the selected frame.

rdar://147456589
2025-04-03 11:10:16 +01:00
Pavel Labath
662d385c7b
[lldb/telemetry] Report exit status only once (#134078)
SetExitStatus can be called the second time when we reap the debug
server process. This shouldn't be interesting as at that point, we've
already told everyone that the process has exited.

I believe/hope this will also help with sporadic shutdown crashes that
have cropped up recently. They happen because the debug server is
monitored from a detached thread, so this code can be called after main
returns (and starts destroying everything). This isn't a real fix for
that though, as the situation can still happen (it's just that it
usually happens after the exit status has already been set). I think the
real fix for that is to make sure these threads terminate before we
start shutting everything down.
2025-04-03 11:59:02 +02:00
Vladislav Dzhidzhoev
094904303d Revert "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders (#133247)"
This reverts commit d7afafdbc464e65c56a0a1d77bad426aa7538306.

Caused remote Linux to Linux buildbot failure
https://lab.llvm.org/buildbot/#/builders/195/builds/7046.
2025-04-03 11:33:11 +02:00
Jacob Lalonde
b8d8405238
[LLDB] Expose checking if the symbol file exists/is loaded via SBModule (#134163)
The motivation for this patch is that in Statistics.cpp we [check to see
if the module symfile is
loaded](990a086d9d/lldb/source/Target/Statistics.cpp (L353C60-L353C75))
to calculate how much debug info has been loaded. I have an external
utility that only wants to look at the loaded debug info, which isn't
exposed by the SBAPI.
2025-04-02 21:27:44 -07:00
Jeremy Day
be3abfc00f
[lldb] Clear thread name container before writing UTF8 bytes (#134150)
`llvm::convertUTF16ToUTF8String` opens with an assertion that the output
container is empty:
3bdf9a0880/llvm/lib/Support/ConvertUTFWrapper.cpp (L83-L84)

It's not clear to me why this function requires the output container to
be empty instead of just overwriting it, but the callsite in
`TargetThreadWindows::GetName` may reuse the container without clearing
it out first, resulting in an assertion failure:
```
 # Child-SP          RetAddr               Call Site
00 000000d2`44b8ea48 00007ff8`beefc12e     ntdll!NtTerminateProcess+0x14
01 000000d2`44b8ea50 00007ff8`bcf518ab     ntdll!RtlExitUserProcess+0x11e
02 000000d2`44b8ea80 00007ff8`bc0e0143     KERNEL32!ExitProcessImplementation+0xb
03 000000d2`44b8eab0 00007ff8`bc0e4c49     ucrtbase!common_exit+0xc7
04 000000d2`44b8eb10 00007ff8`bc102ae6     ucrtbase!abort+0x69
05 000000d2`44b8eb40 00007ff8`bc102cc1     ucrtbase!common_assert_to_stderr<wchar_t>+0x6e
06 000000d2`44b8eb80 00007fff`b8e27a80     ucrtbase!wassert+0x71
07 000000d2`44b8ebb0 00007fff`b8b821e1     liblldb!llvm::convertUTF16ToUTF8String+0x30 [D:\r\_work\swift-build\swift-build\SourceCache\llvm-project\llvm\lib\Support\ConvertUTFWrapper.cpp @ 88] 
08 000000d2`44b8ec30 00007fff`b83e9aa2     liblldb!lldb_private::TargetThreadWindows::GetName+0x1b1 [D:\r\_work\swift-build\swift-build\SourceCache\llvm-project\lldb\source\Plugins\Process\Windows\Common\TargetThreadWindows.cpp @ 198] 
09 000000d2`44b8eca0 00007ff7`2a3c3c14     liblldb!lldb::SBThread::GetName+0x102 [D:\r\_work\swift-build\swift-build\SourceCache\llvm-project\lldb\source\API\SBThread.cpp @ 432] 
0a 000000d2`44b8ed70 00007ff7`2a3a5ac6     lldb_dap!lldb_dap::CreateThread+0x1f4 [S:\SourceCache\llvm-project\lldb\tools\lldb-dap\JSONUtils.cpp @ 877] 
0b 000000d2`44b8ef10 00007ff7`2a3b0ab5     lldb_dap!`anonymous namespace'::request_threads+0xa6 [S:\SourceCache\llvm-project\lldb\tools\lldb-dap\lldb-dap.cpp @ 3906] 
0c 000000d2`44b8f010 00007ff7`2a3b0fe8     lldb_dap!lldb_dap::DAP::HandleObject+0x1c5 [S:\SourceCache\llvm-project\lldb\tools\lldb-dap\DAP.cpp @ 796] 
0d 000000d2`44b8f130 00007ff7`2a3a8b96     lldb_dap!lldb_dap::DAP::Loop+0x78 [S:\SourceCache\llvm-project\lldb\tools\lldb-dap\DAP.cpp @ 812] 
0e 000000d2`44b8f1d0 00007ff7`2a4b5fbc     lldb_dap!main+0x1096 [S:\SourceCache\llvm-project\lldb\tools\lldb-dap\lldb-dap.cpp @ 5319] 
0f (Inline Function) --------`--------     lldb_dap!invoke_main+0x22 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 78] 
10 000000d2`44b8fb80 00007ff8`bcf3e8d7     lldb_dap!__scrt_common_main_seh+0x10c [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 
11 000000d2`44b8fbc0 00007ff8`beefbf6c     KERNEL32!BaseThreadInitThunk+0x17
12 000000d2`44b8fbf0 00000000`00000000     ntdll!RtlUserThreadStart+0x2c
```

This stack trace was captured from the lldb distributed in the Swift
toolchain. The issue is easy to reproduce by resuming from a breakpoint
twice in VS Code.

I've verified that clearing out the container here fixes the assertion
failure.
2025-04-02 16:35:02 -07:00
Dave Lee
93d3775da8
[lldb] Fix tagged-pointer info address parsing (#134123)
Change `objc tagged-pointer info` to call
`OptionArgParser::ToRawAddress`.

Previously `ToAddress` was used, but it calls `FixCodeAddress`, which
can erroneously mutate the bits of a tagged pointer.
2025-04-02 15:16:58 -07:00
David Peixotto
2026873fb8
Add enable/disable api for SystemRuntime plugins (#133794)
This commit adds support for enabling and disabling plugins by name. The
changes are made generically in the `PluginInstances` class, but
currently we only expose the ability to SystemRuntime plugins. Other
plugins types can be added easily.

We had a few design goals for how disabled plugins should work

1. Plugins that are disabled should still be visible to the system. This
allows us to dynamically enable and disable plugins and report their
state to the user.
2. Plugin order should be stable across disable and enable changes. We
want avoid changing the order of plugin lookup. When a plugin is
re-enabled it should return to its original slot in the creation order.
3. Disabled plugins should not appear in PluginManager operations.
Clients should be able to assume that only enabled plugins will be
returned from the PluginManager.

For the implementation we modify the plugin instance to maintain a bool
of its enabled state. Existing clients external to the Instances class
expect to iterate over only enabled instance so we skip over disabed
instances in the query and snapshot apis. This way the client does not
have to manually check which instances are enabled.
2025-04-02 13:15:31 -07:00
Jonas Devlieghere
6f959a46c0
[lldb] uint8_t -> unsigned short in std::independent_bits_engine
According to [1], the template parameter must be cv-unqualified and one
of unsigned short, unsigned int, unsigned long, or unsigned long long.

Should fix the following MSVC error:

  error: static assertion failed due to requirement
  '_Is_any_of_v<unsigned char, unsigned short, unsigned int, unsigned
  long, unsigned long long>': invalid template argument for
  independent_bits_engine: N4659

[1] https://en.cppreference.com/w/cpp/numeric/random/independent_bits_engine
2025-04-02 09:23:35 -07:00
Jonas Devlieghere
ee60f7c7a4
[lldb] Hoist UUID generation into the UUID class (#133662)
Hoist UUID generation into the UUID class and add a trivial unit test.
This also changes the telemetry code to drop the double underscore if we
failed to generate a UUID and subsequently logs to the Host instead of
Object log channel.
2025-04-02 08:50:28 -07:00