Skip to content

Debugger now allows generic selection of sub-configurations #2435

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

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions commands/debug/debug_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl
for k, v := range toolProperties.SubTree("debug").AsMap() {
debugProperties.Set(k, toolProperties.ExpandPropsInString(v))
}
if debugAdditionalConfig, ok := toolProperties.GetOk("debug.additional_config"); ok {
debugAdditionalConfig = toolProperties.ExpandPropsInString(debugAdditionalConfig)
for k, v := range toolProperties.SubTree(debugAdditionalConfig).AsMap() {
debugProperties.Set(k, toolProperties.ExpandPropsInString(v))
}
}

if !debugProperties.ContainsKey("executable") {
return nil, &arduino.FailedDebugError{Message: tr("Debugging not supported for board %s", req.GetFqbn())}
Expand Down Expand Up @@ -169,12 +175,10 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl
}
}

toolchainPrefix := debugProperties.Get("toolchain.prefix")
// HOTFIX: for samd (and maybe some other platforms). We should keep this for a reasonable
Copy link
Contributor

Choose a reason for hiding this comment

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

This is also for other cores like the esp32 one

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

Choose a reason for hiding this comment

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

So I'd change the comment

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 comment says:

for samd (and maybe some other platforms)

esp32 is some other platform :-)

// amount of time to allow seamless platforms update.
toolchainPrefix := debugProperties.Get("toolchain.prefix")
if toolchainPrefix == "arm-none-eabi-" {
toolchainPrefix = "arm-none-eabi"
}
toolchainPrefix = strings.TrimSuffix(toolchainPrefix, "-")

customConfigs := map[string]string{}
if cortexDebugProps := debugProperties.SubTree("cortex-debug.custom"); cortexDebugProps.Size() > 0 {
Expand Down
57 changes: 57 additions & 0 deletions internal/integrationtest/debug/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,62 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli
}`)
}

{
// Mixing programmer and additional_config
jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my3", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json")
require.NoError(t, err)
debugOut := requirejson.Parse(t, jsonDebugOut)
debugOut.MustContain(`
{
"toolchain": "gcc",
"toolchain_path": "gcc-path",
"toolchain_prefix": "gcc-prefix",
"server": "openocd",
"server_path": "openocd-path",
"server_configuration": {
"path": "openocd-path",
"scripts_dir": "openocd-scripts-dir",
"scripts": [
"cold_ice_script"
]
},
"custom_configs": {
"cortex-debug": {
"test1": "true"
}
},
"svd_file": "test1.svd",
"programmer": "my_cold_ice"
}`)
}

{
// Mixing programmer and additional_config selected by another variable
jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my4", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json")
require.NoError(t, err)
debugOut := requirejson.Parse(t, jsonDebugOut)
debugOut.MustContain(`
{
"toolchain": "gcc",
"toolchain_path": "gcc-path",
"toolchain_prefix": "gcc-prefix",
"server": "openocd",
"server_path": "openocd-path",
"server_configuration": {
"path": "openocd-path",
"scripts_dir": "openocd-scripts-dir",
"scripts": [
"cold_ice_script"
]
},
"custom_configs": {
"cortex-debug": {
"test2": "true"
}
},
"svd_file": "test2.svd",
"programmer": "my_cold_ice"
}`)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,28 @@ my2.debug.server.openocd.path=openocd-path
my2.debug.server.openocd.scripts_dir=openocd-scripts-dir
my2.debug.server.openocd.script=single-script
my2.debug.svd_file=svd-file

my3.name=My third Cool Board
my3.build.core=arduino:arduino
my3.build.variant=arduino:mkr1000
my3.debug.toolchain.path=gcc-path
my3.debug.toolchain.prefix=gcc-prefix
my3.debug.server.openocd.path=openocd-path
my3.debug.server.openocd.scripts_dir=openocd-scripts-dir
my3.debug.server.openocd.script=single-script
# this one will be overwritten by additional_config
my3.debug.svd_file=svd-file
my3.debug.additional_config=build.debug.config.test1

my4.name=My fourth Cool Board
my4.build.core=arduino:arduino
my4.build.variant=arduino:mkr1000
my4.debug.toolchain.path=gcc-path
my4.debug.toolchain.prefix=gcc-prefix
my4.debug.server.openocd.path=openocd-path
my4.debug.server.openocd.scripts_dir=openocd-scripts-dir
my4.debug.server.openocd.script=single-script
my4.build.mcu=test2
# this one will be overwritten by additional_config
my4.debug.svd_file=svd-file
my4.debug.additional_config=build.debug.config.{build.mcu}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build.debug.config.test1.svd_file=test1.svd
build.debug.config.test1.cortex-debug.custom.test1=true

build.debug.config.test2.svd_file=test2.svd
build.debug.config.test2.cortex-debug.custom.test2=true