33529 Commits

Author SHA1 Message Date
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
d6a73d08d5
[lldb] Add priority support to synthetic frame providers (#172848)
This patch adds `get_priority()` support to synthetic frame providers to
enable priority-based selection when multiple providers match a thread.
This is the first step toward supporting frame provider chaining for
visualizing coroutines, Swift async tasks, and et al.

Priority ordering follows Unix nice convention where lower numbers
indicate higher priority (0 = highest). Providers without explicit
priority return `std::nullopt`, which maps to UINT32_MAX (lowest
priority), ensuring backward compatibility with existing providers.

The implementation adds `GetPriority()` as a virtual method to
`SyntheticFrameProvider` base class, implements it through the scripting
interface hierarchy (`ScriptedFrameProviderInterface` and
`ScriptedFrameProviderPythonInterface`), and updates
`Thread::GetStackFrameList()` to sort applicable providers by priority
before attempting to load them.

Python frame providers can now specify priority:

```python
@staticmethod
def get_priority():
   return 10  # Or return None for default priority.
```

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-18 23:20:38 +01:00
Dave Lee
56db2416ff
[lldb-dap] Add missing tablegen dependency to lldb-dap (#172891)
rdar://165929985
2025-12-18 13:39:12 -08:00
Charles Zablit
6b9a1f38fe
[lldb-dap][windows] deactivate TestDAP_attach.test_by_name_waitFor on Windows (#172880)
Attaching by name on Windows is not implemented yet.
2025-12-18 20:01:27 +00:00
Charles Zablit
78d291eda0
[lldb][windows] only use a ConPTY if needed (#172877)
This patch fixes a regression caused by
https://github.com/llvm/llvm-project/pull/168729.

The changes ensure that we only create the process with a ConPTY if we
need to.
2025-12-18 18:09:20 +00:00
Ebuka Ezike
b34dd38784
[lldb-dap] Do not show memory address on types with no summary (#172670)
Majority of the time users are less interested on the memory address of
a type. It is mostly useful for pointer types (the memory address is
shown).
It makes the view more bloated without adding useful information.

can always fall back to the debug console or watch pane to view the
information if necessary.
2025-12-18 18:08:16 +00:00
Charles Zablit
2ec3ea7e93
[lldb][windows] refactor the version check in @skipIfWindows (#172838)
This patch refactors the way we check for the windows version in the
`@skipIfWindows` decorator.

The new logic reuses the `expectedCompilerVersion` method logic for the
parsing and comparison of the version.
2025-12-18 17:07:36 +00: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
Stefan Gränitz
8fe1dddce6
[lldb] Restrict JITLoaderGDB test to native Linux environments (#172292)
This test used to work on non-Linux platforms that could run simple ELF
objects in a JIT session. However, there is a risk that this will become
too unstable for CI, so let's limit it to what we actually need.
2025-12-18 13:38:49 +01:00
nerix
d1e98939c8
[LLDB] Run MSVC STL vector tests with PDB (#172726) 2025-12-18 13:18:53 +01:00
Ilia Kuklin
f4e941b209
[lldb] Use AST nodes as Subscript and BitExtraction arguments in DIL (#169363)
Use AST nodes as Subscript and BitExtraction arguments instead of bare
integers. This enables using any supported expression as an array or bit
index.
2025-12-18 16:04:31 +05:00
Charles Zablit
7fe5953a44
[lldb][windows] add Windows Virtual Console support (#168729) 2025-12-18 10:29:38 +00:00
Jonas Devlieghere
f34900b7dd
[lldb-dap] Bump the version to 0.4.1 2025-12-17 20:06:55 -08: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
Med Ismail Bennani
f8377f59fb
[lldb/test] Fix libcxx configuration handling for remote platforms (#172761)
When using --platform remote-* options, explicitly clear the libcxx
configuration variables instead of just warning and continuing with
potentially set values. This prevents the test suite from attempting to
use custom libcxx paths on remote platforms where they're not
applicable.

Also initialize libcxx variables to None when not specified, ensuring a
clean state regardless of how the arguments are parsed.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-18 00:57:29 +01:00
Dave Lee
26c9598c10
[lldb] Fix TestIvarProtocols to use +new instead of +alloc (NFC) (#172740)
A test failure on green dragon shows the ivars with unexpected values.
This makes the test us an explicit `+new` instead of `+alloc` (which is
missing an `-init` call).
2025-12-17 13:48:52 -08:00
Augusto Noronha
208553460a
[lldb] Prefer exact address match when looking up symbol by address (#172055)
The current behavior will pick the first symbol that contains the
address, this causes LLDB to pick the wrong symbol when looking for
swift reflection metadata on Linux, as in that case it is valid for a
symbol to completely encompass another one.

Instead, this function should prefer the symbol which is an exact, if it
exists. As a bonus, this should also be faster in the vast majority of
the cases, as we probably query symbols by their exact address most of
the time.

rdar://166344740
2025-12-17 10:51:14 -08:00
Alex Langford
32feb01dc3
[lldb][NFCI] Remove unused field in BreakpointResolverName (#172574) 2025-12-17 08:56:07 -08:00
Michael Buch
e4c4498798
[lldb][ObjC][NFCI] Replace StringLexer with llvm::StringRef (#172466)
We had a dedicated `StringLexer` class that pretty much just replicates
the `llvm::StringRef` interface. This patch removes the `StringLexer` in
favour of just using `llvm::StringRef`. Much of the string parsing can
be cleaned up, but I tried to keep the changes a small as possible so
just kept the logic and replaced the APIs calls. The only awkward
side-effect of this is that we have to pass a `llvm::StringRef &`
around.

There were some gaps in the API, so added two helper methods to
consume/pop off characters from the front of the StringRef (maybe those
can be added to `llvm::StringRef` in the future).

The `StringLexer` also had a roll-back mechanism used in two places.
That can be handled by just saving a copy of the `StringRef`.
2025-12-17 12:58:26 +00:00
David Spickett
c563a73cd3 [lldb][docs] Fix formatting in troubleshooting guide
Fixes #171806
2025-12-17 09:13:52 +00:00
David Spickett
31e757d3a1
[lldb][docs] Add register info problems to troubleshooting doc (#171806)
This new section talks about the ways we try to get register
information, how to find out what LLDB decides to do and how to remedy
that choice if needed.

All the methods have their place, so I've tried to present this in the
order we try them. Roughly speaking, each is less accurate than the
previous one. Most people will want to ensure that they're using the XML
from the debug server.

Target definition scripts are the least documented but also most
advanced topic. I have included them because they are the first thing
LLDB checks, but only briefly, as 99.9% of users won't be using one and
should not bother to write one.
2025-12-17 09:01:39 +00:00
n2h9
99553bcdef
[lldb] [docs] [sbapi]: fix lldb-forward header name (#172578)
This pr fixes the header file name from `lldb_forward.h` to
`lldb-forward.h` in `sbapi.rst`.

Here is the header file in question:
[lldb-forward.h](https://github.com/llvm/llvm-project/blob/main/lldb/include/lldb/lldb-forward.h).

Signed-off-by: Nikita B <n2h9z4@gmail.com>
2025-12-16 21:09:07 -08:00
Michael Buch
b2880eac7c
[lldb][ClangASTSource][NFC] Clean up RegisterNamespaceMap (#172520)
I've been trying to wrap my head around this code but there's a lot of
action-at-a-distance going on which I'm having trouble following. This
patch cleans up a small part of it.

We were passing the `context`s namespace map as a separate mutable
argument. But nothing in this function requires it to be mutable (and
separate from the owning structure). This patch drops the redundant
argument and passes the shared_ptr by value.
2025-12-16 18:05:49 +00: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
Sergei Druzhkov
cc13d46d8f
[lldb-dap] Fix Windows build (#172475)
Fix after #172283
2025-12-16 16:11:01 +03:00
Sergei Druzhkov
35a22719f5
[lldb-dap] Migrate additional requests to stuctured types (#172283)
These patches update `compileUnits` and `testGetTargetBreakpoints`
requests, which are not a part of DAP. I combine two commits into one MR
to save maintainers time and because it is mostly NFC.
2025-12-16 15:03:49 +03:00
Alex Langford
34f6303293
[lldb][NFCI] Make LookupInfo const (#171901)
Instead of changing an existing LookupInfo after creation, let's make
them constant.
2025-12-15 10:51:48 -08:00
Charles Zablit
4ab36d8674
[NFC][lldb] fix PseudoTerminal documentation (#172318)
This NFC patch improves removes documentation references to methods that
have been removed in the PseudoTerminal class and adds some `\see`
references.
2025-12-15 18:12:06 +00:00
Charles Zablit
60d447d0d1
[lldb][windows] fix a race condition when polling Pipes (#172063)
This patch fixes a deadlock due to a race condition inside the
`PipeEvent` class.

The lldp-dap tests on Windows are very prone to this deadlock (from my
testing almost 1/2 times `TestDAP_Launch.py` fails because of a deadlock
inside `PipeEvent`.

Before this patch, the destructor could try to set `m_ready` right
before `PipeEvent::Monitor` would reset it, causing
`WaitForSingleObject(m_ready, INFINITE);` to deadlock.

This is fixed by ensuring all the `SetEvent` and `ResetEvent` calls
inside the class are behind a mutex.

Furthermore, `CancelIoEx` now passes the same `LPOVERLAPPED` reference
as the one used by the blocking calls in `Monitor`. This ensure we only
cancel the IO tasks which were created by `PipeEvent::Monitor`.
2025-12-15 18:04:29 +00:00
Felipe de Azevedo Piovezan
566eb2b78f
[lldb] Respect max packet size limits for MultiMemRead in ProcessGDBRemote (#172022)
(ignore the first commit, it is the dependency of this PR)

Servers advertise what their maximum packet size is, MultiMemRead needs
to respect that.

Depends on:
*  https://github.com/llvm/llvm-project/pull/172020
2025-12-15 17:49:29 +00: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
Michael Buch
90783f5c4a
[lldb][AppleObjCDeclVendor] Fix format specifiers when printing log (#172263)
This was causing a crash when enabling the expression log:
```
4   LLDB                          	       0x1376d68d0 llvm::formatv_object_base::parseFormatString(llvm::StringRef, unsigned long, bool) + 532
5   LLDB                          	       0x13776d838 llvm::formatv_object_base::format(llvm::raw_ostream&) const + 84
6   LLDB                          	       0x13776d7d4 llvm::raw_ostream::operator<<(llvm::formatv_object_base const&) + 36
7   LLDB                          	       0x1375f4980 lldb_private::Log::Format(llvm::StringRef, llvm::StringRef, llvm::formatv_object_base const&) + 164
8   LLDB                          	       0x12f7b39f0 lldb_private::AppleObjCExternalASTSource::CompleteType(clang::TagDecl*) + 416
9   LLDB                          	       0x12fa038dc lldb_private::ClangASTSource::FindExternalLexicalDecls(clang::DeclContext const*, llvm::function_ref<bool (clang::Decl::Kind)>, llvm::SmallVectorImpl<clang::Decl*>&) + 1132
10  LLDB                          	       0x135d94838 clang::ExternalASTSource::FindExternalLexicalDecls(clang::DeclContext const*, llvm::SmallVectorImpl<clang::Decl*>&) + 92
11  LLDB                          	       0x135d94690 clang::DeclContext::LoadLexicalDeclsFromExternalStorage() const + 204
12  LLDB                          	       0x135d95ca0 clang::DeclContext::buildLookup() + 308
13  LLDB                          	       0x135d964b8 clang::DeclContext::lookupImpl(clang::DeclarationName, clang::DeclContext const*) const + 824
14  LLDB                          	       0x135d96168 clang::DeclContext::lookup(clang::DeclarationName) const + 124
15  LLDB                          	       0x134f093d4 clang::Sema::CheckImplicitSpecialMemberDeclaration(clang::Scope*, clang::FunctionDecl*) + 128
16  LLDB                          	       0x134efb488 clang::Sema::DeclareImplicitDestructor(clang::CXXRecordDecl*) + 932
17  LLDB                          	       0x1352ddf24 clang::Sema::LookupSpecialMember(clang::CXXRecordDecl*, clang::CXXSpecialMemberKind, bool, bool, bool, bool, bool)::$_0::operator()() const + 36
```
2025-12-15 09:28:19 +00:00
Raul Tambre
14c69497b3
Partially revert "[NFCI][lldb][test][asm] Enable AT&T syntax explicitly (#166770)" (#172233)
Flag changes reverted as those require the X86 target to be enabled.  
Don't have time to test fixes as I need to go to sleep so will revert for now.

Reverts: 423919d31f4b55f22b09cd5066534f7c91e71d4b
2025-12-15 00:26:54 +02: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
Sergei Druzhkov
e82edd28f6
[lldb-dap] Migrate locations request to structured types (#171099)
This patch migrates `locations` request into structured types and adds
test for it.
2025-12-14 18:37:24 +03:00
nerix
9de41eef6e
[LLDB][NativePDB] Create typedefs in structs (#169248)
Typedef/using declarations in structs and classes were not created with
the native PDB plugin. The following would only create `Foo` and
`Foo::Bar`:
```cpp
struct Foo {
    struct Bar {};
    using Baz = Bar;
    using Int = int;
};
```

With this PR, they're created. One complication is that typedefs and
nested types show up identical. The example from above gives:
```
  0x1006 | LF_FIELDLIST [size = 40, hash = 0x2E844]
           - LF_NESTTYPE [name = `Bar`, parent = 0x1002]
           - LF_NESTTYPE [name = `Baz`, parent = 0x1002]
           - LF_NESTTYPE [name = `Int`, parent = 0x0074 (int)]
```

To distinguish nested types and typedefs, we check if the parent of a
type is equal to the current one (`parent(0x1002) == 0x1006`) and if the
basename matches the nested type name.
2025-12-14 15:42:57 +01:00
Jonas Devlieghere
61db1ff8c5
[lldb] Add unit tests for NonNullSharedPtr (#172173)
I was investigating a crash yesterday that implicated NonNullSharedPtr
which made me realize I didn't add unit tests for my new class.
2025-12-13 20:10:23 +00:00
Jonas Devlieghere
9878bac3a8
Revert "[lldb] Still echo the command if we print the error." (#172110)
Reverts llvm/llvm-project#171931 because the test is failing on Windows.
2025-12-12 23:53:22 +00: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
Jonas Devlieghere
eb501b211a
[lldb] Still echo the command if we print the error. (#171931)
When the command interpreter is asked to not echo commands but still
print errors, a user has no idea what command caused the error.

For example, when I add `bogus` in my `~/.lldbinit`:

```
$ lldb
error: 'bogus' is not a valid command.
```

Things are even more confusing when we have inline diagnostics, which
point to nothing. For example, when I add `settings set target.run-args
-foo` to my `~/.lldbinit`:

```
❯ lldb
                                    ˄˜˜˜
                                    ╰─ error: unknown or ambiguous option
```

We should still echo the command if the command fails, making it obvious
which command caused the failure and fixing the inline diagnostics.

Fixes #171514
2025-12-12 15:04:56 -08: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
Michael Buch
26ff166637
[lldb][ClangExpressionParser] Emit more accurate language note for Objective-C++ fallback (#172047)
We fall back to `Objective-C++` when running C++ expressions in frames
that don't have debug-info. But we were missing a fallback note for this
situation. We would now print following note on expression error:
```
note: Possibly stopped inside system library, so speculatively enabled Objective-C. Ran expression as 'Objective C++'.
```
2025-12-12 17:42:58 +00:00
Charles Zablit
8515ddaa2b
[lldb] fix failing diagnostics test when Unicode is supported (#172038)
This patch fixes a test failure introduced by
https://github.com/llvm/llvm-project/pull/171832 due to a check which
was not properly updated.
2025-12-12 09:30:23 -08:00
Michael Buch
d7cbc7f9e4
[lldb][InstrumentationRuntime] Run sanitizer utility expressions as C (#172019)
The utility expressions in the `InstrumentationRuntime` plugins are just
plain C code, but we run them as `ObjC++`. That meant we were doing
redundant work (like looking up decls in the Objective-C runtime). The
sanitizer tests sporadically time out while looking up function symbols
in the Objective-C runtime. This patch switches the expression language
to `C`.

Didn't find a great way of testing this other than looking at the
expression log.

rdar://165656320
2025-12-12 16:08:13 +00:00
Felipe de Azevedo Piovezan
66f2b6625e
[lldb][nfc] Change ProcessGDBRemote::ParseMultiMemReadPacket signature (#172020)
Instead of returning an `Expected<vector<...>>` it now returns an Error,
and receives a vector argument to fill in. This will be useful to
support a change were ParseMultiMemReadPacket will be called multiple
times in a loop with the same vector; without this change, we would have
to concatenate vectors and copy memory around.
2025-12-12 16:07:09 +00:00
Charles Zablit
7345233fb6
[lldb] improve the heuristics for checking if a terminal supports Unicode (#171832)
This patch improves the way lldb checks if the terminal it's opened in
(if any) supports Unicode or not.

On POSIX systems, we check if `LANG` contains `UTF-8`.

On Windows, we always return `true` since we use the `WriteToConsoleW`
api.

This is a relanding of https://github.com/llvm/llvm-project/pull/168603.

The tests failed because the bots support Unicode but the tests expect
ASCII. To avoid different outputs depending on the environment the tests
are running in, this patch always force ASCII in the tests.
2025-12-12 15:07:08 +00:00
nerix
6f44be6f3e
[LLDB][NativePDB] Use original struct name when searching for constants (#166845)
We used to search for constants using the name we parsed. For C++, this
would mean using the demangled struct name (from the unique name). This
name is not always equal to the one used for the struct's name by the
compiler. For example:

```
  0x105E | LF_STRUCTURE [size = 120, hash = 0xF38F] ``anonymous namespace'::Anonymous<A::B::C<void> >::D`
           unique name: `.?AUD@?$Anonymous@U?$C@X@B@A@@@?A0x8C295248@@`
```
We would use the unique name and get to `(anonymous
namespace)::Anonymous<struct A::B::C<void>>::D`. Then, when finding the
constant in the field list, we'd search for `(anonymous
namespace)::Anonymous<struct A::B::C<void>>::D::StaticMember`. This
wouldn't yield any results, because the constant will use the demangled
name as given by the compiler.

With this PR, we use the struct's name as given in the PDB and append
the member name.
2025-12-12 15:33:38 +01:00
Felipe de Azevedo Piovezan
7d151cf170
[LLDB][NFC] Remove redundant target/process checks in SBFrame (#153258)
This is a follow up to https://github.com/llvm/llvm-project/pull/152020,
continuing the removal of now-redundant `if(process && target)` checks.
Since this causes a diff in every line of the affected functions, this
commit also uses the opportunity to create some helper functions and
reduce nesting of the affected methods by rewriting all pre-condition
checks as early returns, while remaining strictly NFC.

This has exposed some odd behaviors:

1. `SBFrame::GetVariables` has a variable `num_produced` which is
clearly meant to be incremented on every iteration of the loop but it is
only incremented once, after the loop. So its value is always 0 or
   1. The variable now lives in `FetchVariablesUnlessInterrupted`.
2. `SBFrame::GetVariables` has an interruption mechanism for local
variables, but not for "recognized arguments". It's unclear if this is
by design or not, but it is now evident that there is a discrepancy
there.
3. In `SBFrame::EvaluateExpression` we only log some error paths, but
not all of them.

To stick to the strictly NFC nature of this patch, it does not address
any of these issues.
2025-12-12 13:11:58 +00:00
Sergei Druzhkov
f0d7d833f5
[lldb-dap] Allow empty memory reference in disassemble arguments (#162517)
This patch implements a workaround for a VSCode bug that causes it to
send disassemble requests with empty memory reference. You can find more
detailed description
[here](https://github.com/microsoft/vscode/pull/270361). I propose to
allow empty memory reference and return invalid instructions when this
occurs.

Error log example:
```
1759923554.517830610 (stdio) --> {"command":"disassemble","arguments":{"memoryReference":"","offset":0,"instructionOffset":-50,"instructionCount":50,"resolveSymbols":true},"type":"request","seq":3}
1759923554.518007517 (stdio) queued (command=disassemble seq=3)
1759923554.518254757 (stdio) <-- {"body":{"error":{"format":"invalid arguments for request 'disassemble': malformed memory reference at arguments.memoryReference\n{\n  \"instructionCount\": 50,\n  \"instructionOffset\": -50,\n  \"memoryReference\": /* error: malformed memory reference */ \"\",\n  \"offset\": 0,\n  \"resolveSymbols\": true\n}","id":3,"showUser":true}},"command":"disassemble","request_seq":3,"seq":0,"success":false,"type":"response"}
```

I am not sure that we should add workaround here when bug on VSCode
side, but I think this bug affects our users. WDYT?
2025-12-12 12:33:07 +03:00