Commit Graph

192 Commits

Author SHA1 Message Date
royitaqi
0e0ea714f3 [vscode-lldb] Add VS Code commands for high level debug workflow (#151827)
This allows other debugger extensions to leverage the `lldb-dap`
extension's settings and logic (e.g. "Server Mode").

Other debugger extensions can invoke these commands to resolve
configuration, create adapter descriptor, and get the `lldb-dap` process
for state tracking, additional interaction, and telemetry.

VS Code commands added:
* `lldb-dap.resolveDebugConfiguration`
* `lldb-dap.resolveDebugConfigurationWithSubstitutedVariables`
* `lldb-dap.createDebugAdapterDescriptor`
* `lldb-dap.getServerProcess`
2025-08-06 11:42:21 -07:00
Jonas Devlieghere
f62370290a [lldb] Implement RegisterContextWasm (#151056)
This PR implements a register context for Wasm, which uses virtual
registers to resolve Wasm local, globals and stack values. The registers
are used to implement support for `DW_OP_WASM_location` in the DWARF
expression evaluator (#151010). This also adds a more comprehensive
test, showing that we can use this to show local variables.
2025-07-30 19:51:09 -07:00
Jonas Devlieghere
a28e7f1aad [lldb] Add WebAssembly Process Plugin (#150143)
Extend support in LLDB for WebAssembly. This PR adds a new Process
plugin (ProcessWasm) that extends ProcessGDBRemote for WebAssembly
targets. It adds support for WebAssembly's memory model with separate
address spaces, and the ability to fetch the call stack from the
WebAssembly runtime.

I have tested this change with the WebAssembly Micro Runtime (WAMR,
https://github.com/bytecodealliance/wasm-micro-runtime) which implements
a GDB debug stub and supports the qWasmCallStack packet.

```
(lldb) process connect --plugin wasm connect://localhost:4567
Process 1 stopped
* thread #1, name = 'nobody', stop reason = trace
    frame #0: 0x40000000000001ad
wasm32_args.wasm`main:
->  0x40000000000001ad <+3>:  global.get 0
    0x40000000000001b3 <+9>:  i32.const 16
    0x40000000000001b5 <+11>: i32.sub
    0x40000000000001b6 <+12>: local.set 0
(lldb) b add
Breakpoint 1: where = wasm32_args.wasm`add + 28 at test.c:4:12, address = 0x400000000000019c
(lldb) c
Process 1 resuming
Process 1 stopped
* thread #1, name = 'nobody', stop reason = breakpoint 1.1
    frame #0: 0x400000000000019c wasm32_args.wasm`add(a=<unavailable>, b=<unavailable>) at test.c:4:12
   1    int
   2    add(int a, int b)
   3    {
-> 4        return a + b;
   5    }
   6
   7    int
(lldb) bt
* thread #1, name = 'nobody', stop reason = breakpoint 1.1
  * frame #0: 0x400000000000019c wasm32_args.wasm`add(a=<unavailable>, b=<unavailable>) at test.c:4:12
    frame #1: 0x40000000000001e5 wasm32_args.wasm`main at test.c:12:12
    frame #2: 0x40000000000001fe wasm32_args.wasm
```

This PR is based on an unmerged patch from Paolo Severini:
https://reviews.llvm.org/D78801. I intentionally stuck to the
foundations to keep this PR small. I have more PRs in the pipeline to
support the other features/packets.

My motivation for supporting Wasm is to support debugging Swift compiled
to WebAssembly:
https://www.swift.org/documentation/articles/wasm-getting-started.html
2025-07-29 10:07:13 -07:00
Chelsea Cassanova
4396c87bfe [lldb][docs] Update instructions to build standalone (#137383)
The instructions to build LLDB standalone contain a CMake configure step
to build LLVM standalone. This configure step needs to also have the
CMake build type in order to work.
2025-07-24 12:43:52 -07:00
David Spickett
9f364fe9c4 [lldb][docs] Add section on testing with QEMU user (#149057)
This is not recommended to basically anyone but on occasion it's useful
and could be used for testing with other simulator programs for example
bare metal simulators.

It is not something we do officially support or make any quality
guarantees for.

Adding this is also an excuse to document the limitations and make the
time spent setting up system mode look more worthwhile and might be good
to cite in future discussions about testing in simulation.
2025-07-16 17:47:21 +01:00
David Spickett
97922a7d40 [lldb][docs] Add CAMKE_BUILD_TYPE to standlone build instructions
The first stage requires it, the second appears to default to
debug mode, which works but it's better we advise release mode
to match.
2025-07-16 16:44:40 +00:00
Kazu Hirata
9f5061d4f0 [lldb] Fix a typo in documentation (#146115) 2025-06-27 14:26:32 -07:00
David Spickett
d59e0ba80b [lldb][docs] Document qWatchpointSupportInfo (#145709) 2025-06-26 13:41:33 +01:00
Pavel Labath
46e1e9f104 Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (#145305)
The only difference from the original PR are the added BRIEF and
FULL_DOCS arguments to define_property, which are required for
cmake<3.23.
2025-06-24 11:10:35 +02:00
Pavel Labath
18f667d804 Revert "[lldb/cmake] Plugin layering enforcement mechanism (#144543)"
Causes failures on several bots.

This reverts commits 714b2fdf3a and
e7c1da7c8e.
2025-06-23 12:07:10 +02:00
Pavel Labath
e7c1da7c8e [lldb/cmake] Plugin layering enforcement mechanism (#144543)
Some inter-plugin dependencies are okay, others are not. Yet others not,
but we're sort of stuck with them. The idea is to be able to prevent
backsliding while making sure that acceptable dependencies are..
accepted. For context, see
https://github.com/llvm/llvm-project/pull/139170 and the attached
changes to the documentation.
2025-06-23 11:31:26 +02:00
Kazu Hirata
bdf8c9984a [lldb] Fix typos in documentation (#139839) 2025-05-13 23:34:28 -07:00
David Spickett
62385b8487 [lldb][docs] Correct spelling in debugging doc 2025-05-07 10:07:02 +00:00
David Spickett
382263376f [lldb][docs] Repeat required Python version number
We do say it in the table below but if you didn't
want any optional stuff you'd miss it.
2025-04-22 08:53:01 +00:00
Julius Alexandre
5757da1480 [lldb][docs] Added LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS for macOS configuration (#130381)
Referenced here:
https://github.com/llvm/llvm-project/issues/130171#issuecomment-2707058235

I think this will allow for issues relating towards missing modules for
test suites to be more manageable.

cc @adrian-prantl

---------

Co-authored-by: medievalghoul <61852278+medievalghoul@users.noreply.github.com>
2025-03-10 15:23:49 -07:00
Pavel Labath
ad38c4c625 [lldb] Document lldb x packet deprecation. (#125682) 2025-02-05 09:26:26 +01:00
David Spickett
5d738b2be0 [lldb][Docs] Expand remote testing instructions (#122694)
There's a lot of fiddly bits to get right here, so I've added a more
complete example and explained why you might choose one method over
another.

I thought about adding this to the qemu testing page, as that's what we
(Linaro) use this for mostly, but it applies to any remote system
whether hardware or simulator.
2025-02-03 09:10:20 +00:00
David Spickett
9ea64dd878 [lldb] Make Python >= 3.8 required for LLDB 21 (#124735)
As decided on
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731.

LLDB 20 recommended `>= 3.8` but did not remove support for anything
earlier. Now we are in what will become LLDB 21, so I'm removing that
support and making
`>= 3.8` required.

See https://docs.python.org/3/c-api/apiabiversion.html#c.PY_VERSION_HEX
for the format of PY_VERSION_HEX.
2025-01-29 09:56:41 +00:00
Adrian Prantl
ee1adc5aab [lldb] Add a return opcode to the formatter bytecode (#121602)
In LLVM we love our early exists and this opcode allows for simpler code
generation.
2025-01-03 15:26:40 -08:00
Adrian Prantl
9ee454a57c [lldb] Fix RST table formatting 2024-12-16 10:42:37 -08:00
Adrian Prantl
fffe8c6684 [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples
This PR adds a proof-of-concept for a bytecode designed to ship and
run LLDB data formatters. More motivation and context can be found in
the formatter-bytecode.rst file and on discourse.

https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696

Relanding with a fix for a case-sensitive path.
2024-12-06 16:27:16 -08:00
Adrian Prantl
b504c8771f Revert "[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples"
This reverts commit 60380cd27c.
2024-12-06 16:26:55 -08:00
Adrian Prantl
60380cd27c [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples
This PR adds a proof-of-concept for a bytecode designed to ship and
run LLDB data formatters. More motivation and context can be found in
the formatter-bytecode.rst file and on discourse.

https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696

Relanding with a fix for a case-sensitive path.
2024-12-06 16:10:09 -08:00
Adrian Prantl
8ab76a47b2 Revert "[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples"
This reverts commit 7e3da87ca896484a11ac09df297183147154ac91.

I managed to break the bots.
2024-12-06 15:34:12 -08:00
Adrian Prantl
0ee364d2a2 [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (#113398)
This PR adds a proof-of-concept for a bytecode designed to ship and run
LLDB data formatters. More motivation and context can be found in the
`formatter-bytecode.md` file and on discourse.

https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696
2024-12-06 15:11:21 -08:00
David Spickett
3ce0dbb718 [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (#114807)
See
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will be
a CMake warning telling builders that from LLDB 21 this will be a hard
requirement. From LLDB 21, it will be an error to try to build with
anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch is
created we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new
warnings or errors from this change.
2024-11-12 10:49:16 +00:00
Jonas Devlieghere
e19d740169 [lldb] Support both Lua 5.3 and Lua 5.4 (#115500)
Lua 5.3 and Lua 5.4 are similar enough that we can easily support both
in LLDB. This patch adds support for building LLDB with both and updates
the documentation accordingly.
2024-11-11 08:11:03 -08:00
Jonas Devlieghere
2ab98dfe19 [lldb] Update link to GreenDragon in the docs 2024-10-29 09:45:29 -07:00
Michael Buch
7b703bd3e7 [lldb][docs] Fix "Developing LLDB" table of contents (#113166)
Currently all the headings marked as `#` show up
as a top-level entry in the `Developing LLDB`
toctree. This patch marks these as `##` so only
`Adding Programming Language Support` is displayed
in the table of contents.
2024-10-21 22:19:26 +01:00
Jonas Devlieghere
6e02e19cd3 [lldb][docs] Add JSON symbol file docs to the ToC 2024-10-18 14:22:54 -07:00
Jonas Devlieghere
7437f3ef7e [lldb] Document SymbolFileJSON (#112938)
I've had multiple request for documentation about the JSON symbol file
format that LLDB supports. This patch documents the structure and
fields, shows a handful of examples and explains how to use it in LLDB.
2024-10-18 13:24:15 -07:00
Vladislav Dzhidzhoev
32e90bbe57 [lldb][test] Support remote run of Shell tests (#95986)
1. This commit adds LLDB_TEST_PLATFORM_URL, LLDB_TEST_SYSROOT,
LLDB_TEST_PLATFORM_WORKING_DIR, LLDB_SHELL_TESTS_DISABLE_REMOTE cmake
flags to pass arguments for cross-compilation and remote running of both Shell&API tests.
2. To run Shell tests remotely, it adds 'platform select' and 'platform connect' commands to %lldb
substitution.
3. 'remote-linux' feature added to lit to disable tests failing with
remote execution.
4. A separate working directory is assigned to each test to avoid
conflicts during parallel test execution.
5. Remote Shell testing is run only when LLDB_TEST_SYSROOT is set for
building test sources. The recommended compiler for that is Clang.

---------

Co-authored-by: Vladimir Vereschaka <vvereschaka@accesssoftek.com>
2024-10-07 20:31:33 +02:00
Adrian Vogelsgesang
6c137b75f3 [lldb-dap][docs] Improve documentation for contributors (#110987)
This commit extends the developer docs for `lldb-dap`. It also adds a
short "Contributing" section to the user-facing README.

Last but not least, it updates the `repository` in the package.json to
point to the actual source of truth for the source code, instead of
pointing to its mirrored repository. I hope that the VS Code Marketplace
properly supports the `directory` property. Unfortunately, I have no way
to test this before merging this Pull Request.
2024-10-03 19:51:34 +02:00
Dmitry Vasilyev
2e89312419 [lldb] Removed gdbserver ports map from lldb-server (#104238)
Listen to gdbserver-port, accept the connection and run `lldb-server gdbserver --fd` on all platforms.
Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of #101283.

Fixes #97537.
2024-10-03 21:00:47 +04:00
David Spickett
a3cf01d585 [lldb][docs] Resurrect the information on adding a new language (#109427)
This got deleted in e078c9507c, I presume
accidentally, because it didn't have a corresponding rst file for it.

So I've brought it back and converted it into Markdown. The content
remains accurate, from what I know at least.

It's a bit "now draw the rest of the owl" but if nothing else, it gives
you a bunch of important classes to go and research as a starting point.

You can see the original content here:
5d71fc5d7b/lldb/www/adding-language-support.html
2024-09-24 11:21:24 +01:00
jimingham
02d8813820 Add a comment in the SB API doc about keeping the SB API's lightweight. (#108462) 2024-09-13 10:18:03 -07:00
David Spickett
77b388cfc6 [lldb][Docs] Fix broken link to qemu testing page 2024-09-06 09:31:19 +01:00
Jason Molenda
2ba1aeed2e [lldb] Don't use a vm addr range starting at 0 for local memory (#100288)
When an inferior stub cannot allocate memory for lldb, and lldb needs to
store the result of expressions, it will do it in lldb's own memory
range ("host memory"). But it needs to find a virtual address range that
is not used in the inferior process. It tries to use the
qMemoryRegionInfo gdb remote serial protocol packet to find a range that
is inaccessible, starting at address 0 and moving up the size of each
region.

If the first region found at address 0 is inaccessible, lldb will use
the address range starting at 0 to mean "read lldb's host memory, not
the process memory", and programs that crash with a null dereference
will have poor behavior.

This patch skips consideration of a memory region that starts at address
0.

I also clarified the documentation of qMemoryRegionInfo to make it clear
that the stub is required to provide permissions for a memory range that
is accessable, it is not an optional key in this response. This issue
was originally found by a stub that did not list permissions in its
response, and lldb treated the first region returned as the one it would
use. (the stub also didn't support the memory-allocate packet)
2024-07-24 17:25:57 -07:00
David Spickett
d4a89af5a8 [lldb][Docs] Move QEMU testing page into the developing lldb section 2024-07-16 13:08:04 +01:00
Aaron Siddhartha Mondal
852aaf5407 Reapply "[Support] Remove terminfo dependency (#92865)" (#93889)
This reverts commit fe82a3da36.

This broke LLDB on MacOS due to a missing symbol during linking.

The fix has been applied in c6c08eee37.

Original commit message:

The terminfo dependency introduces a significant nonhermeticity into the
build. It doesn't respect `--no-undefined-version` meaning that it's not
a dependency that can be built with Clang 17+. This forces maintainers
of source-based distributions to implement patches or ignore linker
errors.

Remove it to reduce the closure size and improve portability of
LLVM-based tools. Users can still use command line arguments to toggle
color support expliticly.

Fixes #75490
Closes #53294 #23355
2024-05-31 01:29:00 +02:00
Michael Buch
fe82a3da36 Revert "[Support] Remove terminfo dependency (#92865)"
This reverts commit 6bf450c7a6.

It breaks LLDB CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4762/execution/node/97/log/

```
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=14.1 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-no_warn_duplicate_libraries tools/lldb/unittests/Editline/CMakeFiles/EditlineTests.dir/EditlineTest.cpp.o -o tools/lldb/unittests/Editline/EditlineTests  lib/libLLVMSupport.a  lib/libllvm_gtest_main.a  lib/libllvm_gtest.a  lib/liblldbHost.a  lib/liblldbUtility.a  lib/libLLVMTestingSupport.a  /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libxml2.tbd  /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd  lib/liblldbHostMacOSXObjCXX.a  lib/liblldbUtility.a  -framework Foundation  -framework CoreFoundation  -framework CoreServices  -framework Security  lib/libLLVMObject.a  lib/libLLVMIRReader.a  lib/libLLVMBitReader.a  lib/libLLVMAsmParser.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libllvm_gtest.a  lib/libLLVMSupport.a  -lm  /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libz.tbd  /opt/homebrew/lib/libzstd.dylib  lib/libLLVMDemangle.a  -lpthread && cd /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline && /opt/homebrew/Cellar/cmake/3.28.3/bin/cmake -E make_directory /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline/./Inputs
ld: Undefined symbols:
  _setupterm, referenced from:
      lldb_private::Editline::Editline(char const*, __sFILE*, __sFILE*, __sFILE*, std::__1::recursive_mutex&) in liblldbHost.a[35](Editline.cpp.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
2024-05-29 16:20:42 +01:00
Aaron Siddhartha Mondal
6bf450c7a6 [Support] Remove terminfo dependency (#92865)
The terminfo dependency introduces a significant nonhermeticity into the
build. It doesn't respect `--no-undefined-version` meaning that it's not
a dependency that can be built with Clang 17+. This forces maintainers
of source-based distributions to implement patches or ignore linker
errors.

Remove it to reduce the closure size and improve portability of
LLVM-based tools. Users can still use command line arguments to toggle
color support expliticly.

Fixes #75490
Closes #53294 #23355
2024-05-24 20:20:15 +02:00
Jonas Devlieghere
525bd66fc2 [lldb-dap] Separate user and developer documentation (#92428)
The README.md is what users see when they look for the extension in the
Marketplace [1]. Right now, it's a mix of developer documentation (for
us) and user documentation. This commit moves the developer docs into
`docs` and the lldb website and refocuses the README on using the
extension.

[1] https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap
2024-05-16 10:41:06 -07:00
David Spickett
b6f050fa12 [lldb] Document some more packets (#92124)
Comparing a bit of the mock GDB server code to what was in the document
I found these:
* QLaunchArch
* qSpeedTest
* qSymbol

qSymbol is the most mysterious but it did have some examples in a
comment so I've adapted that.
2024-05-15 11:20:58 +01:00
David Spickett
0c42fa361d [lldb][Docs] Sort documented packets alphabetically (#90584)
For the platform and extension doc.

Also add links in the extension doc to the GDB specs we're extending.
2024-05-01 08:57:52 +01:00
David Spickett
ff6c0cac70 [lldb][Docs] Remove more subtitles from packets doc (#90443)
This removes various subtitles or converts them to bold text so that the
table of contents is less cluttered.

This includes "Example", "Notes", "Priority To Implement" and
"Response".
2024-04-30 08:14:12 +01:00
David Spickett
41942c852e [lldb[Docs] Reduce title noise in packets doc (#90183)
This removes the "Brief" and "Description" subtitles and merges the text
of both so that the contents listing is clearer.
2024-04-29 08:40:09 +01:00
David Spickett
bd53c7cce4 [lldb][Docs] Document vFile "MD5" and "exists"
This is a Markdown version of https://github.com/llvm/llvm-project/pull/89357.
2024-04-26 09:45:17 +01:00
David Spickett
c4b28bf903 [lldb][Docs] Link from platform doc to extensions doc (#90029)
So we aren't describing the same packets twice. Basically turning the
platform doc into a list of cross links.

qLaunchSuccess was missing a description so I added one.
2024-04-26 09:33:29 +01:00
David Spickett
51f6570eba [lldb][Docs] Convert platform packets doc to Markdown (#89913)
As before, script did most of the work, hand edits after that.

There's a lot more we can do dedupe this and the packets doc, this will
come in a follow up PR.
2024-04-25 08:49:57 +01:00