Skip to content

Commit

Permalink
use getConfiguration launch to read debug config (#1261)
Browse files Browse the repository at this point in the history
* use getConfiguration launch to read debug config

* add initialBreakpoint as launch json argument

* rm c in default initCmds

* fix initial breakpoint
  • Loading branch information
brianignacio5 authored Aug 9, 2024
1 parent dd2ed6d commit 81dea08
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/DEBUGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ In case the user wants more customized control, the basic arguments in launch.js
"initCommands": [
"set remote hardware-watchpoint-limit {IDF_TARGET_CPU_WATCHPOINT_NUM}",
"mon reset halt",
"maintenance flush register-cache",
"thb app_main"
"maintenance flush register-cache"
],
"gdb": "${command:espIdf.getToolchainGdb}",
"target": {
Expand All @@ -62,7 +61,8 @@ In case the user wants more customized control, the basic arguments in launch.js
```

- `program`: ELF file of your project build directory to execute the debug session. The command `${command:espIdf.getProjectName}` will query the extension to find the current build directory project name.
- `initCommands`: GDB Commands to initialize GDB and target.
- `initCommands`: GDB Commands to initialize GDB and target. The default value is `["set remote hardware-watchpoint-limit {IDF_TARGET_CPU_WATCHPOINT_NUM}", "mon reset halt", "maintenance flush register-cache"]`.
- `initialBreakpoint`: When `initCommands` is not defined, this command will add to default initCommands a hardward breakpoint at the given function name. For example `app_main`, the default value, will add `thb app_main` to default initCommmands. If set to "", an empty string, no initial breakpoint will be set and if let undefined it will use the default `thb app_main`.
- `gdb`: GDB executable to be used. By default `"${command:espIdf.getToolchainGdb}"` will query the extension to find the ESP-IDF toolchain GDB for the current `IDF_TARGET` of your esp-idf project (esp32, esp32c6, etc.).

> **NOTE** `{IDF_TARGET_CPU_WATCHPOINT_NUM}` is resolved by the extension according to the current `IDF_TARGET` of your esp-idf project (esp32, esp32c6, etc.).
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,11 @@
},
"default": []
},
"initialBreakpoint": {
"type": "string",
"description": "Initial hardware breakpoint being set as 'thb <value>'. For a value 'app_main' result in 'thb app_main' in initCommands. If user set an empty string '' no initial breakpoint will be set and if let undefined it will use the default 'thb app_main'. Ignored if user defines initCommands argument.",
"default": "app_main"
},
"preRunCommands": {
"type": "array",
"description": "List of GDB commands sent after loading image on target before resuming target.",
Expand Down Expand Up @@ -1839,6 +1844,11 @@
},
"default": []
},
"initialBreakpoint": {
"type": "string",
"description": "Initial hardware breakpoint being set as 'thb <value>'. For a value 'app_main' result in 'thb app_main' in initCommands. If user set an empty string '' no initial breakpoint will be set and if let undefined it will use the default 'thb app_main'. Ignored if user defines initCommands argument.",
"default": "app_main"
},
"preRunCommands": {
"type": "array",
"description": "List of GDB commands sent after loading image on target before resuming target.",
Expand Down
6 changes: 5 additions & 1 deletion src/cdtDebugAdapter/debugConfProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ export class CDTDebugConfigurationProvider
"set remote hardware-watchpoint-limit {IDF_TARGET_CPU_WATCHPOINT_NUM}",
"mon reset halt",
"maintenance flush register-cache",
"thb app_main",
];
if (typeof config.initialBreakpoint === "undefined") {
config.initCommands.push(`thb app_main`);
} else if (config.initialBreakpoint) {
config.initCommands.push(`thb ${config.initialBreakpoint.trim()}`);
}
}

if (config.initCommands && Array.isArray(config.initCommands)) {
Expand Down
15 changes: 8 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2623,13 +2623,14 @@ export async function activate(context: vscode.ExtensionContext) {
);
return;
}
const launchJson = await readJson(launchJsonPath);
if (
launchJson &&
launchJson.configurations &&
launchJson.configurations.length
) {
for (const conf of launchJson.configurations) {
const config = vscode.workspace.getConfiguration("launch", workspaceRoot);

// retrieve values
const configurations = config.get(
"configurations"
) as vscode.DebugConfiguration[];
if (configurations && configurations.length) {
for (const conf of configurations) {
if (conf.type === "gdbtarget") {
await vscode.debug.startDebugging(workspaceFolder, conf.name);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/pythonManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export async function execProcessWithLog(
undefined,
undefined,
cancelToken,
pyTracker.Log
undefined
);
Logger.info(processResult + "\n");
if (pyTracker) {
Expand Down

0 comments on commit 81dea08

Please sign in to comment.