1354 Commits

Author SHA1 Message Date
Charles Zablit
dbbea962c9
[lldb-dap][windows] fix invalid path substitution for lldb-dap (#180237)
https://github.com/llvm/llvm-project/pull/178642 added
`lldb/test/Shell/DAP/TestSTDINConsole.test` with an incorrect
`%lldb-dap` expansion. This patch fixes it.
2026-02-09 14:49:57 +01:00
puneeth_aditya_5656
936ec4ea66
[lldb] Handle STT_TLS symbol type in ELF parser (#178975)
Add handling for `STT_TLS` (thread-local storage) symbols in the ELF
symbol parsing code. Previously, TLS symbols like `errno` from glibc
were not recognized because `STT_TLS` was not handled in the symbol type
switch statement.

This treats TLS symbols as data symbols (`eSymbolTypeData`), similar to
`STT_OBJECT`. The actual TLS address resolution is already implemented
in `DynamicLoaderPOSIXDYLD::GetThreadLocalData()` which uses the DWARF
`DW_OP_form_tls_address` opcode to calculate thread-local addresses.
2026-02-09 10:02:44 +00:00
Charles Zablit
9f8f90143e
Revert "[lldb-dap] fix executable substitution in tests (#179685)" (#180241)
This reverts commit 082a47d8944da242993bf28980b07f2c8c3df4a6.

`ToolSubst` should only be used explicitely for passing `extra_args`.
2026-02-06 17:38:37 +00:00
Charles Zablit
082a47d894
[lldb-dap] fix executable substitution in tests (#179685)
This patch fixes the `lldb-dap` executable substitution in tests. This
was not done before.
2026-02-04 18:06:04 +00:00
Dave Lee
e438a903db
[lldb] Increment max-children-depth to 5 (#178717)
`max-children-depth` was [originally 6][1], which produced too large of
output. It was then [reduced to 4][2], which for some people is too low.
This change is to try 5 as the default.

Originally upstreamed in
https://github.com/llvm/llvm-project/pull/149282

[1]:
ee0782bf6b
[2]: https://github.com/swiftlang/llvm-project/pull/10683
2026-01-30 09:02:03 -08:00
Charles Zablit
e17374a33f
[lldb-dap][windows] allow STDIN to be a console (#178642) 2026-01-29 12:20:51 +00:00
Charles Zablit
4ebede7696
Revert "[lldb-dap][windows] allow STDIN to be a console (#178409)" (#178641) 2026-01-29 11:50:51 +00:00
Charles Zablit
f1235bd624
[lldb-dap][windows] allow STDIN to be a console (#178409)
Co-authored-by: Ebuka Ezike <yerimyah1@gmail.com>
2026-01-29 10:59:40 +00:00
Greg Clayton
16149ca932
Add support for DW_FORM_GNU_ref_alt and DW_FORM_GNU_strp_alt. (#176056)
LLDB's DWARF parser didn't support parsing DW_FORM_GNU_ref_alt and
DW_FORM_GNU_strp_alt forms which would cause any file loaded by LLDB to
fail to parse any DWARF. Added support for parsing this information
only, not for actually finding the debug info reference to an alternate
file or a string in an alternate file. These extensions are used by DWZ
files which are present in some linux distros, so it will be good for
LLDB to just be able to parse these without emitting an error like:

(lldb) b bar
warning: (arm64) /tmp/a.out unsupported DW_FORM values: 0x1f20 0x1f21
2026-01-28 17:49:18 -08:00
Vladimir Gorsunov
c3d4375729
[lldb][NativePDB] Fix crash in debugger when PDB has bad type index value (#166455)
Fix crash when an inline site record in the PDB file contains type index
which is out of bounds
2026-01-28 17:18:09 +01:00
Ebuka Ezike
78f9d78b13
[lldb] Fix Python stderr redirection in test (#177970)
Python's internal stderr may differ from sys.stderr. 
When Python writes errors, it uses its internal stderr rather than the
overwritten sys.stderr.
This may not be the same file/handle

Fix the test to explicitly write to the specified stderr.
2026-01-26 22:20:55 +00:00
David Spickett
e1a23f7152
[lldb] Fix error when running "memory region --all" repeatedly (#177176)
Due to some faulty logic, if you ran "memory region --all" twice, the
second time lldb would try to repeat the command. There's nothing to
repeat, so it failed with an error. It should treat each "--all" use as
starting from scratch.

The logic here was written in a confusing way, so I've refactored it to
first look at how many arguments there are (aka how many address
expressions there are) and then validate based on that.

For reasons unknown, I could not reproduce this issue using the API test
TestMemoryRegion.py. So I have added a shell test that I confirmed does
fail without this fix.
2026-01-26 09:43:04 +00:00
Charles Zablit
168ccaebf0
Revert "[lldb][windows] add STDIN and STDOUT forwarding support (#175812)" (#177610) 2026-01-23 16:40:05 +00:00
Charles Zablit
4b7cf46f6b
[lldb][windows] add STDIN and STDOUT forwarding support (#175812) 2026-01-23 13:37:21 +01:00
Michael Buch
3aea01b271
[lldb][DWARFASTParserClang] RequireCompleteType for ObjC types (#176765)
Currently we forcefully complete C++ types if we can't find their
definition for layout purposes. This ensures that we at least don't
crash in Clang when laying out the type. The definition is required for
types of members/array elements/base classes for the purposes of
calculating their layout. This is also true for Obj-C types, but we
haven't been forcefully completing those.

The test-case that's being un-XFAILed in this patch demonstrates a case
where not completing the super-class forcefully causes a clang crash.

rdar://168440264
2026-01-20 18:26:23 +00:00
Michael Buch
230f6ab1b8 [lldb][test] Add a test for evaluating Obj-C types with an incomplete super-class
LLDB currently crashes when the super-class of an Objective-C type can't
be completed (i.e., has no definition). For Foundation types such as
`NSObject`, the debug-info would usually only contain forward
declarations. The definitions live in the Clang module `.pcm` files. But
if the source of the definition fails to be loaded (e.g., if we just
delete the module cache), then we can no longer guarantee that the
super-class has a definition. This breaks a key Clang invariant, which
requires base-classes to have definitions by the time we try to lay them
out. This patch adds an XFAILed test for such scenario.

rdar://168440264
2026-01-19 14:34:46 +00:00
Austin Jiang
e6cdfb75ac
Fix typos and spelling errors across codebase (#156270)
Corrected various spelling mistakes such as 'occurred', 'receiver',
'initialized', 'length', and others in comments, variable names,
function names, and documentation throughout the project. These
changes improve code readability and maintain consistency in naming
and documentation.

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2026-01-13 11:52:46 -05:00
Raul Tambre
8fb1200c95
[NFCI][lldb][test][asm] Enable AT&T syntax explicitly (#172358)
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).

Unreverts: 14c69497b31038b37c273417f43bd2cfe169c86f
2026-01-12 20:56:20 +02:00
Jonas Devlieghere
17e226f71e
[lldb] Fix crash when passing a folder in as the executable (#175181)
This is another instance where we weren't checking that the result of
FileSystem::CreateDataBuffer and unconditionally accessing it, similar
to the bug in SourceManager last week. In this particular case,
ObjectFile was assuming that we can read the contents non-zero, which
isn't true for directory nodes.

Jim figured this one out yesterday. I'm just putting up the patch and
adding a test.

rdar://167796036
2026-01-09 11:29:31 -06:00
Ebuka Ezike
21a1e6e6a7
[lldb] skip the python interactive I/O test on windows (#175055)
There is no indication this ever worked on windows as this is the first
test that checks python interactive console from a file.

Looking at the error from the CI, It closed the interpreter before
running any python commands.
Will reconfirm this when I have access to a windows machine. 


From https://github.com/llvm/llvm-project/pull/174216
2026-01-08 20:16:42 +00:00
Ebuka Ezike
43cb4631c1
[lldb] Fix typed commands not shown on the screen (#174216)
The cause is that in `python3.14`, `fcntl.ioctl` now throws a buffer
overflow error
when the buffer is too small or too large (see
https://github.com/python/cpython/pull/132919). This caused the Python
interpreter to fail terminal detection and not properly echo user
commands back to the screen.

Fix by dropping the custom terminal size check entirely and using the
built-in `sys.stdin.isatty()` instead.

Fixes #173302
2026-01-08 18:46:03 +00:00
Michael Buch
1d07609894
[lldb][Format] Reject recursive format entities (#174750)
Depends on:
* https://github.com/llvm/llvm-project/pull/174618

If a format entity calls back into `Format` and passes it a format
entity type that we're already in the process of parsing, we are likely
going to run into infinite recursion and blow the stack. I think this is
only an issue when a format entity calls Format on a format string
provided by the user (otherwise we're in control of the recursion). An
example of this can be seen in the test-case adjusted by this patch.

This seems to be causing actual crashes in the field, so this patch adds
basic tracking to `Formatter::Format` that checks whether we're
recursively parsing the same entity. This may very well be intended by
some entities (e.g., `Root` and `Scope`), so there is an escape hatch
for those. There's also a special case where `Variable` causes a
recursive format (which I pointed out in a source comment).

We could narrow the scope of what kind of recursion is allowed by adding
a `UserProvidedFormatChild` (or similar) flag to `Entry`, and only
disallow recursing on those kinds of entries. For now I just use an
exemption list in `IsInvalidRecursiveFormat`.

Adding a unit-test for this is unfortunately tricky because the only
format entity that currently suffers from this is
`${function.name-with-args}`, which requires a language plugin and valid
target. If we really wanted to we could probably mock all of those, but
the shell test provides test coverage for the previously crashing case.

rdar://166890120
2026-01-08 16:25:42 +00:00
Jonas Devlieghere
1f5126dae1
[lldb] Don't trim expression in progress event (#174609)
Trimming the content of the progress event is the responsibility of the
consumer, not the producer. For example, when using the statusline,
there's plenty of space to show longer expressions.

rdar://166879951
2026-01-06 13:57:01 -06: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
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
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
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
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
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
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
Omair Javaid
c89d87a512
[lldb][test] Fix toolchain-msvc.test for native ARM64 MSVC environment (#171797)
This patch fixes toolchain-msvc.test on Windows ARM64 hosts running
under native ARM64 environment via vcvarsarm64.bat. Our lab buildbot
recently switched from using cross vcvarsamd64_arm64.bat environment to
native vcvarsarm64.bat. This patch updates FileCheck patterns to also
allow HostARM64 and arm64 PATH entries.

Changes:
-> Extend host regex to match HostARM64 (case-insensitive)
-> Allow arm64 in PATH tail.
-> Apply same fix in both 32-bit and 64-bit sections.
2025-12-11 16:15:10 +05:00
Charles Zablit
0b522d9e8e
Revert "[lldb] fix failing tests due to CI diagnostics rendering (#171791) 2025-12-11 10:16:01 +00:00
Charles Zablit
871dabc8ea
[lldb] fix failing tests due to CI diagnostics rendering (#171685)
This patch fixes issues introduced by
https://github.com/llvm/llvm-project/pull/171491 when running tests in
CI.

The shell tests expect certain characters when matching diagnostics.
With https://github.com/llvm/llvm-project/pull/171491, those characters
can either be Unicode specific characters or their ASCII equivalent. The
tests were always expecting the ASCII version. This patch fixes this by
using a regex to match one or the other.
2025-12-10 23:08:01 +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
Derek Schuff
782f50792f
[lldb][Wasm] Handle imports when parsing Wasm name sections (#170960)
LLDB can use the wasm name section to populate its symbol table and get
names for functions. However the index space used in the name section is
the "function index space" which includes imported as well as locally
defined functions.
2025-12-09 23:41:06 +00: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
Jonas Devlieghere
bc9f96a5e6
[lldb] Dump build configuration with version -v (#170772)
Add a verbose option to the version command and include the "build
configuration" in the command output. This allows users to quickly
identify if their version of LLDB was built with support for
xml/curl/python/lua etc. This data is already available through the SB
API using SBDebugger::GetBuildConfiguration, but this makes it more
discoverable.

```
(lldb) version -v
lldb version 22.0.0git (git@github.com:llvm/llvm-project.git revision 21a2aac5e5456f9181384406f3b3fcad621a7076)
  clang revision 21a2aac5e5456f9181384406f3b3fcad621a7076
  llvm revision 21a2aac5e5456f9181384406f3b3fcad621a7076
  editline_wchar: yes
  lzma: yes
  curses: yes
  editline: yes
  fbsdvmcore: yes
  xml: yes
  lua: yes
  python: yes
  targets: [AArch64, AMDGPU, ARM, AVR, BPF, Hexagon, Lanai, LoongArch, Mips, MSP430, NVPTX, PowerPC, RISCV, Sparc, SPIRV, SystemZ, VE, WebAssembly, X86, XCore]
  curl: yes
```

Resolves #170727
2025-12-08 10:11:39 -08: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
Felipe de Azevedo Piovezan
cdc41478a0 [lldb][shell tests] Properly fix fallout from c8031c3dd743 2025-12-02 16:14:04 +00:00
Felipe de Azevedo Piovezan
bfc45712f8
Revert "Revert "[LLDB] Update Shell lit config to handle c8031c3dd743"" (#170312)
Reverts llvm/llvm-project#170288

Turns out this was not the cause of the failure
2025-12-02 15:34:59 +00:00
Felipe de Azevedo Piovezan
ac23264c03
Revert "[LLDB] Update Shell lit config to handle c8031c3dd743" (#170288)
Reverts llvm/llvm-project#170225

See failures in
https://ci.swift.org/view/all/job/llvm.org/job/as-lldb-cmake/36912/

```
[2025-12-02T01:20:37.083Z] # .---command stderr------------
[2025-12-02T01:20:37.083Z] # | clang: warning: no such sysroot directory: 'b/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' [-Wmissing-sysroot]
[2025-12-02T01:20:37.083Z] # | clang: warning: argument unused during compilation: '-fmodules-cache-path=/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-shell' [-Wunused-command-line-argument]
[2025-12-02T01:20:37.083Z] # | /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/test/Shell/Settings/Output/TestFrameFormatFunctionPrefix.test.tmp/main.m:2:13: warning: non-void function does not return a value [-Wreturn-type]
[2025-12-02T01:20:37.083Z] # |     2 | int func() {}
[2025-12-02T01:20:37.083Z] # |       |             ^
[2025-12-02T01:20:37.083Z] # | /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/test/Shell/Settings/Output/TestFrameFormatFunctionPrefix.test.tmp/main.m:3:21: warning: non-void function does not return a value [-Wreturn-type]
[2025-12-02T01:20:37.083Z] # |     3 | int bar() { func(); }
[2025-12-02T01:20:37.083Z] # |       |                     ^
[2025-12-02T01:20:37.083Z] # | 2 warnings generated.
[2025-12-02T01:20:37.083Z] # | ld: library 'System' not found
[2025-12-02T01:20:37.083Z] # | clang: error: linker command failed with exit code 1 (use -v to see invocation)
[2025-12-02T01:20:37.083Z] # `-----------------------------
[2025-12-02T01:20:37.083Z] # error: command failed with exit status: 1
```
2025-12-02 13:11:02 +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
Alex Langford
ace65a0a8d
[LLDB] Update Shell lit config to handle c8031c3dd743 (#170225) 2025-12-01 15:44:01 -08:00
nerix
c9d9dddc1c
[LLDB][NativePDB] Look for PDBs in target.debug-file-search-paths (#169719)
Similar to DWARF's DWO, we should look for PDBs in
`target.debug-file-search-paths` if the PDB isn't at the original
location or next to the executable.

With this PR, the search order is as follows:

1. PDB path specified in the PE/COFF file
2. Next to the executable
3. In `target.debug-file-search-paths`

This roughly matches [the order Visual Studio
uses](https://learn.microsoft.com/en-us/visualstudio/debugger/specify-symbol-dot-pdb-and-source-files-in-the-visual-studio-debugger?view=vs-2022#where-the-debugger-looks-for-symbols),
except that we don't have a project folder and don't support symbol
servers.

Closes #125355 (though I think this is already fixed in the native
plugin).
2025-12-01 19:27:54 +01:00
nerix
b38ed00495
[LLDB][PDB] Relax check for resolving breakpoint (#169932)
The test was flaky, because it assumed that the breakpoint was always
resolved before `r` was executed
(https://github.com/llvm/llvm-project/pull/169728#issuecomment-3589799783).
This PR removes the check for this order. It still checks that the
breakpoint is resolved before it is hit.
2025-11-28 18:14:59 +01:00
nerix
cc72171322
[LLDB][PDB] Access object file through module (#169728)
When a PDB is loaded through `target symbols add <pdb-path>`, its
`m_objectfile_sp` is an `ObjectFilePDB` instead of `ObjectFilePECOFF`
(the debugged module). In both the native and DIA plugin, some paths
assumed that `m_objectfile_sp` is the debugged module. With this PR,
they go through `m_objfile_sp->GetModule()->GetObjectFile()`.

For the DIA plugin, this lead to an assertion failure
(https://github.com/llvm/llvm-project/issues/169628#issuecomment-3582555277)
and for both plugins, it meant that the symbol table wasn't loaded.
2025-11-28 14:58:32 +01:00
Dan Liew
8bdbc57b89
[NFC][LLDB] Make it possible to detect if the compiler used in tests supports -fbounds-safety (#169112)
This patch makes it possible to detect in LLDB shell and API tests if
`-fbounds-safety` is supported by the compiler used for testing. The
motivation behind this is to allow upstreaming
https://github.com/swiftlang/llvm-project/pull/11835 but with the tests
disabled in upstream because the full implementation of -fbounds-safety
isn't available in Clang yet.

For shell tests when -fbounds-safety is available the
`clang-bounds-safety` feature is available which means tests can be
annotated with `# REQUIRES: clang-bounds-safety`.

API tests that need -fbounds-safety support in the compiler can use the
new `@skipUnlessBoundsSafety` decorator.

rdar://165225507
2025-11-21 19:01:31 -08:00