156 Commits

Author SHA1 Message Date
Jonas Devlieghere
d654d37c86
[lldb-dap] Correctly report breakpoints as resolved on macOS (#129589)
On macOS, breakpoints are briefly unresolved between process launch and
when the dynamic loader has informed us about the loaded libraries. This
information was being forwarded by lldb-dap, but only partially. In the
event handler, we were listening for the `LocationsAdded` and
`LocationsRemoved` breakpoint events. For the scenario described above,
the latter would trigger and we'd send an event reporting the breakpoint
as unresolved. The problem is that when the breakpoint location is
resolved again, you receive a `LocationsResolved` event, not a
`LocationsAdded` event. As a result, the breakpoint would continue to
show up as unresolved in the DAP client.

I found a test that tried to test part of this behavior, but the test
was broken and disabled. I revived the test and added coverage for the
situation described above.

Fixes #112629
rdar://137968318
2025-03-03 18:56:21 -06:00
Da-Viper
8ec0d60e28
[lldb-dap] Add: show return value on step out (#106907)
https://github.com/user-attachments/assets/cff48c6f-37ae-4f72-b881-3eff4178fb3c
2025-03-01 18:21:21 -06:00
John Harrison
a3ac1f2278
[lldb-dap] Adding server mode support to lldb-dap VSCode extension. (#128957)
This adds support for launching lldb-dap in server mode. The extension
will start lldb-dap in server mode on-demand and retain the server until
the VSCode window is closed (when the extension context is disposed).
While running in server mode, launch performance for binaries is greatly
improved by improving caching between debug sessions.

For example, on my local M1 Max laptop it takes ~5s to attach for the
first attach to an iOS Simulator process and ~0.5s to attach each time
after the first.
2025-02-28 10:49:24 -08:00
Jonas Devlieghere
fb191efa70
[lldb-dap] Adaptor -> Adapter (NFC) (#129110)
Both spellings are considered correct and acceptable, with adapter being
more common in American English. Given that DAP stands for Debug Adapter
Protocol (with an e) let's go with that as the canonical spelling.
2025-02-27 19:56:56 -06:00
Jonas Devlieghere
8f8529c137
[lldb-dap] Gardening in lldb-dap.cpp (NFC) (#128949)
- Remove more unused includes
 - Limit anonymous namespace to llvm::opt
 - Fix code style
2025-02-27 12:42:54 -06:00
Jonas Devlieghere
f409340cc2
[lldb-dap] Return an llvm::Error instead of calling exit directly (NFC) (#128951)
Return an `llvm::Error` from `LaunchRunInTerminalTarget` instead of
calling `exit()` directly.
2025-02-26 18:34:21 -06:00
John Harrison
1e246704e2
[lldb-dap] Use existing lldb::IOObjectSP for DAP IO (NFC). (#128750)
This simplifies the IOStream.cpp implementation by building on top of
the existing lldb::IOObjectSP.

Additionally, this should help ensure clients connected of a
`--connection` specifier properly detect shutdown requests when the
Socket is closed. Previously, the StreamDescriptor was just accessing
the underlying native handle and was not aware of the `Close()` call to
the Socket itself.

This is both nice to have for simplifying the existing code and this
unblocks an upcoming refactor to support the cancel request.

---------

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-02-26 11:29:13 -08:00
Jonas Devlieghere
317461ed61
[lldb-dap] Avoid a std::string allocation for the help output (NFC)
Don't create a temporary `std::string` for the help output, just write
it to `llvm::outs()` directly.
2025-02-26 11:56:23 -06:00
Jonas Devlieghere
66af4923ce
[lldb-dap] Refactor reverse request response handlers (NFC) (#128594)
This refactors the response handlers for reverse request to follow the
same architecture as the request handlers. With only two implementation
that might be overkill, but it reduces code duplication and improves
error reporting by storing the sequence ID. This PR also fixes an
unchecked Expected in the old callback for unknown sequence IDs.
2025-02-25 13:00:26 -06:00
Jonas Devlieghere
f6a3002124
[lldb-dap] Remove unused headers (NFC) 2025-02-24 17:05:22 -06:00
John Harrison
162eb32e74
[lldb-dap] Add 'source' references to stack frames without source files. (#128268)
This adds 'source' references to all stack frames. When opening a stack
frame users will see the disassembly of the frame if the source is not
available.

This works around the odd behavior of navigating frames without the
VSCode disassembly view open, which causes 'step' to step in the first
frame with a source instead of the active frame.

This fixes #128260

Old behavior:

https://github.com/user-attachments/assets/3f40582d-ac96-451a-a5ae-498a323bf30e

New behavior:

https://github.com/user-attachments/assets/3a3f9ac6-3e6c-4795-9bb2-1132b3916b6f

---------

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-02-24 14:56:28 -08:00
Jonas Devlieghere
911e94c651
[lldb-dap] Finish refactoring the request handlers (NFC) (#128553)
Completes the work started in #128262. This PR removes the
old way of register request handlers with callbacks and makes
the operator const.
2025-02-24 16:46:12 -06:00
John Harrison
e8f1623a22
[lldb-dap] Addressing the order of events during disconnect to flush output. (#128583)
The TestDAP_ouput test is flaky due to the order of events during
shutdown. We were stopping the output and error handle redirection after
we finished the disconnect request, which can cause us to miss output
events due to timing. Moving when we stop the redirection to ensure we
have consistent output prior to disconnect responding.

Fixes #128567
2025-02-24 14:41:19 -08:00
Jonas Devlieghere
38d7cf1a81
[lldb-dap] Refactor remaining request handlers (NFC)Remaining request handlers (#128551)
Continuation of the work started in #128262. Builds on top of #128550.
2025-02-24 15:56:13 -06:00
Jonas Devlieghere
d362319404
[lldb-dap] Refactor breakpoint related request handlers (NFC) (#128550)
Continuation of the work started in #128262. Builds on top of #128549.
2025-02-24 15:40:31 -06:00
Jonas Devlieghere
988480323d
[lldb-dap] Refactor custom & testing related request handlers (NFC) (#128549)
Continuation of the work started in
https://github.com/llvm/llvm-project/pull/128262. Builds on top of
#128453.
2025-02-24 14:06:00 -06:00
Jonas Devlieghere
82264d23a1
[lldb-dap] Refactor stepping related request handlers (NFC) (#128453)
Continuation of the work started in #128262.
2025-02-24 13:50:11 -06:00
Jonas Devlieghere
51ce6c437f
[lldb-dap] Fix error C2065: 'PATH_MAX': undeclared identifier
This should fix the Windows build.
2025-02-24 12:16:05 -06:00
Jonas Devlieghere
d0e37d9723
[lldb-dap] Refactor request handlers (NFC) (#128262)
Currently, all request handlers are implemented as free functions in
lldb-dap.cpp. That file has grown to over 5000 lines and is starting to
become hard to maintain. This PR moves the request handlers into their
own class (and file), together with their documentation.

This PR migrates about a third of the request handlers and the rest will
be migrated in subsequent commits. I'm merging this in an incomplete
state because almost any lldb-dap change is going to result in merge
conflicts and migrating request handlers one by one is easier to review.
2025-02-23 20:13:55 -06:00
Kazu Hirata
434d86ac92 [lldb] Fix warnings
This patch fixes:

  lldb/tools/lldb-dap/lldb-dap.cpp:5184:9: error: 'scoped_lock' may
  not intend to support class template argument deduction
  [-Werror,-Wctad-maybe-unsupported]

  lldb/tools/lldb-dap/lldb-dap.cpp:5200:7: error: 'unique_lock' may
  not intend to support class template argument deduction
  [-Werror,-Wctad-maybe-unsupported]

  lldb/tools/lldb-dap/lldb-dap.cpp:5222:5: error: 'scoped_lock' may
  not intend to support class template argument deduction
  [-Werror,-Wctad-maybe-unsupported]

  lldb/tools/lldb-dap/lldb-dap.cpp:5236:3: error: 'unique_lock' may
  not intend to support class template argument deduction
  [-Werror,-Wctad-maybe-unsupported]
2025-02-21 20:37:16 -08:00
John Harrison
998b28f196
[lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (#116392)
This adjusts the lldb-dap listening mode to accept multiple clients.
Each client initializes a new instance of DAP and an associated
`lldb::SBDebugger` instance.

The listening mode is configured with the `--connection` option and
supports listening on a port or a unix socket on supported platforms.

When running in server mode launch and attach performance should
be improved by lldb sharing symbols for core libraries between debug
sessions.
2025-02-21 18:30:43 -08:00
John Harrison
c2e96778e0
[lldb-dap] Ensure we do not print the close sentinel when closing stdout. (#126833)
If you have an lldb-dap log file you'll almost always see a final
message like:

```
<-- 
Content-Length: 94

{
  "body": {
    "category": "stdout",
    "output": "\u0000\u0000"
  },
  "event": "output",
  "seq": 0,
  "type": "event"
}
<-- 
Content-Length: 94

{
  "body": {
    "category": "stderr",
    "output": "\u0000\u0000"
  },
  "event": "output",
  "seq": 0,
  "type": "event"
}
```

The OutputRedirect is always writing the `"\0"` byte as a final stdout
message during shutdown. Instead, I adjusted this to detect the sentinel
value and break out of the read loop as if we detected EOF.

---------

Co-authored-by: Pavel Labath <pavel@labath.sk>
2025-02-13 10:35:50 -08:00
Jonas Devlieghere
73ab0c0762
[lldb-dap] Upgrade @types/node to fix TS2386 in node/module.d.ts (#126994)
Upgrade @types/node to work around an issue in TypeScript [1] that
caused our "publish to VSCode Marketplace" github action [2] to fail:

```
node_modules/@types/node/module.d.ts:290:13 - error TS2386: Overload signatures must all be optional or required.

290             resolve?(specified: string, parent?: string | URL): Promise<string>;
```

[1] https://github.com/microsoft/TypeScript/pull/59259#issuecomment-2228833941
[2] https://github.com/llvm/vscode-lldb/actions/runs/13298213337/job/37134713009
2025-02-12 19:09:09 -08:00
Jonas Devlieghere
1b582ef3c0
[lldb-dap] Bump the version number for publishing in the Marketplace 2025-02-12 16:14:00 -08:00
Da-Viper
4238238684
[lldb-dap] Fix: Could not find DAP in path (#126903)
Fixes #120839
2025-02-12 16:11:43 -08:00
Matthew Bastien
105b3a92a7
[lldb-dap] add debugAdapterExecutable property to launch configuration (#126803)
The Swift extension for VS Code requires that the `lldb-dap` executable
come from the Swift toolchain which may or may not be configured in
`PATH`. At the moment, this can be configured via LLDB DAP's extension
settings, but experience has shown that modifying other extensions'
settings on behalf of the user (especially those subject to change
whenever a new toolchain is selected) causes issues. Instead, it would
be easier to have this configurable in the launch configuration and let
the Swift extension (or any other extension that wanted to, really)
configure the path to `lldb-dap` that way. This allows the Swift
extension to have its own launch configuration type that delegates to
the LLDB DAP extension in order to provide a more seamless debugging
experience for Swift executables.

This PR adds a new property to the launch configuration object called
`debugAdapterExecutable` which allows overriding the `lldb-dap`
executable path for a specific debug session.
2025-02-12 15:49:38 -08:00
Keith Smiley
1932ed040c
[lldb-dap] Silence Wunused-result warning (#126580) 2025-02-10 15:20:34 -08:00
Adrian Vogelsgesang
f6162108c0
[lldb-dap] Update npm dependencies (#125832)
This commit upgrades our npm dependencies to the latest available
version.

I was prompted to this change because `npm run package` failed for me
with an error. The error disappeared after upgrading `@vscode/vsce`. I
also upgraded the other dependencies because I think it's generally
preferable to stay up-to-date.

I did not bump the `@types/vscode` and `@types/node` versions, since
this would effectively make older VS-Code versions unsupported. I also
changed `@types/vscode` to be a precise version match, since we are
claiming compatibility with that version via the `enginges.vscode`
property.
2025-02-06 21:31:31 +01:00
Adrian Vogelsgesang
8e6fa15bc3
[lldb-dap] Support column breakpoints (#125347)
This commit adds support for column breakpoints to lldb-dap

To do so, support for the `breakpointLocations` request was
added. To find all available breakpoint positions, we iterate over
the line table.

The `setBreakpoints` request already forwarded the column correctly to
`SBTarget::BreakpointCreateByLocation`. However, `SourceBreakpointMap`
did not keep track of multiple breakpoints in the same line. To do so,
the `SourceBreakpointMap` is now indexed by line+column instead of by
line only.

This was previously submitted as #113787, but got reverted due to
failures on ARM and macOS. This second attempt has less strict test
case expectations. Also, I added a release note.
2025-02-04 01:23:28 +01:00
Adrian Prantl
87b7f63a11 Revert "Reland "[lldb] Implement basic support for reverse-continue" (#125242)"
This reverts commit 7e66cf74fb4e6a103f923e34700a7b6f20ac2a9b.

Breaking green dragon:

https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/19569/testReport/junit/lldb-api/functionalities_reverse-execution/TestReverseContinueWatchpoints_py/
2025-01-31 13:11:20 -08:00
Jonas Devlieghere
2a2d6e66ce
[lldb-dap] Bump the version to 0.2.9
Bump the version to 0.2.9 to publish #124986 in the Marketplace.
2025-01-31 11:57:20 -08:00
David Spickett
7e66cf74fb
Reland "[lldb] Implement basic support for reverse-continue" (#125242)
This reverts commit a774de807e56c1147d4630bfec3110c11d41776e.

This is the same changes as last time, plus:
* We load the binary into the target object so that on Windows, we can
resolve the locations of the functions.
* We now assert that each required breakpoint has at least 1 location,
to prevent an issue like that in the future.
* We are less strict about the unsupported error message, because it
prints "error: windows" on Windows instead of "error: gdb-remote".
2025-01-31 15:56:33 +00:00
John Harrison
41910f7263
[lldb-dap] Fix build failure on Windows. (#125156)
A previous change is triggering a failure due to SOCKET not being
defined in IOStream.h. Adjusting the Windows includes to correct the
imports and using a more narrow import (winsock2.h vs windows.h).

Also removed a stale comment.

Tested this on an x86_64 wins 11 vm.

This should fix https://lab.llvm.org/buildbot/#/builders/197/builds/1379
and https://lab.llvm.org/buildbot/#/builders/141/builds/5878
2025-01-31 09:48:09 +00:00
John Harrison
adb9ef0355
[lldb-dap] Partially reverting OutputRedirector changes. (#125136)
I just noticed with these changes lldb-dap was using 200% of my CPU and
root causing the issue it seems that lldb_private::Pipe::Read() (without
a timeout) is using a timeout of `std::chrono::microseconds::zero()`
which ends up setting the SelectHelper timeout to `now + 0` (see
7ceef1b182/lldb/source/Host/posix/PipePosix.cpp (L314)
and
7ceef1b182/lldb/source/Utility/SelectHelper.cpp (L46))
which causes SelectHelper to return immediately with a timeout error. As
a result the `lldb_dap::OutputRedirector::RedirectTo()` to turn into a
busy loop.

Additionally, the 'read' call is waiting until the output buffer is full
before returning, which prevents any partial output (see
7ceef1b182/lldb/source/Host/posix/PipePosix.cpp (L325C9-L326C17)).

This is not the desired behavior for lldb-dap. Instead we want a write
to the FD to result in a callback to send the DAP Output event, which
mean we want partial output.

To mitigate this, I'm reverting the reading operation to the previous
behavior before 873426bea3dd67d80dd10650e64e91c69796614f but keeping the
refactored structure and thread management.
2025-01-30 16:35:15 -08:00
Matthew Bastien
0d46657cb6
Only include necessary files in the lldb-dap VSIX (#124986)
The published VSIX for the LLDB DAP extension contains a bunch of
unnecessary files:
```
❯ tar tf llvm-vs-code-extensions.lldb-dap-0.2.8.vsix

extension.vsixmanifest
[Content_Types].xml
extension/.github/workflows/auto_publish.yml
extension/.github/workflows/integrate_llvmproject.yml
extension/.gitignore
extension/.vscode/launch.json
extension/.vscode/tasks.json
extension/LICENSE.TXT
extension/out/debug-adapter-factory.js
extension/out/debug-adapter-factory.js.map
extension/out/disposable-context.js
extension/out/disposable-context.js.map
extension/out/extension.js
extension/out/extension.js.map
extension/out/types.js
extension/out/types.js.map
extension/package.json
extension/README.md
extension/src-ts/debug-adapter-factory.ts
extension/src-ts/disposable-context.ts
extension/src-ts/extension.ts
extension/src-ts/types.ts
extension/syntaxes/arm.disasm
extension/syntaxes/arm64.disasm
extension/syntaxes/disassembly.json
extension/syntaxes/x86.disasm
extension/tsconfig.json
```

All that's really needed is the package.json, license, README, syntaxes
folder, and compiled sources. This PR adds a `.vscodeignore` file that
requires files and directories to be explicitly added to the VSIX.

Contents of the VSIX after applying this change and running `npm run
package`:

```
❯ tar tf out/lldb-dap.vsix

extension.vsixmanifest
[Content_Types].xml
extension/LICENSE.TXT
extension/out/debug-adapter-factory.js
extension/out/debug-adapter-factory.js.map
extension/out/disposable-context.js
extension/out/disposable-context.js.map
extension/out/extension.js
extension/out/extension.js.map
extension/package.json
extension/README.md
extension/syntaxes/arm.disasm
extension/syntaxes/arm64.disasm
extension/syntaxes/disassembly.json
extension/syntaxes/x86.disasm
```

I did a very basic sanity check of installing the packaged extension and
debugging a simple swift application in VS Code to make sure the
extension was still functional.
2025-01-30 12:18:55 -08:00
David Spickett
a774de807e
Revert "Reland "[lldb] Implement basic support for reverse-continue" (#123906)"" (#125091)
Reverts llvm/llvm-project#123945

Has failed on the Windows on Arm buildbot:
https://lab.llvm.org/buildbot/#/builders/141/builds/5865
```
********************
Unresolved Tests (2):
  lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py
  lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py
********************
Failed Tests (1):
  lldb-api :: functionalities/reverse-execution/TestReverseContinueNotSupported.py
```
Reverting while I reproduce locally.
2025-01-30 16:45:36 +00:00
David Spickett
0caba6c8dc
Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (#123945)
This reverts commit 22561cfb443267905d4190f0e2a738e6b412457f and fixes
b7b9ccf44988edf49886743ae5c3cf4184db211f (#112079).

The problem is that x86_64 and Arm 32-bit have memory regions above the
stack that are readable but not writeable. First Arm:
```
(lldb) memory region --all
<...>
[0x00000000fffcf000-0x00000000ffff0000) rw- [stack]
[0x00000000ffff0000-0x00000000ffff1000) r-x [vectors]
[0x00000000ffff1000-0xffffffffffffffff) ---
```
Then x86_64:
```
$ cat /proc/self/maps
<...>
7ffdcd148000-7ffdcd16a000 rw-p 00000000 00:00 0                          [stack]
7ffdcd193000-7ffdcd196000 r--p 00000000 00:00 0                          [vvar]
7ffdcd196000-7ffdcd197000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]
```
Compare this to AArch64 where the test did pass:
```
$ cat /proc/self/maps
<...>
ffffb87dc000-ffffb87dd000 r--p 00000000 00:00 0                          [vvar]
ffffb87dd000-ffffb87de000 r-xp 00000000 00:00 0                          [vdso]
ffffb87de000-ffffb87e0000 r--p 0002a000 00:3c 76927217                   /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
ffffb87e0000-ffffb87e2000 rw-p 0002c000 00:3c 76927217                   /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
fffff4216000-fffff4237000 rw-p 00000000 00:00 0                          [stack]
```
To solve this, look up the memory region of the stack pointer (using
https://lldb.llvm.org/resources/lldbgdbremote.html#qmemoryregioninfo-addr)
and constrain the read to within that region. Since we know the stack is
all readable and writeable.

I have also added skipIfRemote to the tests, since getting them working
in that context is too complex to be worth it.

Memory write failures now display the range they tried to write, and
register write errors will show the name of the register where possible.

The patch also includes a workaround for a an issue where the test code
could mistake an `x` response that happens to begin with an `O` for an
output packet (stdout). This workaround will not be necessary one we
start using the [new
implementation](https://discourse.llvm.org/t/rfc-fixing-incompatibilties-of-the-x-packet-w-r-t-gdb/84288)
of the `x` packet.

---------

Co-authored-by: Pavel Labath <pavel@labath.sk>
2025-01-30 14:03:01 +00:00
John Harrison
873426bea3
[lldb-dap] Ensure the IO forwarding threads are managed by the DAP object lifecycle. (#122783)
This moves the ownership of the threads that forward stdout/stderr to
the DAP object itself to ensure that the threads are joined and that the
forwarding is cleaned up when the DAP connection is disconnected.

This is part of a larger refactor to allow lldb-dap to run in a
listening mode and accept multiple connections.

This reverts the previous revert and now that the underlying Windows
issue was fixed by 3ea2b546a8d17014d3ecf05356ecfaadf26ed846.
2025-01-27 08:58:50 -08:00
Jacob Lalonde
a939a9fd53
[LLDB-DAP] Send Progress update message over DAP (#123837)
When testing my SBProgress DAP PR (#123826), I noticed Progress update
messages aren't sent over DAP. This patch adds the lldb progress event's
message to the body when sent over DAP.

Before 

![image](https://github.com/user-attachments/assets/404adaa8-b784-4f23-895f-cd3625fdafad)


Now

![image](https://github.com/user-attachments/assets/eb1c3235-0936-4e36-96e5-0a0ee60dabb8)

Tested with my [progress tester
command](https://gist.github.com/Jlalond/48d85e75a91f7a137e3142e6a13d0947),
testing 10 events 5 seconds apart 1-10
2025-01-22 15:49:13 -08:00
Pavel Labath
22561cfb44
Revert "[lldb] Implement basic support for reverse-continue" (#123906)
Reverts llvm/llvm-project#112079 due to failures on the arm bot.
2025-01-22 09:43:11 +01:00
Robert O'Callahan
b7b9ccf449
[lldb] Implement basic support for reverse-continue (#112079)
This commit adds support for a
`SBProcess::ContinueInDirection()` API. A user-accessible command for
this will follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`) providing
support for the `bc` and `bs` packets. `lldb-server` does not support
those packets, and there is no plan to change that. For testing
purposes, this commit adds a Python implementation of *very limited*
record-and-reverse-execute functionality, implemented as a proxy between
lldb and lldb-server in `lldbreverse.py`. This should not (and in
practice cannot) be used for anything except testing.

The tests here are quite minimal but we test that simple breakpoints and
watchpoints work as expected during reverse execution, and that
conditional breakpoints and watchpoints work when the condition calls a
function that must be executed in the forward direction.
2025-01-22 08:37:17 +01:00
Jacob Lalonde
b9813ceb95
[LLDB][LLDB-DAP] Wire up DAP to listen to external progress events (#123826)
Recently I added SBProgress (#119052), and during that original commit I
tested if the progress event was sent over LLDB-DAP, and it was. However
upon the suggestion of @JDevlieghere and @labath we added an external
category (#120171), which I did not test.

This small patch wires up DAP to listen for external events by default,
and adds the external category to the SBDebugger enumeration.
2025-01-21 16:54:53 -08:00
Benjamin Kramer
81898ac00e Revert "[lldb-dap] Ensure the IO forwarding threads are managed by the DAP object lifecycle. (#120457)"
This reverts commit 0d9cf2671e06c9124a0b5fc753330c39c8b4a791. Breaks the
lldb-aarch64-windows buildbot.
2025-01-08 15:49:46 +01:00
John Harrison
0d9cf2671e
[lldb-dap] Ensure the IO forwarding threads are managed by the DAP object lifecycle. (#120457)
This moves the ownership of the threads that forward stdout/stderr to
the DAP object itself to ensure that the threads are joined and that the
forwarding is cleaned up when the DAP connection is disconnected.

This is part of a larger refactor to allow lldb-dap to run in a
listening mode and accept multiple connections.

---------

Co-authored-by: Pavel Labath <pavel@labath.sk>
2025-01-07 09:01:34 -08:00
Chandler Carruth
dd647e3e60
Rework the Option library to reduce dynamic relocations (#119198)
Apologies for the large change, I looked for ways to break this up and
all of the ones I saw added real complexity. This change focuses on the
option's prefixed names and the array of prefixes. These are present in
every option and the dominant source of dynamic relocations for PIE or
PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of
them for the Clang driver which has a huge number of options.

This PR addresses this by building a string table and a prefixes table
that can be referenced with indices rather than pointers that require
dynamic relocations. This removes almost 7k dynmaic relocations from the
`clang` binary, roughly 8% of the remaining dynmaic relocations outside
of vtables. For busy-boxing use cases where many different option tables
are linked into the same binary, the savings add up a bit more.

The string table is a straightforward mechanism, but the prefixes
required some subtlety. They are encoded in a Pascal-string fashion with
a size followed by a sequence of offsets. This works relatively well for
the small realistic prefixes arrays in use.

Lots of code has to change in order to land this though: both all the
option library code has to be updated to use the string table and
prefixes table, and all the users of the options library have to be
updated to correctly instantiate the objects.

Some follow-up patches in the works to provide an abstraction for this
style of code, and to start using the same technique for some of the
other strings here now that the infrastructure is in place.
2024-12-11 15:44:44 -08:00
Lily Wang
72aefbb5d0
[lldb] Include <chrono> for system_clock and now (#118059)
I am a member of Microsoft vcpkg, due to there are new changes merged by
microsoft/STL#5105, which revealed a conformance issue in `llvm`. It
must add include `<chrono>` to fix this error.

Compiler error with this STL change:
```
D:\b\llvm\src\org-18.1.6-e754cb1d0b.clean\lldb\tools\lldb-dap\ProgressEvent.h(79): error C2039: 'system_clock': is not a member of 'std::chrono'
D:\b\llvm\src\org-18.1.6-e754cb1d0b.clean\lldb\tools\lldb-dap\ProgressEvent.cpp(134): error C3083: 'system_clock': the symbol to the left of a '::' must be a type
D:\b\llvm\src\org-18.1.6-e754cb1d0b.clean\lldb\tools\lldb-dap\ProgressEvent.cpp(134): error C2039: 'now': is not a member of 'std::chrono'
```
2024-12-06 09:18:00 +00:00
Jonas Devlieghere
244b207d3c
[lldb-dap] Add attach & corefile templates (#118894) 2024-12-05 16:20:11 -08:00
Jonas Devlieghere
9302043bef
[lldb-dap] Fix links to LLVM issue tracker and pull requests (#118681)
Currently, the link to the issue tracker takes you to the Github source
repository, rather than the Github issue tracker. This fixes the link
and includes the lldb-dap label in both the issue and PR URL.
2024-12-04 11:04:05 -08:00
Jonas Devlieghere
ff5953804e
[lldb-dap] Support finding the lldb-dap binary (#118547)
Support finding the lldb-dap binary with `xcrun` on Darwin or in PATH on
all other platforms.

Unfortunately, this PR is larger than I would like because it removes
the `lldbDapOptions`. I believe these options are not necessary, and as
previously implemented, they caused a spurious warning with this change.
The problem was that the options were created before the custom factory.
By moving the creation logic into the factory, we make sure it's only
called after the factory has been registered. The upside is that this
simplifies the code and removes a level of indirection.
2024-12-04 09:43:49 -08:00
Jonas Devlieghere
442ee78cb4
[lldb-dap] Fix Markdown tables in README.md
The markdown tables in the README aren't getting rendered correctly on
the LLDB-DAP page in the Visual Studio arketplace [1]. This is a
somewhat speculative fix as the table itself appears to be correct. Even
if this change doesn't fix it, the new formatting significantly improves
the readability.

[1] https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap
2024-12-03 20:59:02 -08:00