124 Commits

Author SHA1 Message Date
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
Jason Molenda
a3fe9221ab
Remove hardware index from watchpoints and breakpoints (#72012)
The Watchpoint and Breakpoint objects try to track the hardware index
that was used for them, if they are hardware wp/bp's. The majority of
our debugging goes over the gdb remote serial protocol, and when we set
the watchpoint/breakpoint, there is no (standard) way for the remote
stub to communicate to lldb which hardware index was used. We have an
lldb-extension packet to query the total number of watchpoint registers.

When a watchpoint is hit, there is an lldb extension to the stop reply
packet (documented in lldb-gdb-remote.txt) to describe the watchpoint
including its actual hardware index,

<addr within wp range> <wp hw index> <actual accessed address>

(the third field is specifically needed for MIPS). At this point, if the
stub reported these three fields (the stub is only required to provide
the first), we can know the actual hardware index for this watchpoint.

Breakpoints are worse; there's never any way for us to be notified about
which hardware index was used. Breakpoints got this as a side effect of
inherting from StoppointSite with Watchpoints.

We expose the watchpoint hardware index through "watchpoint list -v" and
through SBWatchpoint::GetHardwareIndex.

With my large watchpoint support, there is no *single* hardware index
that may be used for a watchpoint, it may need multiple resources. Also
I don't see what a user is supposed to do with this information, or an
IDE. Knowing the total number of watchpoint registers on the target, and
knowing how many Watchpoint Resources are currently in use, is helpful.
Knowing how many Watchpoint Resources
a single user-specified watchpoint needed to be implemented is useful.
But knowing which registers were used is an implementation detail and
not available until we hit the watchpoint when using gdb remote serial
protocol.

So given all that, I'm removing watchpoint hardware index numbers. I'm
changing the SB API to always return -1.
2023-11-15 13:32:42 -08:00
David Spickett
d3fb05ba10
[lldb][AArch64][Linux] Add SME2 release notes and usage docs (#70935)
ZT0 is much like ZA apart from not being scalable, so there's not much
new to cover.
2023-11-08 09:23:02 +00:00
David Spickett
42c25fddcb [lldb][docs][AArch64] Update example in SME docs
This output has now changed because I moved the za register
into the main SME register set.
2023-10-25 13:12:37 +00:00
David Spickett
bb826951dc
[lldb][AArch64] Add release notes and documentation for SME (#66767)
This adds a release note for all the SME support now in LLDB and a page
where I have documented the user experience (for want of a better term)
when using SVE and SME.

This includes things like which mode transitions can or cannot be
triggered from within LLDB. I hope this will serve to A: document what
I've implemented and B: be a user's guide to these extensions.

(though it is not a design document, read the commits and code for that
sort of detail)
2023-10-20 14:06:06 +01:00
David Spickett
f47914a7cd [lldb][Docs] Use RST link format in IntelPT doc 2023-10-09 08:21:21 +01:00
David Spickett
21030b9ab4 [lldb][Docs] Add section on using QEMU without bridge networking
Bridge network means that you can get to any port on the VM,
from the host, which is great. However it is quite involved to
setup in some cases, and I've certainly messed it up in the past.

An alternative is forwarding a block of ports and using some
hidden options to lldb-server to limit what it uses. This
commit documents that and the pitfall that the port list isn't shared.

The theory also works for Arm's FVP (which inspired me to write
this up) but since QEMU is the preferred option upstream, it goes
in that document.

Along the way I fixed a link to the QEMU page that used the URL
not a relative link to the document.
2023-10-06 15:28:10 +01:00
Author: Eddie Phillips
9ce82a10a3 Wrong link target in the documentation #62990
In the LDDB documentation you have the following sentence:

"The --format (which you can shorten to -f) option accepts a format name."

The link points to the wrong place.

I pointed it to the table that precedes the Type summary section.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D151668
2023-09-08 15:38:28 +01:00
Jonas Devlieghere
3aa678a777
[lldb/docs] Add section links to the top of the GDB to LLDB command map
Add section links to the top of the GDB to LLDB command map. This makes
navigating the page easier.
2023-09-07 16:26:53 -07:00
Kazu Hirata
5dd9568717 Fix typos in documentation 2023-09-02 09:32:48 -07:00
Med Ismail Bennani
6a2552a141 [lldb/infra] Revamp lldb.llvm.org
This patch brings a fresh coat of paint to the LLDB website.

This uses the `furo` theme from the suggested theme list, adds some
changes to the css to make it use the full browser window width and
removes the table of contents since the theme generates it automatically.

This patch also rewrites the tables for "GDB to LLDB command map" to
convert them from raw HTML to native inlined code blocks.

To generate the website, make sure you install the theme first with
`pip install furo`, enable sphinx in the cmake invocation` then run
`ninja docs-lldb-html`

Discourse: https://discourse.llvm.org/t/rfc-revamping-lldbs-website

Differential Revision: https://reviews.llvm.org/D158323

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-26 09:54:56 +01:00
Med Ismail Bennani
dfb48dcc9c Revert "[lldb/infra] Revamp lldb.llvm.org"
This patch reverts the lldb website revamp (eea8874) since the `furo` theme
that we use is not installed on the publisher bot. The prevents other
website from getting there documentation updated.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-24 19:44:16 +01:00
Med Ismail Bennani
eea8874064 [lldb/infra] Revamp lldb.llvm.org
This patch brings a fresh coat of paint to the LLDB website.

This uses the `furo` theme from the suggested theme list, adds some
changes to the css to make it use the full browser window width and
removes the table of contents since the theme generates it automatically.

This patch also rewrites the tables for "GDB to LLDB command map" to
convert them from raw HTML to native inlined code blocks.

To generate the website, make sure you install the theme first with
`pip install furo`, enable sphinx in the cmake invocation` then run
`ninja docs-lldb-html`

Discourse: https://discourse.llvm.org/t/rfc-revamping-lldbs-website

Differential Revision: https://reviews.llvm.org/D158323

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-24 15:41:16 +01:00
Jonas Devlieghere
3e3880e370
[lldb] Simplify the LLDB website structure
Feedback I hear regularly is that the LLDB website is hard to navigate.
This patch is an attempt to simplify things by breaking the website up
in 3 major areas: "Using LLDB", "Scripting LLDB" and "Developing LLDB".

  - The majority of the "project" pages were eliminated. The projects
    page was moved under "Developing LLDB". The releases page was
    replaced with a link under "External links". The other pages (goals,
    features and status) were pretty outdated and while they probably
    made sense in the past, they don't feel all that relevant anymore
    now that LLDB is an established debugger.

  - "USE & EXTENSION" was renamed to "Using LLDB". Besides that, this
    section remained mostly unchanged. The exception are the Python
    pages which were moved under "Scripting LLDB".

  - "Development" was renamed to "Developing LLDB" and now houses all the
    resources for LLDB developers. The old "Design" section (which only
    contained two pages) was moved back under here too.

Differential revision: https://reviews.llvm.org/D158023
2023-08-18 11:20:20 -07:00
David Spickett
01e30b30d0 [lldb][AArch64] Add Scalable Matrix Extension option to QEMU launch script
The Scalable Matrix Extension (SME) does not require extra options
beyond setting the cpu to "max".

https://qemu-project.gitlab.io/qemu/system/arm/cpu-features.html#sme-cpu-property-examples

SME depends on SVE, so that will be enabled too even if you don't ask
for it by name.

--sve --sme -> SVE and SME
--sme       -> SVE and SME
--sve       -> Only SVE

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D152519
2023-06-14 14:33:47 +01:00
Kazu Hirata
23e26cb98d [lldb] Fix typos in documentation 2023-05-23 22:10:59 -07:00
Jim Ingham
d98086036a Add usage info for backtick to the lldb tutorial. 2023-02-02 13:47:12 -08:00
Saagar Jha
93ccccb00d
[lldb] Fix typos and update "GDB To LLDB Command Map" to be a bit more clear
I've gone through the GDB To LLDB Command Map and tried to improve it:

 - Fix obvious typos (e.g. <cope> → <code>)
 - Wrap code and program names in <code> tags
 - Reword a couple parts where (IMHO) the phrasing could be a bit better

Differential revision: https://reviews.llvm.org/D28758
2023-01-15 11:10:52 -08:00
Jorge Gorbe Moya
868186cf6c [lldb] Make callback-based formatter matching available from the CLI.
This change adds a `--recognizer-function` (`-R`) to `type summary add`
and `type synth add` that allows users to specify that the names in
the command are not type names but python function names.

It also adds an example to lldb/examples, and a section in the data
formatters documentation on how to use recognizer functions.

Differential Revision: https://reviews.llvm.org/D137000
2022-11-10 10:29:38 -08:00
Michael Buch
2a812bdc70 [lldb][Docs][NFC] Fix sphinx warnings/errors for LLDB docs
Ran `ninja docs-lldb-html` and made sure the docs are fixed.

Differential Revision: https://reviews.llvm.org/D136766
2022-10-28 11:31:15 +01:00
David Spickett
6cc5bcc12d [LLDB] Correct env vars for Android port selection
These should have "LOCAL" in them.

First added in 1e210abf9925ad08fb7c79894b4ec5ef8f0ef173.
2022-10-26 12:31:27 +00:00