Skip to content

Support LLDB-DAP as a debugger (OSX/Linux/Windows) #13569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

fearthecowboy
Copy link
Member

@fearthecowboy fearthecowboy commented Apr 29, 2025

This adds the ability to debug processes via LLDB using the LLDB-DAP adapter that is bundled with LLVM's LLDB debugger.

This includes:

  • additions to the options schema to support the cpplldb debug type
  • refinements to the process picker (and ps/cim code) so that the user can actually identify the process they are selecting.
    • the ps code was returning items that were not clear as to which process was which. It now gets the full path of the process if at all possible.
    • expands the length of process arguments to get a better representation of the command line
  • some new common code:
    • for searching the PATH for a binary (with predicate to verify on the fly)
    • for searching folders for a binary (with predicate)
    • added a note function to the logger that sets a transient message in the status bar.
  • created a links.ts as central place to store links (there are others embedded in the code that should be moved, and then they should all be aka.ms links for security)
  • allow the user to specify a program with attach so that the processes can be filtered to what they expect.
  • cleaned up use of string constants cppdbg and cppvsdbg so that they use the constants that exist already.
  • translates the cpplldb options to lldb-dap options on the fly
  • some changes to the debug configuration generation to improve clarity of which debugger is being enabled.
  • refactored ConfigurationProvider code so that it's not string-smashing to write JSON.
  • LLDB-DAP specific work:
    • it will scan the system to find the LLDB-DAP path by searching the PATH, using xcrun (on OSX) and searching secure/well-known-locations to find the binary
    • it tests any found binary since LLDB-DAP has a dependency on Python3 (and SPECIFICALLY Python310 on Windows) - and if that's not found it doesn't run or say anything.
    • searches for lldb-dap, lldb-dap-##, lldb-vscode, and lldb-vscode-## to support different named binaries (especially on linux)

Important Notes

  • the cppvsdbg debugger on Windows can debug LLVM compiled binaries very well, and there is really no reason you want to use the LLDB-DAP on windows - it's just not as good as the other platforms. It's sluggish and has problems with step over and other things.

  • LLDB-DAP on windows has a dependency of Python310 - which means if your Python3 installed by the store or whereever is not 3.10 but say 3.13 - it won't work. To fix that, you can run this from an elevated command line:

    • curl https://www.python.org/ftp/python/3.10.11/python-3.10.11-embed-amd64.zip --output - | tar x -C c:\program files\llvm\bin -- this will download the right binary and unpack it into the correct folder -- but this is really a hack.

@fearthecowboy fearthecowboy marked this pull request as ready for review April 29, 2025 17:40
@fearthecowboy fearthecowboy requested a review from a team as a code owner April 29, 2025 17:40
"rust"
],
"_aiKeyComment": "Ignore 'Property aiKey is not allowed'. See https://github.com/microsoft/vscode/issues/76493",
"aiKey": "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does lldb-dap send telemetry events? If it doesn't, you may want to remove this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, this key is used by VSCode itself to send telemetry for the debugger extension (ie, monacoworkbench/debugsessionstart) events - which is the very code that I've written.

Yes, this is absolutely necessary

Copy link
Member

@WardenGnaw WardenGnaw May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

monacoworkbench/debugsessionstart is from VS Code's telemetry table, they send that at https://github.com/microsoft/vscode/blob/2ba158ca779b715bd4d29d1cb6ac022b27672b26/src/vs/workbench/contrib/debug/browser/debugService.ts#L677 and does not rely on aiKey

This aiKey should be for telemetry sent from the debugger via OutputEvent with category: "telemetry"
I don't see anywhere in lldb-dap that utilized OutputType::Telemetry.

https://github.com/search?q=repo%3Allvm%2Fllvm-project+OutputType%3A%3ATelemetry&type=code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aikey for the Debugger Contribution is read in VSCode itself here in getCustomTelemetryEndpoint() :

https://github.com/microsoft/vscode/blob/2ba158ca779b715bd4d29d1cb6ac022b27672b26/src/vs/workbench/contrib/debug/common/debugger.ts#L223

It would appear that getCustomTelemetryEndpoint() is called, and it writes at least one event here:

https://github.com/microsoft/vscode/blob/2ba158ca779b715bd4d29d1cb6ac022b27672b26/src/vs/workbench/contrib/debug/browser/debugSession.ts#L1193

I could be wrong, but I don't see any way that the lldb-dap binary would even be able to get the configuration for the debugger contribution from package.json since we never pass that to it.

This is following the same pattern that the debugger contribution points for the other debug types (cppdbg and cppvsdbg ) - cppdbg uses the MIEngine adapter, and I find no indication that MIEngine uses aikey at all (https://github.com/search?q=repo%3Amicrosoft%2FMIEngine%20aikey&type=code)

After reading the comments here:
microsoft/vscode#2931
microsoft/vscode#76493 (comment)

I was under the impression that's why we even have the aikey in the debugger contribution point, otherwise we just send telemetry events ourselves with the key as normal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would appear that getCustomTelemetryEndpoint() is called, and it writes at least one event here:

https://github.com/microsoft/vscode/blob/2ba158ca779b715bd4d29d1cb6ac022b27672b26/src/vs/workbench/contrib/debug/browser/debugSession.ts#L1193

A couple lines above show that the aiKey is used specifically for the OutputEvent that lldb-dap does not send. lldb-dap does not need aiKey, but aiKey is used when Telemetry is sent (via OutputEvent) from the debugger.

This link shows that lldb-dap does not send any OutputType::Telemetry at all https://github.com/search?q=repo%3Allvm%2Fllvm-project+OutputType%3A%3ATelemetry&type=code

My comment here is saying, this aiKey is going to be unused so you can remove from the configuration unless there's plan to introduce telemetry OutputEvents from lldb-dap.

@sean-mcmanus sean-mcmanus self-requested a review April 30, 2025 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pull Request
Development

Successfully merging this pull request may close these issues.

4 participants