1538 Commits

Author SHA1 Message Date
Aiden Grossman
74c8891c9a Revert "[lldb] Fix TSan report on Linux (#179115)"
This reverts commit cc7292056683f592c33055bb6456d509201654ec.

This patch causes two tests to unexpectedly pass:
1. lldb-api.functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py
2. lldb-api.functionalities/tsan/global_location/TestTsanGlobalLocation.py

Reverting to fix premerge. Not fixing forward so someone who is familiar
with LLDB can take a look and make sure those tests now should pass.
2026-02-09 18:50:17 +00:00
Sergei Druzhkov
cc72920566
[lldb] Fix TSan report on Linux (#179115)
Linux uses 0 for `RTLD_DEFAULT` opposite to macOS and BSD systems (they
use -2).
2026-02-09 20:03:46 +03:00
Michael Buch
a07347f609
[lldb][test] Rename/remove duplicate methods in API tests (#180250)
Ran my python script from
https://github.com/llvm/llvm-project/pull/97043 over the repo again and
there were 2 duplicate test-cases that have been introduced since I last
did this.

Also one of the WASM classes had a duplicate method which I just
removed.
2026-02-09 09:47:14 +00:00
jimingham
124c8b4054
Fix the modal private state thread we use for running expressions on the private state thread (#179799)
We have a problem when some code on the private state thread needs to
run an expression. The private state thread is the one that fetches
"raw" events from the Process Plugin and decides how to handle them. But
if the private state thread needs to fetch the processed events to drive
running an expression, it can't also be the thread processing the raw
events.

We solve this by swapping in a modal private state thread just to handle
the events from the expression evaluation. That worked until you could
cause the expression evaluation to happen from Python, because then it
wasn't just the fetching of events that matter, but also the state of
the process and the state of the runlocks. The modal private state
thread is really a modal version of the thread and its associated state.

This patch gathers all the relevant control parameters into a structure
which we can swap in and out when needed.

It also adds a test using the new "was_hit" breakpoint resolver
affordance, which, since it acts as an asynchronous breakpoint callback,
gets run on the private state thread, showing that with the change we
can call expressions in the `was_hit` callback without problems.
2026-02-05 15:03:52 -08:00
Adrian Vogelsgesang
943782be5a
[lldb] Broadcast eBroadcastBitStackChanged when frame providers change (#171482)
We want to reload the call stack whenever the frame providers are
updated. To do so, we now emit a `eBroadcastBitStackChanged` on all
threads whenever any changes to the frame providers take place.

I found this very useful while iterating on a frame provider in
lldb-dap. So far, the new frame provider only took effect after
continuing execution. Now the backtrace in VS-Code gets refreshed
immediately upon running `target frame-provider add`.
2026-02-05 21:00:23 +01:00
Med Ismail Bennani
c373d7632a
[lldb] Fix variable access in old SBFrames after inferior function calls (#178823)
When a user holds an SBFrame reference and then triggers an inferior
function
call (via expression evaluation or GetExtendedBacktraceThread),
variables in
that frame become inaccessible with "register fp is not available"
errors.

This happens because inferior function calls execute through
ThreadPlanCallFunction, which calls ClearStackFrames() during cleanup to
invalidate the unwinder state. ExecutionContextRef objects in the old
SBFrames
were tracking StackFrameLists via weak_ptr, which became stale when
ClearStackFrames() created new instances.

The fix uses stable StackFrameList identifiers that persist across
ClearStackFrames():
- ID = 0: Normal unwinder frames (constant across all instances)
- ID = sequential counter: Scripted frame provider instances

ExecutionContextRef now stores the frame list ID instead of a weak_ptr,
allowing
it to resolve to the current StackFrameList with fresh unwinder state
after an
inferior function call completes.

The Thread object preserves the provider chain configuration
(m_provider_chain_ids and m_next_provider_id) across ClearStackFrames()
so
that recreated StackFrameLists get the same IDs. When providers need to
be
recreated, GetStackFrameList() rebuilds them from the persisted
configuration.

This commit also fixes a deadlock when Python scripted frame providers
call
back into LLDB during frame fetching. The m_list_mutex is now released
before
calling GetFrameAtIndex() on the Python scripted frame provider to
prevent
same-thread deadlock. A dedicated m_unwinder_frames_sp member ensures
GetFrameListByIdentifier(0) always returns the current unwinder frames,
and
proper cleanup in DestroyThread() and ClearStackFrames() to prevent
modules
from lingering after a Thread (and its StackFrameLists) gets destroyed.

Added test validates that variables remain accessible after
GetExtendedBacktraceThread triggers an inferior function call to fetch
libdispatch Queue Info.

rdar://167027676

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2026-02-03 03:12:35 +00:00
Ebuka Ezike
8370304f1e
[lldb] Fix SBBreakpointName::SetEnabled to propagate changes to breakpoints (#178734)
When setting the enabled state of a breakpoint name via the API, the
change was not being propagated to breakpoints using that name.
This was inconsistent with the CLI behaviour where `breakpoint name
configure --enable/--disable` correctly updates all associated
breakpoints.
2026-01-30 10:20:46 +00:00
Aman LaChapelle
10f2611c21
[lldb] Add support for ScriptedFrame to provide values/variables. (#178575)
This patch adds plumbing to support the implementations of StackFrame::Get{*}Variable{*} on ScriptedFrame. The major pieces required are:
- A modification to ScriptedFrameInterface, so that we can actually call the python methods.
- A corresponding update to the python implementation to call the python methods.
- An implementation in ScriptedFrame that can get the variable list on construction inside ScriptedFrame::Create, and pass that list into the ScriptedFrame so it can get those values on request.

There is a major caveat, which is that if the values from the python side don't have variables attached, right now, they won't be passed into the scripted frame to be stored in the variable list. Future discussions around adding support for 'extended variables' when printing frame variables may create a reason to change the VariableListSP into a ValueObjectListSP, and generate the VariableListSP on the fly, but that should be addressed at a later time.

This patch also adds tests to the frame provider test suite to prove these changes all plumb together correctly.

Related radar: rdar://165708771
2026-01-29 21:24:17 -08:00
n2h9
a617b901cd
[lldb] [disassembler] chore: add GetVariableAnnotations to SBInstruction api (#177676)
## Description
Contribution to this topic [Rich Disassembler for
LLDB](https://discourse.llvm.org/t/rich-disassembler-for-lldb/76952),
this part.
```
The rich disassembler output should be exposed as structured data and made available through LLDB’s scripting API so more tooling could be built on top of this
```

----

This pr replaces #174847

As was suggested in [this
comment](https://github.com/llvm/llvm-project/pull/174847#issuecomment-3757015552),
implement access to variable annotations from `SBInstruction` class
itself.

Notes:
-   did run black formatter on the python file;

## Testing
Run test with
```sh
./build/bin/lldb-dotest -v -p TestVariableAnnotationsDisassembler.py lldb/test/API/functionalities/disassembler-variables
```

all tests (9 existing + 1 newly added) are passing

<details>
<summary>screenshot 2026-01-23</summary>

build from the latest commit  08f00730b5768a8e3f7039d810084fabaaa24470

<img width="1506" height="562" alt="image"
src="https://github.com/user-attachments/assets/69516353-3432-47df-ae45-c40b51ec14c4"
/>

</details>

<details>
<summary>screenshot 2026-01-29</summary>

build from the latest commit  f48a1a2c10f96a457ca6844be2ccc9406d3d57a0

<img width="1232" height="740" alt="image"
src="https://github.com/user-attachments/assets/9d104ce6-36c3-430b-98fe-f028f83a6b6d"
/>


</details>

---------

Signed-off-by: Nikita B <n2h9z4@gmail.com>
2026-01-29 20:54:42 +01:00
Jacob Lalonde
c92e24b7d3
[LLDB][Statistics] Add coreFile to Target stats (#161448)
This patch adds the coreFilePath, if applicable, to the target
statistics for LLDB. My primary motivation here is sanity check user
reports when they say I had an issue with a specific corefile and then
validating it was in fact that specifies corefile, as right now there is
no guaruntee the filename and the process/target name will be the same.
2026-01-29 11:26:02 -08:00
Ebuka Ezike
1dd9e20046
[lldb] Fix UbSan decorator (#177964)
the ubsan decorator previously assumes the platform is macOS.

macOS has an extra underscore in symbols names match two or more.
uses the llvm-nm that is built instead of the system's nm.
2026-01-29 11:29:01 +00:00
Greg Clayton
5968e29dad
[lldb] Add the ability to load ELF core file executables and shared libraries from memory (#177289)
This patch enables ELF core files to be loaded and still show
executables and shared libraries. Functionality includes:
- Load executable and shared libraries from memory if ELF headers are
available
- Create placeholder for missing shared libraries and executable.
Previously you just wouldn't get anything in the "image list" if no
executable was provided.
2026-01-28 17:49:04 -08:00
Sergei Druzhkov
8092c997bc
[lldb] Add MSVC STL std::*_ordering summary providers (#175070)
Added summary providers for std::*_ordering from MSVC STL
2026-01-26 22:42:13 +03:00
Charles Zablit
4d460d6578
[lldb][windows] fix ProcessSaveCoreTestCase.test_save_core_to_nonwritable_dir (#178016)
This patch fixes the
`ProcessSaveCoreTestCase.test_save_core_to_nonwritable_dir` test on
Windows.

This test fails on Windows because `os.chmod` does not work on Windows.
It was used to make the directory unwritable.

[`icacls`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/icacls)
can be used instead to block the directory.

This is a followup to https://github.com/llvm/llvm-project/pull/177496.
2026-01-26 20:19:45 +01:00
Sergei Druzhkov
e4dc7034f8
[lldb] Add libcxx std::*_ordering summary providers (#174227)
Added libcxx std::*_ordering summary providers similar to #174195.
2026-01-26 21:20:47 +03:00
David Spickett
e9ac1a3190
[lldb] Improve error and docs for repeating "memory region" (#177559)
"memory region" can be given an address once and then when repeated,
it will try to find a region just beyond the last one it printed.
This continues until the end of the address space.

Then it gives you an error showing the usage, which is odd because
you just saw a bunch of "memory region" with no options work.

So I've improved the error a bit to imply its to do with the repetition.
Then described the repeating behaviour in the help text.
2026-01-26 15:39:39 +00:00
Augusto Noronha
7954b47910 Revert "[lldb] Fix setting CanJIT if memory cannot be allocated (#176099)"
This reverts commit b5d8fc553d8e03f4d325458d29ac2c9e46a464e3.
2026-01-23 16:44:11 -08:00
Igor Kudrin
b5d8fc553d
[lldb] Fix setting CanJIT if memory cannot be allocated (#176099)
When a server is unable to allocate memory for the `_M` packet, it may
respond with an error code. In this case,
`GDBRemoteCommunicationClient::AllocateMemory()` sets
`m_supports_alloc_dealloc_memory` to `eLazyBoolYes`; `eLazyBoolNo` is
only used if the server cannot handle the packet at all. Before this
patch, `ProcessGDBRemote::DoAllocateMemory()` checked this flag and
returned `LLDB_INVALID_ADDRESS` without setting an error, which caused
`Process::CanJIT()` to set `m_can_jit = eCanJITYes`, resulting in
`IRMemoryMap::FindSpace()` attempting to allocate memory in the inferior
process and failing. With the patch,
`ProcessGDBRemote::DoAllocateMemory()` returns an error and `m_can_jit`
is set to `eCanJITNo`.

Example debug session:
```
(lldb) platform connect...
(lldb) file test
(lldb) br set...
(lldb) run
Process 100 launched:...
Process 100 stopped
* thread #1,...
(lldb) expr $x0
error: Couldn't allocate space for materialized struct: Couldn't malloc: address space is full
error: errored out in virtual lldb_private::LLVMUserExpression::DoExecute, couldn't PrepareToExecuteJITExpression
```
2026-01-23 14:18:05 -08:00
Leandro Lupori
cd70e2d836
[lldb] Fix test_chained_frame_providers on 32-bit Arm (#177668)
PC addresses must always be 16-bit aligned on 32-bit Arm CPUs.

Fixes #177666
2026-01-23 18:04:57 -03:00
Jonas Devlieghere
859052a34e
[lldb] Improve error message when we can't save core (#177496)
When you specify a filename to `process save core`, we'll write it in
the current working directory. In Xcode the CWD is `/` and you can't
generally write there.

```
(lldb) process save-core --style full foo
error: failed to save core file for process: Read-only file system
```

This PR improves the error message by including the output file when we
can't save core. However, just printing the filename isn't that much
more helpful, because FileSystem::Resolve only makes a path absolute if
it exists.

```
error: failed to save core file for process to 'foo': Read-only file system
```

Therefore I also modified the interface to add a flag to force resolve a
potentially non-exist path.

```
error: failed to save core file for process to '/foo': Read-only file system
```
2026-01-22 22:32:03 -08:00
Michael Buch
ec28be3cca [lldb][test] TestDataFormatterLibcxxOptionalSimulator.py: skip on older Clang versions 2026-01-22 13:25:24 +00:00
Michael Buch
59db71c7bd [lldb][test] Re-enable and fix TestUbsanBasic.py
UBSAN stopped reporting the misaligned load since 5569bf26f0 so this test started failing. We skipped it to unblock CI.

There's been discussion on making UBSAN stricter and still trigger on
the one-line version of this. But for now, to get the test running
again, change it to a form which *does* trigger UBSAN.

Fixes https://github.com/llvm/llvm-project/issues/177064
2026-01-22 09:28:47 +00:00
Augusto Noronha
c3c22c945a
[lldb] Skip TestUbsanBasic (#177263)
The fix for this is being discussed in
https://github.com/llvm/llvm-project/issues/177064. Skip the test for
now to get the bots green.
2026-01-21 15:27:10 -08:00
Ebuka Ezike
a97ee96383
[lldb] Check multiword command in UserCommandExists (#176998)
User created multiword command is not reported when querying
`SBCommandInterpreter::UserCommandExists`
2026-01-21 12:28:22 +00:00
Med Ismail Bennani
17b01bbc67
[lldb] Enable chaining multiple scripted frame providers per thread (#172849)
This patch allows threads to have multiple SyntheticFrameProviderSP
instances that chain together sequentially. Each provider receives the
output of the previous provider as input, creating a transformation
pipeline.

It changes `Thread::m_frame_provider_sp` to a vector, adds provider
parameter to SyntheticStackFrameList to avoid calling back into
`Thread::GetFrameProvider()` during frame fetching, updated
`LoadScriptedFrameProvider()` to chain providers by wrapping each
previous provider's output in a `SyntheticStackFrameList` for the next
provider and finally, loads ALL matching providers in priority order
instead of just the first one.

The chaining works as follows:
```
  Real Unwinder Frames
      ↓
  Provider 1 (priority 10) → adds/transforms frames
      ↓
  Provider 2 (priority 20) → transforms Provider 1's output
      ↓
  Provider 3 (priority 30) → transforms Provider 2's output
      ↓
  Final frame list shown to user
  ```

This patch also adds a test for this (test_chained_frame_providers) to verify that 3 providers chain correctly: `AddFooFrameProvider`, `AddBarFrameProvider`, `AddBazFrameProvider`.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2026-01-17 04:10:48 +00:00
Nerixyz
c061ddbd15
Reland [LLDB] Fix MS STL variant with non-trivial types and PDB (#176189)
Relands #171489 which was reverted due to a test failure on GreenDragon.

As suggested in
https://github.com/llvm/llvm-project/pull/171489#issuecomment-3754098800,
I'm checking for `std::string` on Darwin and `std::basic_string<char>`
otherwise, however I can't test that locally.
2026-01-15 23:13:04 +01:00
Jonas Devlieghere
a0b71b048b
Revert "[LLDB] Fix MS STL variant with non-trivial types" (#176059)
Reverts llvm/llvm-project#171489 because it causes
`TestDataFormatterStdVariant.py` to fail on Darwin.

Affected bots:

- https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/as-lldb-cmake/
- https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/lldb-cmake/
2026-01-14 23:29:33 +00:00
willmafh
c705003e8c
[NFC] Exactly one kind typo fixes, change defintions to definitions. (#174333) 2026-01-14 08:12:26 +00:00
Nerixyz
9a632fd684
[LLDB] Fix MS STL variant with non-trivial types (#171489)
When using `std::variant` with non-trivial types, we need to go through
multiple bases to find the `_Which` member. The MSVC STL implements this
in `xsmf_control.h` which conditionally adds/deletes copy/move
constructors/operators.

We now go to `_Variant_base` (the holder of `_Which`). This inherits
from `_Variant_storage`, which is our entry point to finding the n-th
storage (going through `_Tail`).
2026-01-12 11:40:12 +01:00
Jonas Devlieghere
5c3f02cbb3
[lldb] Honor the process plugin name in the attach/launch info (#175195)
When connected to a GDB remote platform, we always use "gdb-remote" as
the process plugin when attaching. This means that the `--plugin`
argument to `process attach` is effectively ignored. This patch makes it
so that "gdb-remote" remains the default, while still honoring the
process plugin name specified in the attach info. The same thing applies
to launching a process.

rdar://167845923
2026-01-09 12:52:58 -06:00
Sergei Druzhkov
8ab6b38dab
[lldb] Add std::*_ordering summary providers (#174195)
I want to propose adding summary providers for `std::*_ordering` types
introduced in `C++20`. GDB already has pretty-printers for
[them](https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/python/libstdcxx/v6/printers.py#L1788),
so I think it will be useful.
2026-01-08 21:13:23 +03:00
Nerixyz
255f173139
[LLDB] Run MSVC STL deque tests with PDB (#172360)
Similar to the other PRs, this looks up the type from a member variable.
Here, we can use the type of `_Mapptr`. On its own, that's enough to
pass the test with clang-cl.
2026-01-08 17:19:54 +01:00
Nerixyz
c7c5259f01
[LLDB] Add MSVC STL span formatter (#173053)
`std::span` didn't have a formatter for MSVC's STL yet. The type is
quite useful in C++ 20, so this PR adds a formatter for it.

Since the formatter is new, I made it work with both DWARF and PDB from
the start.
2026-01-07 15:31:27 +01:00
Sergei Druzhkov
9937769cca
[lldb] Add libstdcpp string view summary provider (#171854)
This patch adds libstdcpp string view summary provider.
2026-01-06 22:16:43 +03:00
Michael Buch
dca088023e
[lldb][Format] Unwrap references to C-strings when printing C-string summaries (#174398)
Depends on:
* https://github.com/llvm/llvm-project/pull/174385

(only last commit is relevant for this review)

The `${var%s}` format isn't capable of formatting references to
C-strings. So the summary for those becomes `<no value available>`. This
patch prevents the system C-string formatter from applying to
references, which means the summary for such types will be empty. This
prompts LLDB to instead print the child, which is the referenced
C-string.

Before:
```
(lldb) v ref
(const char *&) ref = 0x000000016fdfe960 <no value available>
```

After:
```
(lldb) v ref
(const char *&) ref = 0x000000016fdfec40 (&ref = "hi")
```

An alternative would be to support references in the `ValueObject` dump
methods. We assume C-string are pointers/arrays in a lot of places, so
such a fix would be a more intrusive undertaking, and I'm not sure we
would want to support references there in the first place. So for now I
went with the fallback logic in this PR.
2026-01-06 08:41:10 +00:00
Michael Buch
e982b4f411 [lldb][test] Add tests for printing references to C-strings
Printing references to C-strings doesn't work properly at the moment. This patch provides coverage for those cases and should fail once the underlying issue gets fixed (see https://github.com/llvm/llvm-project/pull/174398).
2026-01-05 15:08:23 +00:00
Michael Buch
3c32360c83
[lldb][test] Rewrite TestStringPrinter.py in a non-inline API test style (#174385)
Motivation here is that I'm planning to add more test cases to this and
it's easier to read/maintain as an API test.

Drive-by:
* I also removed the `std::string` checks since those belong in the STL
formatter tests.
2026-01-05 13:43:59 +00:00
nerix
50001bb4de
[LLDB] Run MSVC STL unordered tests with PDB (#172731)
The unordered containers re-use the formatters for `std::list` which
were fixed for PDB with #166953.

This should be the last fix for PDB in MSVC STL tests. Unfortunately,
the type names here are very long, because the types of keys/values are
repeated in the template (for hash/eq/allocator).
2025-12-19 15:09:19 +01:00
Med Ismail Bennani
7a3eddc19f [lldb/test] Fix failure caused by leading zero in TestScriptedFrameProvider.py
This should fix a test failure in TestScriptedFrameProvider.py:

https://lab.llvm.org/buildbot/#/builders/18/builds/23398/steps/6/logs/stdio

This is a happening because on 32bit system, addresses don't have the
leading zeroes. This patch removes them to satisfy the checks.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-18 23:28:29 +01:00
Med Ismail Bennani
6767b86c34
[lldb] Fix frame-format string missing space when module is invalid (#172767)
This patch is a follow-up to 96c733e to fix a missing space in the
frame.pc format entity. This space was intended to be prepended to the
module format entity scope but if the module is not valid, which is
often the case for python pc-less scripted frames, the space between the
pc and the function name is missing.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-18 13:38:58 +01:00
nerix
d1e98939c8
[LLDB] Run MSVC STL vector tests with PDB (#172726) 2025-12-18 13:18:53 +01:00
Dave Lee
6cd651ae21
Revert "Make result variables obey their dynamic values in subsequent expressions (#168611)" (#172780)
[Green Dragon's lldb incremental tests
(x86_64)](https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/)
are failing beginning with
https://github.com/llvm/llvm-project/pull/168611. This commit reverts
that change. If the job continues to fail after committing this revert,
then I will recommit the original.

rdar://166741668

This reverts commit 6344e3aa8106dfdfb30cac36c8ca02bc4c52ce24.
2025-12-17 19:39:25 -08:00
nerix
eaf6d9a2ff
[LLDB] Run MSVC STL atomic tests with PDB (#172349)
Because PDB doesn't know about templates, we need to get to `T` of
`std::atomic<T>` differently. The type includes the `value_type`
typedef, which is always equal to `T`. The native PDB plugin includes
this since #169248.

Then we can run the `std::atomic` test with (native) PDB.
2025-12-16 18:26:27 +01:00
David Spickett
f5a198b8aa
[lldb][test] Xfail 3 backtrace related tests on Windows on Arm (#172300)
Since we updated our buildbot setup, these have been failing. Ignore
them until we have time to find the real problem, which is something to
do with failing to backtrace, or missing debug info when we do.
2025-12-15 14:04:02 +00:00
Raul Tambre
423919d31f
[NFCI][lldb][test][asm] Enable AT&T syntax explicitly (#166770)
Implementation files using the Intel syntax typically explicitly specify it.
Do the same for the few files using AT&T syntax.

This enables building LLVM with `-mllvm -x86-asm-syntax=intel` in one's Clang config files
(i.e. a global preference for Intel syntax).
2025-12-14 23:54:25 +02:00
Med Ismail Bennani
7927597860 Revert "[lldb/test] Enable debug info for TestFrameProviderCircularDependency.py"
This reverts commit 13b4eb9452d37106b1143723e658010a9b58d344 since it
doesn't fix the test failure.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-13 00:29:01 +01:00
Med Ismail Bennani
13b4eb9452 [lldb/test] Enable debug info for TestFrameProviderCircularDependency.py
This is necessary to get the function name in the test, following
20a6c59d8311d92bd8553b22b82a3874e0016edb.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-12 23:39:02 +01:00
Med Ismail Bennani
53972216d1
[lldb] Add arm32/thumb register layout to Scripted{Frame,Thread} (#172005) 2025-12-12 20:06:08 +01:00
jimingham
2f14fb3dde
The C++ dynamic typing tests are failing on Windows, skip for now. (#171922)
This is a follow-on to:

https://github.com/llvm/llvm-project/pull/168611

which added a bunch of tests for detecting dynamic types of C++ result
variables. I don't actually know how well dynamic type detection works
on Windows if at all. It would require Windows support, since the
Linux/Darwin version is specific to the Itanium ABI.
2025-12-11 15:14:01 -08:00
jimingham
6344e3aa81
Make result variables obey their dynamic values in subsequent expressions (#168611)
When you run an expression and the result has a dynamic type that is
different from the expression's static result type, we print the result
variable using the dynamic type, but at present when you use the result
variable in an expression later on, we only give you access to the
static type. For instance:

```
(lldb) expr MakeADerivedReportABase()
(Derived *) $0 = 0x00000001007e93e0
(lldb) expr $0->method_from_derived()
                ^
                error: no member named 'method_from_derived' in 'Base'
(lldb) 

```

The static return type of that function is `Base *`, but we printed that
the result was a `Derived *` and then only used the `Base *` part of it
in subsequent expressions. That's not very helpful, and forces you to
guess and then cast the result types to their dynamic type in order to
be able to access the full type you were returned, which is
inconvenient.

This patch makes lldb retain the dynamic type of the result variable
(and ditto for persistent result variables).

It also adds more testing of expression result variables with various
types of dynamic values, to ensure we can access both the ivars and
methods of the type we print the result as.
2025-12-11 14:28:17 -08:00