Skip to content

Commit 8dcb493

Browse files
committed
Allow overriding remapped debug configuration via debug_custom.json
Some of the data from the `arduino-cli debug --info` output does not match exactly with the launch.json format required by the IDE's debugger. For this reason, some remapping of the data is required. The user can adjust the debugger configuration via a debug_custom.json file in the sketch project. The data from this file is merged into the base data provided by `arduino-cli debug --info`. The data from debug_custom.json should override the base data where there is overlap. Previously the override did not work for the remapped Arduino CLI data since the remapping was applied after merging the debug_custom.json data, which caused the debug_custom.json data to be overridden by that subset of the Arduino CLI data. The bug is fixed by performing the remapping before merging the debug_custom.json data.
1 parent 8e0d97b commit 8dcb493

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: src/debug.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ async function mergeLaunchConfig(
306306
(config) => config.configId === configId
307307
);
308308
const name = createName(board, programmer);
309-
const launchConfig = {
309+
// Create base configuration data
310+
let launchConfig = {
310311
configId,
311312
cwd: '${workspaceRoot}',
312313
request: 'launch',
@@ -315,17 +316,26 @@ async function mergeLaunchConfig(
315316
...(debugInfo.customConfigs
316317
? debugInfo.customConfigs[cortexDebug] ?? {}
317318
: {}),
318-
...(customConfig ? customConfig : {}),
319319
name,
320320
};
321+
322+
// Remap Arduino CLI debug config properties to launch.json keys
321323
replaceValue('serverPath', 'serverpath', launchConfig);
322324
replaceValue('server', 'servertype', launchConfig);
323325
replaceValue('toolchainPath', 'armToolchainPath', launchConfig);
324326
replaceValue('serverConfiguration.scripts', 'configFiles', launchConfig);
327+
// Remove unused Arduino CLI debug config data
325328
unsetValue(launchConfig, 'customConfigs');
326329
unsetValue(launchConfig, 'serverConfiguration');
327330
unsetValue(launchConfig, 'programmer'); // The programmer is not used by the debugger https://github.com/arduino/arduino-cli/pull/2391
328331
unsetValue(launchConfig, 'toolchain'); // The toolchain is also unused by IDE2 or the cortex-debug VSIX
332+
333+
// Merge configuration from debug_custom.json
334+
launchConfig = {
335+
...launchConfig,
336+
...(customConfig ? customConfig : {}),
337+
};
338+
329339
return launchConfig;
330340
}
331341

0 commit comments

Comments
 (0)