Commit Graph

3930 Commits

Author SHA1 Message Date
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 13b4eb9452 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
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
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
nerix
7fdf800a91 [LLDB] Run MSVC variant test with PDB (#171858)
Split off from #171489. This only adds the lookup of the active type for
a `std::variant` based on the head type (since PDB doesn't have template
info).
2025-12-11 18:03:42 +01:00
jimingham
6dafa096f4 Add a _regexp-break-add and some more tests for the b alias. (#171236)
This commit leaves "b" aliased to the old _regexp-break for now. The two
variants are identical except that `_regexp-break` allows you to say:

`(lldb) b <unrecognized_input> 
`
which gets translated to:

`break set <unrecognized_input>
`

So switching people to `_regexp-break-add` would be a surprising
behavior change. It would be wrong for `_regexp_break-add` have one
branch that call `break set`, so to avoid surprise, I'll add the command
and let people who are playing with `break add` instead of `break set`
can set the alias to the new one by hand for now.
2025-12-10 16:26:25 -08:00
Aiden Grossman
49324cd28c [lldb] Make TestJitBreakPoint.py use LLVM_TOOLS_DIR (#171656)
This seems the standard way to get the path to such tools within LLVM.
Calling findBuiltClang() has some annoying behavior like falling back to
CC when it cannot find anything else, which might point to anything or
not even be set.

We noticed this with our internal build system as the lli binary is not
in the same path as the clang binary.
2025-12-10 09:56:03 -08:00
Ebuka Ezike
923974987a [lldb-dap] enable run-in-terminal test on linux arm. (#171598)
follow up to
https://github.com/llvm/llvm-project/pull/144954#issuecomment-2990767363
2025-12-10 16:17:53 +00:00
Ebuka Ezike
36865a1bc7 [lldb-dap] enable TestDAP_module on linux (#171584)
The issue was fixed in https://github.com/llvm/llvm-project/pull/163821
2025-12-10 14:05:38 +00:00
Charles Zablit
2d65bdb00b [lldb] convert jit-loader_rtdyld_elf.test to an API test (#170333)
This patch converts the `jit-loader_rtdyld_elf.test` test from a Shell
test to an API test.

This test is timing out in CI on Windows and the hang cannot be
reproduced at desk. Converting it to an API test would allow us to
instrument it better in order to trace the failure.
2025-12-10 12:43:52 +00:00
Jonas Devlieghere
29760ce5d9 [lldb] Fix capitalization in ambiguous command error (#171519)
We follow LLVM's style guide for diagnostics, which instructs to start
the first sentence with a lowercase letter, and finish the last sentence
without a period, if it would end in one otherwise.
2025-12-09 16:02:40 -08:00
Jonas Devlieghere
9e2b8b0254 [lldb] Remove CommandReturnObject::AppendRawError (#171517)
Remove `CommandReturnObject::AppendRawError` and replace its two uses
with `AppendError`, which correctly prefixes the message with `error:`.
The comment for the method is outdated and the prefixing is clearly
desired in both situations.
2025-12-09 22:36:32 +00:00
nerix
719826d33d [LLDB] Run MSVC STL optional test with PDB (#171486)
Similar to the other PRs, this runs the `std::optional` test with PDB.
Since we don't know that variables use typedefs, we check for the full
name when testing PDB.
2025-12-09 19:52:02 +01:00
nerix
cd805a7373 [LLDB] Run MSVC STL (forward-)list test with PDB (#166953)
Since PDB doesn't have template information, we need to get the element
type from somewhere else. I'm using the type of `_Myval` in a list node,
which holds the element type.
2025-12-09 19:09:33 +01:00
nerix
9b12f8fcae [LLDB] Run MSVC STL smart pointer tests with PDB (#166946)
Runs the `std::shared/unique_ptr` tests with PDB with two changes:

- PDB uses the "full" name, so `std::string` is `std::basic_string<char,
std::char_traits<char>, std::allocator<char>>`
- The type of the pointer inside the shared/unique_ptr isn't the
`element_type` typedef
2025-12-09 18:06:26 +01:00
Michael Buch
f53f6f7250 [lldb][test] Add basic API tests for DW_TAG_template_alias (#170804)
Basic API tests to check how template aliases are rendered by LLDB
(using both `DW_TAG_template_alias` and `DW_TAG_typedef`, with and
without `-gsimple-template-names`).
2025-12-09 07:48:20 +00:00
Michael Buch
0bb0e26aaf [lldb][TypeSystemClang] Set SuppressInlineNamespace to 'All' (#171138)
We used to set it to `true` up until recently, see
[here](https://github.com/llvm/llvm-project/pull/170802). That's
incorrect because `SuppressInlineNamespace` is actually an enum. What
probably happened is that `SuppressInlineNamespace` used to be a boolean
but got turned into an enum. But the assignment in LLDB wasn't updated.
But because the bitfield is an `unsigned`, the compiler never
complained.

This meant that ever since `SuppressInlineNamespace` became an enum,
we've been setting it to `SuppressInlineNamespaceMode::Redundant`. Which
means we would only omit the inline namespace when displaying typenames
if Clang deemed it unambiguous. This is probably a rare situtation but
the attached test-case is one such scenario. Here, `target var t1`
followed by `target var t2` would print the inline namespace for `t2`,
because in that context, the type is otherwise ambiguous. But because
LLDB's context is lazily constructed, evaluating `t2` first would omit
the inline namespace, because `t1` isn't in the context yet to make it
ambiguous.

This patch sets the `SuppressInlineNamespace` to
`SuppressInlineNamespaceMode::All`, which is most likely what was
intended in the first place, and also removes the above-mentioned
non-determinism from our typename printing.
2025-12-09 07:47:39 +00:00
jimingham
0ce6d56996 Fix a typo in "breakpoint add file" and add a test (#171206)
lldbutil.run_to_line_breakpoint had usages that set column breakpoints,
so I thought there was coverage of that on the command-line, but
actually all the `run_to` utilities use the SB API's, and there weren't
any tests of setting file line & column breakpoint through
`run_break_set`. So I missed that I had typed the column option `c` -
that's taken by `--command`.

This patch fixes that typo and adds a CLI test for file + line + column.
2025-12-08 14:34:09 -08:00
Med Ismail Bennani
96c733e0db [lldb] Add support for PC-less scripted frames (#170805)
Scripted frames that materialize Python functions or other non-native
code are PC-less by design, meaning they don't have valid program
counter values. Previously, these frames would display invalid addresses
(`0xffffffffffffffff`) in backtrace output.

This patch updates `FormatEntity` to detect and suppress invalid address
display for PC-less frames, adds fallback to frame methods when symbol
context is unavailable, and modifies `StackFrame::GetSymbolContext` to
skip PC-based symbol resolution for invalid addresses.

The changes enable PC-less frames to display cleanly with proper
function names, file paths, and line numbers, and allow for source
display of foreign sources (like Python). Includes comprehensive test
coverage demonstrating frames pointing to Python source files.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-05 23:57:54 +00:00
jimingham
2110db0f49 Add a breakpoint add command to fix the option-madness that is breakpoint set (#156067)
Someone came up with a clever idea for a new breakpoint type, but we
couldn't figure out how to add it in an ergonomic way because
`breakpoint set` has used up all the short-option characters. And even
if they did find a way to add it, the help for `break set` is so
confusing - because of the way it is implemented - that very few people
would detect the addition.

The basic problem is that `break set` distinguishes amongst the
fundamental breakpoint types it offers by which "required option" you
provide. If you pass a `-a` you are setting an address breakpoint, if
`-n`, `-F`, etc. a symbol name based breakpoint. And so forth. That is
however pretty hard to discern from the option grouping printing from
`help break set`. `break set` also suffers from the problem that it uses
common options in different ways depending on which "required" option is
present, which makes documenting the various behaviors difficult. And as
we run out of single letters it makes extending it difficult to
impossible.

This PR fixes that situation by adding a new command for adding
breakpoints - `break add`. The new command specifies the "breakpoint
types" as subcommands of `break add` rather than distinguishing them by
their being one of the "required" options the way `break set` does. That
both makes it much clearer what the breakpoint types actually are, and
means that the option set can be dedicated to that particular breakpoint
type, and so the help for each is less cluttered, and can be documented
properly for each usage.

Instead of trying to parse the meaning of:

```
(lldb) help break set
Sets a breakpoint or set of breakpoints in the executable.

Syntax: breakpoint set <cmd-options>

Command Options Usage:
  breakpoint set [-DHd] -l <linenum> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-u <column>] [-f <filename>] [-m <boolean>] [-s <shlib-name>] [-K <boolean>]
  breakpoint set [-DHd] -a <address-expression> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-N <breakpoint-name>] [-s <shlib-name>]
  breakpoint set [-DHd] -n <function-name> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-f <filename>] [-L <source-language>] [-s <shlib-name>] [-K <boolean>]
  breakpoint set [-DHd] -F <fullname> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-f <filename>] [-L <source-language>] [-s <shlib-name>] [-K <boolean>]
  breakpoint set [-DHd] -S <selector> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-f <filename>] [-L <source-language>] [-s <shlib-name>] [-K <boolean>]
  breakpoint set [-DHd] -M <method> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-f <filename>] [-L <source-language>] [-s <shlib-name>] [-K <boolean>]
  breakpoint set [-DHd] -r <regular-expression> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-f <filename>] [-L <source-language>] [-s <shlib-name>] [-K <boolean>]
  breakpoint set [-DHd] -b <function-name> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-f <filename>] [-L <source-language>] [-s <shlib-name>] [-K <boolean>]
  breakpoint set [-ADHd] -p <regular-expression> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-N <breakpoint-name>] [-f <filename>] [-m <boolean>] [-s <shlib-name>] [-X <function-name>]
  breakpoint set [-DHd] -E <source-language> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-N <breakpoint-name>] [-h <boolean>] [-w <boolean>]
  breakpoint set [-DHd] -P <python-class> [-k <none>] [-v <none>] [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-N <breakpoint-name>] [-f <filename>] [-s <shlib-name>]
  breakpoint set [-DHd] -y <linespec> [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-R <address>] [-N <breakpoint-name>] [-m <boolean>] [-s <shlib-name>] [-K <boolean>]

```

We instead offer:

```
(lldb) help break add
Commands to add breakpoints of various types

Syntax: breakpoint add

Access the breakpoint search kernels built into lldb.  Along with specifying the
search kernel, each breakpoint add operation can specify a common set of 
"reaction" options for each breakpoint.  The reaction options can also be
modified after breakpoint creation using the "breakpoint modify" command.       
        

The following subcommands are supported:

      address   -- Add breakpoints by raw address
      exception -- Add breakpoints on language exceptions.  If no language is specified, break on exceptions for all supported languages
      file      -- Add breakpoints on lines in specified source files
      name      -- Add breakpoints matching function or symbol names
      pattern   -- Add breakpoints matching patterns in the source text  Expects 'raw' input (see 'help raw-input'.)
      scripted  -- Add breakpoints using a scripted breakpoint resolver.

For more help on any particular subcommand, type 'help <command> <subcommand>'.

```

The individual subcommand helps are also easier to read. They are still
a little too verbose because they all repeat the options for the
`reactions`. A general fix for our help system would be when a command
incorporates an OptionGroup whole into the command options, help would
show the option group name - which you could separately look up. But
even without that:

```
(lldb) help br a a
Add breakpoints by raw address

Syntax: breakpoint add address <cmd-options> <address> [<address> [...]]

Command Options Usage:
  breakpoint add address [-DHde] [-G <boolean>] [-C <command>] [-c <expr>] [-Y <source-language>] [-i <count>] [-o <boolean>] [-q <queue-name>] [-t <thread-id>] [-x <thread-index>] [-T <thread-name>] [-N <breakpoint-name>] [-s <shlib-name>] <address> [<address> [...]]

       -C <command> ( --command <command> )
            A command to run when the breakpoint is hit, can be provided more than once, the commands will be run in left-to-right order.

       -D ( --dummy-breakpoints )
            Act on Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets.

       -G <boolean> ( --auto-continue <boolean> )
            The breakpoint will auto-continue after running its commands.

       -H ( --hardware )
            Require the breakpoint to use hardware breakpoints.

       -N <breakpoint-name> ( --breakpoint-name <breakpoint-name> )
            Adds this name to the list of names for this breakpoint.  Can be specified more than once.

       -T <thread-name> ( --thread-name <thread-name> )
            The breakpoint stops only for the thread whose thread name matches this argument.

       -Y <source-language> ( --condition-language <source-language> )
            Specifies the Language to use when executing the breakpoint's condition expression.

       -c <expr> ( --condition <expr> )
            The breakpoint stops only if this condition expression evaluates to true.

       -d ( --disable )
            Disable the breakpoint.

       -e ( --enable )
            Enable the breakpoint.

       -i <count> ( --ignore-count <count> )
            Set the number of times this breakpoint is skipped before stopping.

       -o <boolean> ( --one-shot <boolean> )
            The breakpoint is deleted the first time it stop causes a stop.

       -q <queue-name> ( --queue-name <queue-name> )
            The breakpoint stops only for threads in the queue whose name is given by this argument.

       -s <shlib-name> ( --shlib <shlib-name> )
            Set the breakpoint at an address relative to sections in this shared library.

       -t <thread-id> ( --thread-id <thread-id> )
            The breakpoint stops only for the thread whose TID matches this argument.  The token 'current' resolves to the current thread's ID.

       -x <thread-index> ( --thread-index <thread-index> )
            The breakpoint stops only for the thread whose index matches this argument.
     
     This command takes options and free-form arguments.  If your arguments resemble option specifiers (i.e., they start with a - or --), you must use ' --
     ' between the end of the command options and the beginning of the arguments.

```

is pretty readable.
2025-12-04 17:36:50 -08:00
Med Ismail Bennani
41f643ab7e [lldb] Add support for synthetic LineEntry objects without valid address ranges (#158811)
Scripted frames that materialize Python functions are PC-less by design,
meaning they don't have valid address ranges. Previously,
LineEntry::IsValid()
required both a valid address range and a line number, preventing
scripted
frames from creating valid line entries for these synthetic stack
frames.

Relaxing this requirement is necessary since
`SBSymbolContext::SetLineEntry`
will first check if the LineEntry is valid and discard it otherwise.

This change introduces an `synthetic` flag that gets set when LineEntry
objects are created or modified through the SBAPI (specifically via
SetLine).
When this flag is set, IsValid() no longer requires a valid address
range,
only a valid line number.

This is risk-free because the flag is only set for LineEntry objects
created
through the SBAPI, which are primarily used by scripted processes and
frames.
Regular debug information-derived line entries continue to require valid
address ranges.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-04 20:48:49 +00:00
Augusto Noronha
d7fb086668 [lldb] Refactor LookupInfo object to be per-language (#168797)
Some months ago, the LookupInfo constructor logic was refactored to not
depend on language specific logic, and use languages plugins instead. In
this refactor, when the language type is unknown, a single LookupInfo
object will handle multiple languages. This doesn't work well, as
multiple languages might want to configure the LookupInfo object in
different ways. For example, different languages might want to set the
m_lookup_name differently from each other, but the previous
implementation would pick the first name a language provided, and
effectively ignored every other language. Other fields of the LookupInfo
object are also configured in incompatible ways.

This approach doesn't seem to be a problem upstream, since only the
C++/Objective-C language plugins are available, but it broke downstream
on the Swift fork, as adding Swift to the list of default languages when
the language type is unknown breaks C++ tests.

This patch makes it so instead of building a single LookupInfo object
for multiple languages, one LookupInfo object is built per language
instead.

rdar://159531216
2025-12-03 16:15:36 -08:00
Vladislav Dzhidzhoev
b13b41a891 Revert "[LLDB] Add SBFrameExtensions Tests (#169236)" (#170555)
This reverts commit 5e5937c3d2, since the
added test fails on the `lldb-x86_64-win` buildbot.

https://lab.llvm.org/buildbot/#/builders/211/builds/4246
2025-12-03 22:01:34 +01:00
Ebuka Ezike
e9bda498e6 [lldb] add libstdcpp span formatter (#168705) 2025-12-03 12:09:23 +00:00
Med Ismail Bennani
542a8f25c0 [lldb/test] Add missing import for decorator (NFC)
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02 18:59:27 -08:00
Med Ismail Bennani
6f5a69b54c [lldb/test] Skip ScriptedFrameProviders tests on arm32 (NFC)
It looks like the providers don't get loaded on arm32 bots:

https://github.com/llvm/llvm-project/issues/170412

Skipping for now since I don't have access to a machine to investigate
it.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02 18:54:30 -08:00
Med Ismail Bennani
82c6ad655d [lldb/test] Add missing import for decorator (NFC)
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02 18:28:42 -08:00
Med Ismail Bennani
2cf276880d [lldb/test] XFAIL TestFrameProviderCircularDependency.py on Windows
This patch disables TestFrameProviderCircularDependency.py on Windows
since the scripted frame provider uses SBTarget.FindFunctions which
doesn't seem to be working (according to TestTargetAPI.test_find_functions).

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02 17:26:30 -08:00
Med Ismail Bennani
b30a48c389 [lldb/test] Fix scripted frame provider tests on ARM32
On ARM32, FixCodeAddress unconditionally clears bit 0 (the Thumb bit)
from all code addresses, including synthetic frame PCs. This causes
test failures where synthetic PCs like 0xFFFF and 0xDEADBEEF become
0xFFFE and 0xDEADBEEE respectively.

This adjusts the tests to expect the modified PC values on ARM32.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02 16:39:33 -08:00
Med Ismail Bennani
c50802cbee Reland "[lldb] Introduce ScriptedFrameProvider for real threads (#161870)" (#170236)
This patch re-lands #161870 with fixes to the previous test failures.

rdar://161834688

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02 18:59:40 +00:00
Ahmed Nour
5e5937c3d2 [LLDB] Add SBFrameExtensions Tests (#169236)
Fixes part of https://github.com/llvm/llvm-project/issues/168920
2025-12-02 10:02:11 -08:00
Ebuka Ezike
5c552c5cff [lldb] Fix GetExpressionPath for vector registers (#169210)
Vector registers have synthetic values for display purposes. This causes
SBValue::GetExpressionPath to dispatch
to ValueObjectSynthetic instead of ValueObjectRegister, producing
incorrect results.

Fixes #147144
2025-12-02 17:10:08 +00:00
Dan Liew
e27dec5eed [BoundsSafety][LLDB] Implement instrumentation plugin for -fbounds-safety soft traps (#169117)
This patch tries to upstream code landed downstream in
https://github.com/swiftlang/llvm-project/pull/11835.

This patch implements an instrumentation plugin for the
`-fbounds-safety` soft trap mode first implemented in
https://github.com/swiftlang/llvm-project/pull/11645 (rdar://158088757).
That functionality isn't supported in upstream Clang yet, however the
instrumented plugin can be compiled without issue so this patch tries to
upstream it. The included tests are all disabled when the clang used for
testing doesn't support `-fbounds-safety`. This means the tests will be
skipped. However, it's fairly easy to point LLDB at a clang that does
support `-fbounds-safety. I've done this and confirmed the tests pass.
To use a custom clang the following can be done:

* For API tests set the `LLDB_TEST_COMPILER` CMake cache variable to
  point to appropriate compiler.
* For shell tests applying a patch like this can be used to set the
  appropriate compiler:

```
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -271,6 +271,7 @@ def use_support_substitutions(config):
     if config.lldb_lit_tools_dir:
         additional_tool_dirs.append(config.lldb_lit_tools_dir)

+    config.environment['CLANG'] = '/path/to/clang'
     llvm_config.use_clang(
```

The current implementation of -fbounds-safety traps works by emitting
calls to runtime functions intended to log the occurrence of a soft
trap.
While the user could just set a breakpoint of these functions the
instrumentation plugin sets it automatically and provides several
additional features:

When debug info is available:

* It adjusts the stop reason to be the reason for trapping. This is
  extracted from the artificial frame in the debug info (similar to
  -fbounds-safety hard traps).
* It adjusts the selected frame to be the frame where the soft trap
  occurred.

When debug info is not available:

* For the `call-with-str` soft trap mode the soft trap reason is
  read from the first argument register.
* For the `call-minimal` soft trap mode the stop reason is adjusted
  to note its a bounds check failure but does not give further
  information because none is available.
* In this situation the selected frame is not adjusted because in
  this mode the user will be looking at assembly and adjusting the
  frame makes things confusing.

This patch includes shell and api tests. The shell tests seemed like the
best way to test behavior when debug info is missing because those tests
make it easy to disable building with debug info completely.

rdar://163230807
2025-12-01 16:13:19 -08:00
Jonas Devlieghere
c103d61758 [lldb] Fix a bug when disabling the statusline. (#169127)
Currently, disabling the statusline with `settings set show-statusline
false` leaves LLDB in a broken state. The same is true when trying to
toggle the setting again.

The issue was that setting the scroll window to 0 is apparently not
identical to setting it to the correct number of rows, even though some
documentation online incorrectly claims so.

Fixes #166608
2025-12-01 18:30:31 +00:00
Sergei Druzhkov
207627f20f [lldb-dap] Add data breakpoints for bytes (#167237)
This patch adds support for `dataBreakpointInfoBytes` capability from
DAP. You can test this feature in VSCode (`Add data breakpoint at
address` button in breakpoints tab).
2025-11-28 18:20:20 +03:00
Ebuka Ezike
14fb59a2c2 [lldb] Fix duplicate test class name causing lldb-dotest conflict (#169861)
Duplicate test class name `TestFrameVarDILPointerArithmetic` prevents
lldb-dotest from running any tests.
The conflict exists between:
- lldb/test/API/commands/frame/vardil/expr/PointerArithmetic/
- lldb/test/API/commands/frame/vardil/basics/PointerArithmetic/

Rename the expr variant to `TestFrameVarDILExprPointerArithmetic`.
2025-11-28 12:09:23 +00:00
n2h9
a4d42775b9 [lldb] [scripting bridge] 167388 chore: add api to return arch name for target (#168273)
This pr fixes #167388 .

## Description

This pr adds new method `GetArchName` to `SBTarget` so that no need to
parse triple to get arch name in client code.

## Testing

### All from `TestTargetAPI.py`

run test with

```
./build/bin/lldb-dotest -v -p TestTargetAPI.py
```
<details>
<summary>existing tests (without newly added)</summary>
<img width="1425" height="804" alt="image"
src="https://github.com/user-attachments/assets/617e4c69-5c6b-44c4-9aeb-b751a47e253c"
/>
</details>

<details>
<summary>existing tests (with newly added)</summary>
<img width="1422" height="778" alt="image"
src="https://github.com/user-attachments/assets/746990a1-df88-4348-a090-224963d3c640"
/>

</details>

### Only `test_get_arch_name`

run test with 
```
./build/bin/lldb-dotest -v -p TestTargetAPI.py -f test_get_arch_name_dwarf -f test_get_arch_name_dwo -f test_get_arch_name_dsym lldb/test/API/python_api/target

```
<details>
<summary>only newly added</summary>
<img width="1422" height="778" alt="image"
src="https://github.com/user-attachments/assets/fcaafa5d-2622-4171-acee-e104ecee0652"
/>
</details>

---------

Signed-off-by: Nikita B <n2h9z4@gmail.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-11-26 11:36:19 -08:00
Janet Yang
5ab3375b2c [lldb-dap] Add multi-session support with shared debugger instances (#163653)
## Summary:
This change introduces a `DAPSessionManager` to enable multiple DAP
sessions to share debugger instances when needed, for things like child
process debugging and some scripting hooks that create dynamically new
targets.

Changes include:
- Add `DAPSessionManager` singleton to track and coordinate all active DAP
sessions
- Support attaching to an existing target via its globally unique target
ID (targetId parameter)
- Share debugger instances across sessions when new targets are created
dynamically
- Refactor event thread management to allow sharing event threads
between sessions and move event thread and event thread handlers to `EventHelpers`
- Add `eBroadcastBitNewTargetCreated` event to notify when new targets are
created
- Extract session names from target creation events
- Defer debugger initialization from 'initialize' request to
'launch'/'attach' requests. The only time the debugger is used currently
in between its creation in `InitializeRequestHandler` and the `Launch`
or `Attach` requests is during the `TelemetryDispatcher` destruction
call at the end of the `DAP::HandleObject` call, so this is safe.

This enables scenarios when new targets are created dynamically so that
the debug adapter can automatically start a new debug session for the
spawned target while sharing the debugger instance.

## Tests:
The refactoring maintains backward compatibility. All existing DAP test
cases pass.

Also added a few basic unit tests for DAPSessionManager
```
>> ninja DAPTests
>> ./tools/lldb/unittests/DAP/DAPTests
>>./bin/llvm-lit -v ../llvm-project/lldb/test/API/tools/lldb-dap/
```
2025-11-26 10:32:25 -08:00
Sergei Druzhkov
3694798210 [lldb-dap] Add format support for evaluate request (#169132)
This patch adds support for format option in the `evaluate` request
according to
[DAP](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Evaluate)
specification. Also, fixed typo in `LLDB_DAP_INVALID_VARRERF` constant.
2025-11-25 22:38:25 +03:00
Ilia Kuklin
d5927a6172 [LLDB] Add unary plus and minus to DIL (#155617)
This patch adds unary nodes plus and minus, introduces unary type
conversions, and adds integral promotion to the type system.
2025-11-24 19:08:53 +05:00
Igor Kudrin
ccdb71932a [lldb] Fix a test if hardware breakpoints are not supported (#168813)
If `HardwareBreakpointTestBase.supports_hw_breakpoints()` returns False,
`SimpleHWBreakpointTest.does_not_support_hw_breakpoints()` returns None,
so the test runs and fails. However, it should be skipped instead.

The test was added in #146602, while `supports_hw_breakpoints()` was
changed in #146609, which was landed earlier despite having a bigger
number.
2025-11-20 09:45:54 -08:00
Igor Kudrin
12d72050e1 [lldb][test] Correctly skip a test on a 32-bit target (#168631)
The test was added in #147252. On a 32-bit target, it fails with error:
```
  File "...\TestDataFormatterLibcxxInvalidString.py", line 23, in test
    self.skip()
    ^^^^^^^^^
AttributeError: 'LibcxxInvalidStringDataFormatterTestCase' object has no attribute 'skip'
```
2025-11-19 13:38:41 -08:00
Felipe de Azevedo Piovezan
93a1327dea [lldb] Skip TestLibcxxInternalsRecognizer on asan + MacOS
Unfortunately, in this configuration, the bots are forced to use the
system libcxx, which is too old for what this test is verifying.
In the future, we should re-enable building libcxx with asan on MacOS.
2025-11-19 14:27:13 +00:00
Adrian Prantl
54c2c7cf0d [LLDB] Fix test compilation errors under asan (NFC) (#168408)
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/2744/consoleText
2025-11-17 13:01:52 -08:00
John Harrison
c555522818 [lldb-dap] Migrating 'evaluate' to structured types. (#167720)
Adding structured types for the evaluate request handler.

This should be mostly a non-functional change. I did catch some spelling
mistakes in our tests ('variable' vs 'variables').
2025-11-17 11:08:49 -08:00
Kiva
bdae26f3b4 [LLDB][DWARF] Use the same qualified name computation for Rust (#165840)
Currently LLDB's `ParseRustVariantPart` generates the following
`CXXRecordDecl` for a Rust enum
```rust
enum AA {
  A(u8)
}
```

```
CXXRecordDecl 0x5555568d5970 <<invalid sloc>> <invalid sloc> struct AA
|-CXXRecordDecl 0x5555568d5ab0 <<invalid sloc>> <invalid sloc> union test_issue::AA$Inner definition
| |-CXXRecordDecl 0x5555568d5d18 <<invalid sloc>> <invalid sloc> struct A$Variant definition
| | |-DefinitionData pass_in_registers aggregate standard_layout trivially_copyable trivial
| | | `-Destructor simple irrelevant trivial needs_implicit
| | `-FieldDecl 0x555555a77880 <<invalid sloc>> <invalid sloc> value 'test_issue::AA::A'
| `-FieldDecl 0x555555a778f0 <<invalid sloc>> <invalid sloc> $variant$ 'test_issue::AA::test_issue::AA$Inner::A$Variant'
|-CXXRecordDecl 0x5555568d5c48 <<invalid sloc>> <invalid sloc> struct A definition
| `-FieldDecl 0x555555a777e0 <<invalid sloc>> <invalid sloc> __0 'unsigned char'
`-FieldDecl 0x555555a77960 <<invalid sloc>> <invalid sloc> $variants$ 'test_issue::AA::test_issue::AA$Inner'
```

While when the Rust enum type name is the same as its variant name, the
generated `CXXRecordDecl` becomes the following – there's a circular
reference between `struct A$Variant` and `struct A`, causing #163048.

```rust
enum A {
  A(u8)
}
```

```
CXXRecordDecl 0x5555568d5760 <<invalid sloc>> <invalid sloc> struct A
|-CXXRecordDecl 0x5555568d58a0 <<invalid sloc>> <invalid sloc> union test_issue::A$Inner definition
| |-CXXRecordDecl 0x5555568d5a38 <<invalid sloc>> <invalid sloc> struct A$Variant definition
| | `-FieldDecl 0x5555568d5b70 <<invalid sloc>> <invalid sloc> value 'test_issue::A'    <---- bug here
| `-FieldDecl 0x5555568d5be0 <<invalid sloc>> <invalid sloc> $variant$ 'test_issue::A::test_issue::A$Inner::A$Variant'
`-FieldDecl 0x5555568d5c50 <<invalid sloc>> <invalid sloc> $variants$ 'test_issue::A::test_issue::A$Inner'
```

The problem was caused by `GetUniqueTypeNameAndDeclaration` not
returning the correct qualified name for DWARF DIE `test_issue::A::A`,
instead, it returned `A`. This caused `ParseStructureLikeDIE` to find
the wrong type `test_issue::A` and returned early.

The failure in `GetUniqueTypeNameAndDeclaration` appears to stem from a
language check that returns early unless the language is C++. I changed
it so Rust follows the C++ path rather than returning. I’m not entirely
sure this is the right approach — Rust’s qualified name rules look
similar, but not identical? Alternatively, we could add a Rust-specific
implementation that forms qualified names according to Rust's rules.
2025-11-17 10:38:40 +00:00
Jonas Devlieghere
6dad2c2cfb [lldb] Add a test for capturing stdout/stderr from Python commands (#168138) 2025-11-14 22:43:01 +00:00