-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lldb-dap] Adding a modules explorer to lldb-dap ext. #138977
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
Conversation
@llvm/pr-subscribers-lldb Author: John Harrison (ashgti) ChangesThis creates a very basic module explorer for tracking and displaying loaded modules, reported by lldb-dap for the active debug session. This includes a basic session tracker that we can use to observe the debug session and collect specific information for additional visualizations in the lldb-dap ext. Here is a screenshot of the current visualization in the tree view. There is some unfortunate wrapping of the path, but it shows the basic support that could be extended in the future. <img width="1759" alt="Screenshot 2025-05-07 at 2 52 50 PM" src="https://github.com/user-attachments/assets/588baa2f-61d5-4434-8692-b1d0cce42875" /> Patch is 53.76 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/138977.diff 7 Files Affected:
diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json
index ab5c7dc33a8e5..0a2b9e764067e 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -1,16 +1,17 @@
{
"name": "lldb-dap",
- "version": "0.2.10",
+ "version": "0.2.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "lldb-dap",
- "version": "0.2.10",
+ "version": "0.2.13",
"license": "Apache 2.0 License with LLVM exceptions",
"devDependencies": {
"@types/node": "^18.19.41",
"@types/vscode": "1.75.0",
+ "@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
"prettier": "^3.4.2",
"prettier-plugin-curly": "^0.3.1",
@@ -405,6 +406,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@vscode/debugprotocol": {
+ "version": "1.68.0",
+ "resolved": "https://registry.npmjs.org/@vscode/debugprotocol/-/debugprotocol-1.68.0.tgz",
+ "integrity": "sha512-2J27dysaXmvnfuhFGhfeuxfHRXunqNPxtBoR3koiTOA9rdxWNDTa1zIFLCFMSHJ9MPTPKFcBeblsyaCJCIlQxg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@vscode/vsce": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-3.2.2.tgz",
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 4734c9d7277bb..ae4973a1c6985 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -30,9 +30,10 @@
"devDependencies": {
"@types/node": "^18.19.41",
"@types/vscode": "1.75.0",
+ "@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.2.2",
- "prettier-plugin-curly": "^0.3.1",
"prettier": "^3.4.2",
+ "prettier-plugin-curly": "^0.3.1",
"typescript": "^5.7.3"
},
"activationEvents": [
@@ -242,527 +243,537 @@
}
}
}
- ]
- },
- "breakpoints": [
- {
- "language": "ada"
- },
- {
- "language": "arm"
- },
- {
- "language": "asm"
- },
- {
- "language": "c"
- },
- {
- "language": "cpp"
- },
- {
- "language": "crystal"
- },
- {
- "language": "d"
- },
- {
- "language": "fortan"
- },
- {
- "language": "fortran-modern"
- },
- {
- "language": "nim"
- },
- {
- "language": "objective-c"
- },
- {
- "language": "objectpascal"
- },
- {
- "language": "pascal"
- },
- {
- "language": "rust"
- },
- {
- "language": "swift"
- }
- ],
- "debuggers": [
- {
- "type": "lldb-dap",
- "label": "LLDB DAP Debugger",
- "configurationAttributes": {
- "launch": {
- "required": [
- "program"
- ],
- "properties": {
- "debugAdapterHostname": {
- "type": "string",
- "markdownDescription": "The hostname that an existing lldb-dap executable is listening on."
- },
- "debugAdapterPort": {
- "type": "number",
- "markdownDescription": "The port that an existing lldb-dap executable is listening on."
- },
- "debugAdapterExecutable": {
- "type": "string",
- "markdownDescription": "The absolute path to the LLDB debug adapter executable to use. Overrides any user or workspace settings."
- },
- "debugAdapterArgs": {
- "type": "array",
- "items": {
- "type": "string"
+ ],
+ "breakpoints": [
+ {
+ "language": "ada"
+ },
+ {
+ "language": "arm"
+ },
+ {
+ "language": "asm"
+ },
+ {
+ "language": "c"
+ },
+ {
+ "language": "cpp"
+ },
+ {
+ "language": "crystal"
+ },
+ {
+ "language": "d"
+ },
+ {
+ "language": "fortan"
+ },
+ {
+ "language": "fortran-modern"
+ },
+ {
+ "language": "nim"
+ },
+ {
+ "language": "objective-c"
+ },
+ {
+ "language": "objectpascal"
+ },
+ {
+ "language": "pascal"
+ },
+ {
+ "language": "rust"
+ },
+ {
+ "language": "swift"
+ }
+ ],
+ "debuggers": [
+ {
+ "type": "lldb-dap",
+ "label": "LLDB DAP Debugger",
+ "configurationAttributes": {
+ "launch": {
+ "required": [
+ "program"
+ ],
+ "properties": {
+ "debugAdapterHostname": {
+ "type": "string",
+ "markdownDescription": "The hostname that an existing lldb-dap executable is listening on."
},
- "markdownDescription": "The list of additional arguments used to launch the debug adapter executable. Overrides any user or workspace settings."
- },
- "program": {
- "type": "string",
- "description": "Path to the program to debug."
- },
- "args": {
- "type": [
- "array"
- ],
- "items": {
- "type": "string"
- },
- "description": "Program arguments.",
- "default": []
- },
- "cwd": {
- "type": "string",
- "description": "Program working directory.",
- "default": "${workspaceRoot}"
- },
- "env": {
- "anyOf": [
- {
- "type": "object",
- "description": "Additional environment variables to set when launching the program. E.g. `{ \"FOO\": \"1\" }`",
- "patternProperties": {
- ".*": {
- "type": "string"
- }
- },
- "default": {}
+ "debugAdapterPort": {
+ "type": "number",
+ "markdownDescription": "The port that an existing lldb-dap executable is listening on."
+ },
+ "debugAdapterExecutable": {
+ "type": "string",
+ "markdownDescription": "The absolute path to the LLDB debug adapter executable to use. Overrides any user or workspace settings."
+ },
+ "debugAdapterArgs": {
+ "type": "array",
+ "items": {
+ "type": "string"
},
- {
- "type": "array",
- "description": "Additional environment variables to set when launching the program. E.g. `[\"FOO=1\", \"BAR\"]`",
- "items": {
- "type": "string",
- "pattern": "^((\\w+=.*)|^\\w+)$"
- },
- "default": []
- }
- ]
- },
- "stopOnEntry": {
- "type": "boolean",
- "description": "Automatically stop after launch.",
- "default": false
- },
- "disableASLR": {
- "type": "boolean",
- "description": "Enable or disable Address space layout randomization if the debugger supports it.",
- "default": true
- },
- "disableSTDIO": {
- "type": "boolean",
- "description": "Don't retrieve STDIN, STDOUT and STDERR as the program is running.",
- "default": false
- },
- "shellExpandArguments": {
- "type": "boolean",
- "description": "Expand program arguments as a shell would without actually launching the program in a shell.",
- "default": false
- },
- "detachOnError": {
- "type": "boolean",
- "description": "Detach from the program.",
- "default": false
- },
- "sourcePath": {
- "type": "string",
- "description": "Specify a source path to remap \"./\" to allow full paths to be used when setting breakpoints in binaries that have relative source paths."
- },
- "sourceMap": {
- "anyOf": [
- {
- "type": "object",
- "description": "Specify an object of path remappings; each entry has a key containing the source path and a value containing the destination path. E.g `{ \"/the/source/path\": \"/the/destination/path\" }`. Overrides sourcePath.",
- "patternProperties": {
- ".*": {
- "type": "string"
- }
- },
- "default": {}
+ "markdownDescription": "The list of additional arguments used to launch the debug adapter executable. Overrides any user or workspace settings."
+ },
+ "program": {
+ "type": "string",
+ "description": "Path to the program to debug."
+ },
+ "args": {
+ "type": [
+ "array"
+ ],
+ "items": {
+ "type": "string"
},
- {
- "type": "array",
- "description": "Specify an array of path remappings; each element must itself be a two element array containing a source and destination path name. Overrides sourcePath.",
- "items": {
+ "description": "Program arguments.",
+ "default": []
+ },
+ "cwd": {
+ "type": "string",
+ "description": "Program working directory.",
+ "default": "${workspaceRoot}"
+ },
+ "env": {
+ "anyOf": [
+ {
+ "type": "object",
+ "description": "Additional environment variables to set when launching the program. E.g. `{ \"FOO\": \"1\" }`",
+ "patternProperties": {
+ ".*": {
+ "type": "string"
+ }
+ },
+ "default": {}
+ },
+ {
"type": "array",
- "minItems": 2,
- "maxItems": 2,
+ "description": "Additional environment variables to set when launching the program. E.g. `[\"FOO=1\", \"BAR\"]`",
"items": {
- "type": "string"
- }
+ "type": "string",
+ "pattern": "^((\\w+=.*)|^\\w+)$"
+ },
+ "default": []
+ }
+ ]
+ },
+ "stopOnEntry": {
+ "type": "boolean",
+ "description": "Automatically stop after launch.",
+ "default": false
+ },
+ "disableASLR": {
+ "type": "boolean",
+ "description": "Enable or disable Address space layout randomization if the debugger supports it.",
+ "default": true
+ },
+ "disableSTDIO": {
+ "type": "boolean",
+ "description": "Don't retrieve STDIN, STDOUT and STDERR as the program is running.",
+ "default": false
+ },
+ "shellExpandArguments": {
+ "type": "boolean",
+ "description": "Expand program arguments as a shell would without actually launching the program in a shell.",
+ "default": false
+ },
+ "detachOnError": {
+ "type": "boolean",
+ "description": "Detach from the program.",
+ "default": false
+ },
+ "sourcePath": {
+ "type": "string",
+ "description": "Specify a source path to remap \"./\" to allow full paths to be used when setting breakpoints in binaries that have relative source paths."
+ },
+ "sourceMap": {
+ "anyOf": [
+ {
+ "type": "object",
+ "description": "Specify an object of path remappings; each entry has a key containing the source path and a value containing the destination path. E.g `{ \"/the/source/path\": \"/the/destination/path\" }`. Overrides sourcePath.",
+ "patternProperties": {
+ ".*": {
+ "type": "string"
+ }
+ },
+ "default": {}
},
- "default": []
- }
- ]
- },
- "debuggerRoot": {
- "type": "string",
- "description": "Specify a working directory to set the debug adapter to so relative object files can be located."
- },
- "targetTriple": {
- "type": "string",
- "description": "Triplet of the target architecture to override value derived from the program file."
- },
- "platformName": {
- "type": "string",
- "description": "Name of the execution platform to override value derived from the program file."
- },
- "initCommands": {
- "type": "array",
- "items": {
- "type": "string"
+ {
+ "type": "array",
+ "description": "Specify an array of path remappings; each element must itself be a two element array containing a source and destination path name. Overrides sourcePath.",
+ "items": {
+ "type": "array",
+ "minItems": 2,
+ "maxItems": 2,
+ "items": {
+ "type": "string"
+ }
+ },
+ "default": []
+ }
+ ]
},
- "description": "Initialization commands executed upon debugger startup.",
- "default": []
- },
- "preRunCommands": {
- "type": "array",
- "items": {
- "type": "string"
+ "debuggerRoot": {
+ "type": "string",
+ "description": "Specify a working directory to set the debug adapter to so relative object files can be located."
},
- "description": "Commands executed just before the program is launched.",
- "default": []
- },
- "postRunCommands": {
- "type": "array",
- "items": {
- "type": "string"
+ "targetTriple": {
+ "type": "string",
+ "description": "Triplet of the target architecture to override value derived from the program file."
},
- "description": "Commands executed just as soon as the program is successfully launched when it's in a stopped state prior to any automatic continuation.",
- "default": []
- },
- "launchCommands": {
- "type": "array",
- "items": {
- "type": "string"
+ "platformName": {
+ "type": "string",
+ "description": "Name of the execution platform to override value derived from the program file."
},
- "description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. Launch the process with \"process launch -s\" to make the process to at the entry point since lldb-dap will auto resume if necessary.",
- "default": []
- },
- "stopCommands": {
- "type": "array",
- "items": {
- "type": "string"
+ "initCommands": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Initialization commands executed upon debugger startup.",
+ "default": []
},
- "description": "Commands executed each time the program stops.",
- "default": []
- },
- "exitCommands": {
- "type": "array",
- "items": {
- "type": "string"
+ "preRunCommands": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Commands executed just before the program is launched.",
+ "default": []
},
- "description": "Commands executed when the program exits.",
- "default": []
- },
- "terminateCommands": {
- "type": "array",
- "items": {
- "type": "string"
+ "postRunCommands": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Commands executed just as soon as the program is successfully launched when it's in a stopped state prior to any automatic continuation.",
+ "default": []
},
- "description": "Commands executed when the debugging session ends.",
- "default": []
- },
- "runInTerminal": {
- "type": "boolean",
- "description": "Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs",
- "default": false
- },
- "timeout": {
- "type": "number",
- "description": "The time in seconds to wait for a program to stop at entry point when launching with \"launchCommands\". Defaults to 30 seconds."
- },
- "enableAutoVariableSummaries": {
- "type": "boolean",
- "description": "Enable auto generated summaries for variables when no summaries exist for a given type. This feature can cause performance delays in large projects when viewing variables.",
- "default": false
- },
- "displayExtendedBacktrace": {
- "type": "boolean",
- "description": "Enable language specific extended backtraces.",
- "default": false
- },
- "enableSyntheticChildDebugging": {
- "type": "boolean",
- "description": "If a variable is displayed using a synthetic children, also display the actual contents of the variable at the end under a [raw] entry. This is useful when creating sythetic child plug-ins as it lets you see the actual contents of the variable.",
- "default": false
- },
- "commandEscapePrefix": {
- "type": "string",
- "description": "The escape prefix to use for executing regular LLDB commands in the Debug Console, instead of printing variables. Defaults to a back-tick (`). If it's an empty string, then all expression in the Debug Console are treated as regular LLDB commands.",
- "default": "`"
- },
- "customFrameFormat": {
- "type": "string",
- "description": "If non-empty, stack frames will have descriptions generated based on the provided format. See https://lldb.llvm.org/use/formatting.html for an explanation on format strings for frames. If the format string contains errors, an error message will be displayed on the Debug Console and the default frame names will be used. This might come with a performance cost because debug information might need to be processed to generate the description.",
- "default": ""
- },
- "cust...
[truncated]
|
This creates a very basic module explorer for tracking and displaying loaded modules, reported by lldb-dap for the active debug session. This includes a basic session tracker that we can use to observe the debug session and collect specific information for additional visualizations in the lldb-dap ext.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really awesome and I'm surprised/impressed with how little TypeScript it takes to implement something like this.
… help explain the code a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but please give @da-viper a chance to review this before merging.
LGTM, Except the load address seems to be in decimal. It does not specify in the dap specification if it is decimal or hex. I assume it is implementation based. if it is the case we should show it as hex as that is default format for address in lldb. We could later extend it to show children instead of using the tool-tip. |
Yea, the address is being encoded as an plain integer not a hex string here llvm-project/lldb/tools/lldb-dap/JSONUtils.cpp Lines 492 to 494 in fa43e8f
We can follow up with other adjustments to either the data. |
It may be a coincidence, but a DAP test failed in green dragon right after this patch was applied: TestDAP_repl_mode_detection.py DAP tasks have been flaky though, so maybe unrelated, I don't fully understand how this patch works. |
The failure seems to be that
This should just be code in the lldb-dap VSCode extension, not in the lldb-dap executable, so this is likely a flaky test. It looks like that was running on macOS and I've been running those tests locally. I'll see if I can reproduce the flake by running it a few times. |
This creates a very basic module explorer for tracking and displaying loaded modules, reported by lldb-dap for the active debug session.
This includes a basic session tracker that we can use to observe the debug session and collect specific information for additional visualizations in the lldb-dap ext.
Here is a screenshot of the current visualization in the tree view. There is some unfortunate wrapping of the path, but it shows the basic support that could be extended in the future.