From afa4a5f7bd6d443cbac5858025690cb513e07a08 Mon Sep 17 00:00:00 2001 From: Brian Ignacio Date: Mon, 5 Aug 2024 18:18:07 +0800 Subject: [PATCH] add initialBreakpoint as launch json argument --- docs/DEBUGGING.md | 6 +++--- package.json | 10 ++++++++++ src/cdtDebugAdapter/debugConfProvider.ts | 5 +++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/DEBUGGING.md b/docs/DEBUGGING.md index c1f21821b..5dfa0fac6 100644 --- a/docs/DEBUGGING.md +++ b/docs/DEBUGGING.md @@ -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": { @@ -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. - `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.). diff --git a/package.json b/package.json index 835a92227..b38e2a320 100644 --- a/package.json +++ b/package.json @@ -1579,6 +1579,11 @@ }, "default": [] }, + "initialBreakpoint": { + "type": "string", + "description": "Hardware breakpoint being set initially as 'thb '. For a value 'app_main' result in 'thb app_main' in initCommands. Ignored if user defines initCommands", + "default": "app_main" + }, "preRunCommands": { "type": "array", "description": "List of GDB commands sent after loading image on target before resuming target.", @@ -1843,6 +1848,11 @@ }, "default": [] }, + "initialBreakpoint": { + "type": "string", + "description": "Hardware breakpoint being set initially as 'thb '. For a value 'app_main' result in 'thb app_main' in initCommands. Ignored if user defines initCommands", + "default": "app_main" + }, "preRunCommands": { "type": "array", "description": "List of GDB commands sent after loading image on target before resuming target.", diff --git a/src/cdtDebugAdapter/debugConfProvider.ts b/src/cdtDebugAdapter/debugConfProvider.ts index 3eb8087d6..f4e71c38c 100644 --- a/src/cdtDebugAdapter/debugConfProvider.ts +++ b/src/cdtDebugAdapter/debugConfProvider.ts @@ -63,9 +63,10 @@ export class CDTDebugConfigurationProvider "set remote hardware-watchpoint-limit {IDF_TARGET_CPU_WATCHPOINT_NUM}", "mon reset halt", "maintenance flush register-cache", - "thb app_main", - "c" ]; + if (config.initialBreakpoint) { + config.initCommands.push(`thb ${config.initialBreakpoint.trim()}`, "c"); + } } if (config.initCommands && Array.isArray(config.initCommands)) {