144 Commits

Author SHA1 Message Date
⭐️NINIKA⭐️
ce0bc3aa70 [lldb][docs] document an analogue for info proc mappings (#153559) 2025-08-15 12:01:52 +00:00
Charles Zablit
ab6923b9b7
[lldb] add TemplateRange and NameQualifiersRange to DemangledNameInfo (#150999)
This patch adds 2 new attributes to `DemangledNameInfo`: `TemplateRange`
and `NameQualifiersRange`. It also introduces the
`function.name-qualifiers` entity formatter which allows tracking
qualifiers between the name of a function and its arguments/template.

This will be used downstream in Swift but may have applications in C++:
https://github.com/swiftlang/llvm-project/pull/11068.
2025-08-05 14:07:35 +02:00
Michael Buch
c31cb8b9b8 [lldb][docs] Fix typo in frame-format docs 2025-07-31 09:00:40 +01:00
Kazu Hirata
19e2991209
[lldb] Proofread formatting.rst (#149768) 2025-07-21 07:24:15 -07:00
Kazu Hirata
c045caae86
[lldb] Proofread python-reference.rst (#149643) 2025-07-20 11:23:57 -07:00
Jonas Devlieghere
e8dc96d9de
[lldb] Document MCP tools & resources (#148708)
Add documentation for the tools and resources exposed by LLDB's MCP
server.
2025-07-16 09:31:43 -07:00
Jonas Devlieghere
17cb0a73a0
[lldb][docs] Fix another broken markdown link 2025-07-03 14:19:09 -07:00
Jonas Devlieghere
eb904e857a
[lldb] Fix link syntax in docs/use/mcp.md 2025-06-30 13:50:32 -07:00
Jonas Devlieghere
16dc6f64de
[lldb] Document MCP support in LLDB (#145935)
Document how to use MCP support in LLDB. I expect this to change
significantly as the feature matures. For now it covers configuring the
server and two example clients.
2025-06-30 09:01:15 -07:00
Michael Buch
5a918923f3
[lldb][Format] Add [inlined] marker to names of inlined frames (#142952)
This was removed in https://github.com/llvm/llvm-project/pull/135343 in
favour of making it a format variable, which we do here. This follows
the precedent of the `[opt]` and `[artificial]` markers.

Before:
```
 thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
 * frame #0: 0x000000010000037c a.out`inlined1() at inline.cpp:4:3
   frame #1: 0x000000010000037c a.out`regular() at inline.cpp:6:17
   frame #2: 0x00000001000003b8 a.out`inlined2() at inline.cpp:7:43
   frame #3: 0x00000001000003b4 a.out`main at inline.cpp:10:3
   frame #4: 0x0000000186345be4 dyld`start + 7040
```

After (note the `[inlined]` markers):
```
thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
* frame #0: 0x000000010000037c a.out`inlined1() at inline.cpp:4:3 [inlined]
  frame #1: 0x000000010000037c a.out`regular() at inline.cpp:6:17
  frame #2: 0x00000001000003b8 a.out`inlined2() at inline.cpp:7:43 [inlined]
  frame #3: 0x00000001000003b4 a.out`main at inline.cpp:10:3
  frame #4: 0x0000000186345be4 dyld`start + 7040
```

rdar://152642178
2025-06-05 17:41:37 +01:00
Zequan Wu
02916a432c
[lldb][Formatters] Add --pointer-match-depth option to type summary add command. (#138209)
Currently, the type `T`'s summary formatter will be matched for `T`,
`T*`, `T**` and so on. This is unexpected in many data formatters. Such
unhandled cases could cause the data formatter to crash. An example
would be the lldb's built-in data formatter for `std::optional`:
```
$ cat main.cpp
#include <optional>

int main() {
  std::optional<int> o_null;
  auto po_null = &o_null;
  auto ppo_null = &po_null;
  auto pppo_null = &ppo_null;
  return 0;
}
$ clang++ -g main.cpp && lldb -o "b 8" -o "r" -o "v pppo_null"
[lldb crash]
```

This change adds an options `--pointer-match-depth` to `type summary
add` command to allow users to specify how many layer of pointers can be
dereferenced at most when matching a summary formatter of type `T`, as
Jim suggested
[here](https://github.com/llvm/llvm-project/pull/124048/#issuecomment-2611164133).
By default, this option has value 1 which means summary formatter for
`T` could also be used for `T*` but not `T**` nor beyond. This option is
no-op when `--skip-pointers` is set as well.

I didn't add such option for `type synthetic add`, `type format add`,
`type filter add`, because it useful for those command. Instead, they
all have the pointer match depth of 1. When printing a type `T*`, lldb
never print the children of `T` even if there is a synthetic formatter
registered for `T`.
2025-05-28 16:04:24 -04:00
Charles Zablit
b8997c07d9
[Demangling] Refactor Demangler range tracking (#140762)
This PR is a subset of the commits made in
https://github.com/swiftlang/llvm-project/pull/10710.

The most notable change is the addition of `PrefixRange` and
`SuffixRange` which are a catch-all to track anything after or before a
function's demangled name. In the case of Swift, this allows to add
support for name highlighting without having to track the range of the
scope and specifiers of a function (this will come in another PR).
2025-05-28 13:53:02 +01:00
Michael Buch
9392652226
[lldb][docs][NFC] Remove references to obsolete gnu-libstdc++ category (#141610)
This is still leftover from the days when the libc++ and libstdc++
formatters were both written in python and in separate categories. Since
then we group libstdc++ and libc++ formatters into the same cateogry.

This patch removes references to the obsolete `gnu-libstdc++` category
from the docs (and a test).

See [this
thread](https://github.com/llvm/llvm-project/pull/140761#discussion_r2102386080)
for more context
2025-05-27 18:08:17 +01:00
Kazu Hirata
6235479db3
[lldb] Fix a typo in documentation (#141384) 2025-05-25 08:20:04 -07:00
Ebuka Ezike
1b6b036c02
[lldb][docs] add command to save core file in gdb to lldb command map. (#140771) 2025-05-20 20:57:51 +01:00
LauraElanorJones
9178a17206
Update python.rst (#140333)
Fix code block formatting in section "The Decision Point Breakpoint
Commands"
2025-05-16 19:17:03 -07:00
Kazu Hirata
bdf8c9984a
[lldb] Fix typos in documentation (#139839) 2025-05-13 23:34:28 -07:00
Pavel Labath
6a99d81720
[lldb/docs] Fix/improve the gdb command map for dynamic types (#138538)
The setting and option value names were wrong. I'm assuming this changed
over time, but I haven't tried to figure out when.
2025-05-06 15:06:24 +02:00
Michael Buch
64b5bc876a
[lldb][Format] Add function.suffix frame-format variable (#137763)
This patch adds another frame-format variable (currently only
implemented in the CPlusPlus language plugin) that represents the
"suffix" of a function. The name is derived from the `DotSuffix` node of
LLVM's Itanium demangler.

For a function name such as `int foo() (.cold)`, the suffix would be
`(.cold)`.
2025-04-29 10:02:44 +01:00
Michael Buch
fcb1a481ce
[lldb][docs] Document new frame-format variables (#137522)
Documents https://github.com/llvm/llvm-project/pull/131836
2025-04-28 08:28:54 +01:00
Jonas Devlieghere
51c2750599
[lldb] Update examples in docs/use/python-reference.rst to work with Python 3 (#134204)
The examples on this page were using the Python 2-style print. I ran the
updated code examples under Python 3 to confirm they are still
up-to-date.
2025-04-03 07:40:00 -07:00
Kon
d4b586ad95
[LLDB][NFC] Fix typo in docs (#131388) 2025-03-20 09:19:33 +01:00
Greg Clayton
8ac359ba0d
Add complete ObjectFileJSON support for sections. (#129916)
Sections now support specifying:
- user IDs
- file offset/size
- alignment
- flags
- bool values for fake, encrypted and thread specific sections
2025-03-07 15:34:27 -08:00
Dave Lee
1b0becf739 [lldb] Add some formatting to variable.rst (NFC) 2025-01-31 09:29:22 -08:00
David Spickett
6d0dd3d5c4
[lldb][Docs] Add Guarded Control Stack to AArch64 Linux page (#117860)
The meat of this is how we execute expressions and deal with the
aftermath. For most users this will never be a concern, so it functions
more as a design doc than anything else.
2025-01-28 11:38:58 +00:00
Jonas Devlieghere
06c54bc1a2
[lldb] Implement ${target.file} format variable (#123431)
Implements a format variable to print the basename and full path to the
current target.
2025-01-20 15:38:04 -08:00
David Spickett
b0c0a148db
[lldb][Docs] Add equivalents of GDB's "skip" to command map (#120740)
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Skipping-Over-Functions-and-Files.html

We can't emulate all the features of that command but we can skip a
function by name with some extra steps.

As far as I know this only matches function name unlike GDB that can
filter on file and line and so on:
```
target.process.thread.step-avoid-regexp -- A regular expression defining functions step-in won't stop in.
```
It's likely it's got some corner cases that don't work, maybe inlining,
but it doesn't seem worth going into it here.

I don't think we can chain lldb interpreter commands, so I have shown
the steps separately.

I have also mentioned `thread step-in` and its alias `sif`. Which were
new to me too.
2025-01-06 09:17:25 +00:00
David Spickett
84fec7757e [lldb][docs] Clarify unit for SVE P register size 2024-11-25 09:53:15 +00:00
Adrian Prantl
5681f756c0 Fix broken link 2024-11-19 13:01:08 -08:00
Adrian Prantl
61057b0f6f
[lldb/www] Garbage collect old videos and add new ones (#116838)
Fixes #66476
2024-11-19 11:06:16 -08:00
Jonas Devlieghere
6e02e19cd3
[lldb][docs] Add JSON symbol file docs to the ToC 2024-10-18 14:22:54 -07:00
Jason Molenda
9c6f85f57a [lldb][NFC] fix two small typeos in aarch64-linxu.md 2024-10-17 19:46:08 -07:00
苏灵素@夏日限定
646aa817d2
[lldb][Docs] Fix typo in tutorial.rst (#111326) 2024-10-07 21:29:39 -07:00
jimingham
a4197e4728
Add docs describing how the thread plan stack affects stepping (#110167)
This is a convenient little feature of lldb, but if you didn't know it
was there you'd likely never discover it.
2024-09-27 09:36:52 -07:00
David Spickett
f6e771cfed [lldb][Docs] Convert AArch64 Linux doc to Markdown
Executive decision from me given that I am the sole author
of the doc and there's nothing Markdown can't handle here.
2024-09-27 13:31:58 +01:00
jimingham
04b443e778
Add the ability to define custom completers to the parsed_cmd template. (#109062)
If your arguments or option values are of a type that naturally uses one
of our common completion mechanisms, you will get completion for free.
But if you have your own custom values or if you want to do fancy things
like have `break set -s foo.dylib -n ba<TAB>` only complete on symbols
in foo.dylib, you can use this new mechanism to achieve that.
2024-09-24 10:00:00 -07:00
jimingham
615bd9ee60
Add docs and an example use of the scripted command get_flags API. (#109176)
The API is present, and we even have a test for it, but it isn't
documented so no one probably knows you can set requirements for your
scripted commands. This just adds docs and uses it appropriately in the
`framestats` example command.
2024-09-18 18:10:43 -07:00
Med Ismail Bennani
8334d2bfd3
[lldb/Interpreter] Fix ambiguous partial command resolution (#101934)
This patch is a follow-up to #97263 that fix ambigous abbreviated
command resolution.

When multiple commands are resolved, instead of failing to pick a
command to
run, this patch changes to resolution logic to check if there is a
single
alias match and if so, it will run the alias instead of the other
matches.

This has as a side-effect that we don't need to make aliases for every
substring of aliases to support abbrivated alias resolution.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-08-08 12:55:10 -07:00
David Spickett
d4a89af5a8 [lldb][Docs] Move QEMU testing page into the developing lldb section 2024-07-16 13:08:04 +01:00
jimingham
77d131eddb
Add the ability for Script based commands to specify their "repeat command" (#94823)
Among other things, returning an empty string as the repeat command
disables auto-repeat, which can be useful for state-changing commands.

There's one remaining refinement to this setup, which is that for parsed
script commands, it should be possible to change an option value, or add
a new option value that wasn't originally specified, then ask lldb "make
this back into a command string". That would make doing fancy things
with repeat commands easier.

That capability isn't present in the lldb_private side either, however.
So that's for a next iteration.

I haven't added this to the docs on adding commands yet. I wanted to
make sure this was an acceptable approach before I spend the time to do
that.
2024-07-03 10:39:34 -07:00
Eisuke Kawashima
586114510c
[lldb] fix(lldb/**.py): fix comparison to None (#94017)
from PEP8
(https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
is not, never the equality operators.

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2024-06-26 15:59:07 +01:00
Pavel Labath
6c36bdb6ea
[lldb] Add documentation for the max_children argument (#94192) 2024-06-04 09:06:31 +02:00
Dave Lee
8530b1c464
[lldb] Support custom LLVM formatting for variables (#91868)
Re-apply https://github.com/llvm/llvm-project/pull/81196, with a fix that handles the 
absence of llvm formatting: 
https://github.com/llvm/llvm-project/pull/91868/commits/3ba650e91eded3543764f37921dcce3b
b47d425f
2024-05-15 14:44:42 -07:00
Anthony Ha
6aed0ab654
[lldb] Have lldb-server assign ports to children in platform mode (#88845)
Fixes #47549

`lldb-server`'s platform mode seems to have an issue with its
`--min-gdbserver-port` `--max-gdbserver-port` flags (and probably the
`--gdbserver-port` flag, but I didn't test it).

How the platform code seems to work is that it listens on a port, and
whenever there's an incoming connection, it forks the process to handle
the connection. To handle the port flags, the main process uses an
instance of the helper class
`GDBRemoteCommunicationServerPlatform::PortMap`, that can be configured
and track usages of ports. The child process handling the platform
connection, can then use the port map to allocate a port for the
gdb-server connection it will make (this is another process it spawns).

However, in the current code, this works only once. After the first
connection is handled by forking a child process, the main platform
listener code loops around, and then 'forgets' about the port map. This
is because this code:
```cpp
GDBRemoteCommunicationServerPlatform platform(
    acceptor_up->GetSocketProtocol(), acceptor_up->GetSocketScheme());
if (!gdbserver_portmap.empty()) {
  platform.SetPortMap(std::move(gdbserver_portmap));
}
```
is within the connection listening loop. This results in the
`gdbserver_portmap` being moved into the platform object at the
beginning of the first iteration of the loop, but on the second
iteration, after the first fork, the next instance of the platform
object will not have its platform port mapped.
The result of this bug is that subsequent connections to the platform,
when spawning the gdb-remote connection, will be supplied a random port
- which isn't bounded by the `--min-gdbserver-port` and
`--max-gdbserver--port` parameters passed in by the user.

This PR fixes this issue by having the port map be maintained by the
parent platform listener process. On connection, the listener allocates
a single available port from the port map, associates the child process
pid with the port, and lets the connection handling child use that
single port number.

Additionally, when cleaning up child processes, the main listener
process tracks the child that exited to deallocate the previously
associated port, so it can be reused for a new connection.
2024-05-07 09:45:07 +01:00
David Spickett
e19f722141
[lldb][Docs] Use proper LLDB/GDB project branding in tutorial (#90712)
Except when referring to the program binaries.
2024-05-02 08:45:48 +01:00
David Spickett
eb6097a79e
[lldb][Docs] Various style improvements to the tutorial (#90594)
* Replace "we" with either "you" (when talking to the reader) or "lldb"
(when talking about the project).
* Refer to lldb as lldb not LLDB, to match what the user sees on
the command line (I am going to come back later and put the proper name in places where it's talking about the projects themselves)
* Remove a bunch of contractions for example "won't". Which don't (pun
intended) seem like a big deal at first but even I as a native English
speaker find the text clearer with them expanded.
* Use RST's plain text highlighting for keywords and command names.
* Split some very long lines for easier editing in future.
2024-05-01 10:00:12 +01:00
Dave Lee
0f628fdb1a Revert "[lldb] Support custom LLVM formatting for variables (#81196)"
This reverts commit 7a8d15e919dde70118dbfa34e927be1705ded67d.
2024-04-30 16:15:19 -07:00
Dave Lee
7a8d15e919
[lldb] Support custom LLVM formatting for variables (#81196)
Adds support for applying LLVM formatting to variables.

The reason for this is to support cases such as the following.

Let's say you have two separate bytes that you want to print as a
combined hex value. Consider the following summary string:

```
${var.byte1%x}${var.byte2%x}
```

The output of this will be: `0x120x34`. That is, a `0x` prefix is
unconditionally applied to each byte. This is unlike printf formatting
where you must include the `0x` yourself.

Currently, there's no way to do this with summary strings, instead
you'll need a summary provider in python or c++.

This change introduces formatting support using LLVM's formatter system.
This allows users to achieve the desired custom formatting using:

```
${var.byte1:x-}${var.byte2:x-}
```

Here, each variable is suffixed with `:x-`. This is passed to the LLVM
formatter as `{0:x-}`. For integer values, `x` declares the output as
hex, and `-` declares that no `0x` prefix is to be used. Further, one
could write:

```
${var.byte1:x-2}${var.byte2:x-2}
```

Where the added `2` results in these bytes being written with a minimum
of 2 digits.

An alternative considered was to add a new format specifier that would
print hex values without the `0x` prefix. The reason that approach was
not taken is because in addition to forcing a `0x` prefix, hex values
are also forced to use leading zeros. This approach lets the user have
full control over formatting.
2024-04-30 10:45:10 -07:00
jimingham
b6dfaf4c29
Make the correct (5 argument) form of the command definition be the primary one suggested in the docs (#86593)
This has been available for years now, so it should be safe to always
use it.
2024-03-25 16:06:51 -07:00
David Spickett
ae92f6e8ae [lldb][Docs] Remove unnecessary colon in title 2024-02-05 15:25:16 +00:00