Skip to content

Commit 3a2f9f1

Browse files
cmaglieumbynos
andauthoredOct 12, 2023
[skip-changelog] debugger: some improvements in configuration handling (#2364)
* Allow non-sequential properties list * Command 'debug info' choose between "script" and "scripts" configs exclusively * Updated docs * Added test for mixed old and new-style openocd script definition * Update docs/platform-specification.md Co-authored-by: Umberto Baldi <[email protected]> --------- Co-authored-by: Umberto Baldi <[email protected]>
1 parent 128d7dc commit 3a2f9f1

File tree

7 files changed

+99
-13
lines changed

7 files changed

+99
-13
lines changed
 

‎.licenses/go/github.com/arduino/go-properties-orderedmap.dep.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: github.com/arduino/go-properties-orderedmap
3-
version: v1.7.1
3+
version: v1.8.0
44
type: go
55
summary: Package properties is a library for handling maps of hierarchical properties.
66
homepage: https://pkg.go.dev/github.com/arduino/go-properties-orderedmap

‎commands/debug/debug_info.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl
159159
case "openocd":
160160
openocdProperties := debugProperties.SubTree("server." + server)
161161
scripts := openocdProperties.ExtractSubIndexLists("scripts")
162-
if s := openocdProperties.Get("script"); s != "" {
163-
// backward compatibility
162+
if s := openocdProperties.Get("script"); s != "" && len(scripts) == 0 {
163+
// backward compatibility: use "script" property if there are no "scipts.N"
164164
scripts = append(scripts, s)
165165
}
166166
openocdConf := &rpc.DebugOpenOCDServerConfiguration{

‎docs/platform-specification.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,10 @@ OpenOCD server specific configurations:
13611361

13621362
- `debug.server.openocd.path`: is the absolute path to the OpenOCD directory
13631363
- `debug.server.openocd.scripts_dir`: is the absolute path to the OpenOCD scripts directory
1364-
- `debug.server.openocd.scripts.N`: is a list of OpenOCD scripts to run (where N is a number starting from 0)
1364+
- `debug.server.openocd.scripts.N`: is a list of OpenOCD script files to run, where N is a number (a sequence of
1365+
non-consecutive numbers is allowed)
1366+
- `debug.server.openocd.script`: if there is only one OpenOCD script to run, this directive con be used instead of the
1367+
`debug.server.openocd.scripts.N` (this directive is ignored if `debug.server.openocd.scripts.N` is present)
13651368

13661369
### Custom config for Cortext-debug plugin for Arduino IDE
13671370

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ replace github.com/mailru/easyjson => github.com/cmaglie/easyjson v0.8.1
88
require (
99
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371
1010
github.com/arduino/go-paths-helper v1.9.0
11-
github.com/arduino/go-properties-orderedmap v1.7.1
11+
github.com/arduino/go-properties-orderedmap v1.8.0
1212
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b
1313
github.com/arduino/go-win32-utils v1.0.0
1414
github.com/cmaglie/pb v1.0.27

‎go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
4949
github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
5050
github.com/arduino/go-paths-helper v1.9.0 h1:IjWhDSF24n5bK/30NyApmzoVH9brWzc52KNPpBsRmMc=
5151
github.com/arduino/go-paths-helper v1.9.0/go.mod h1:V82BWgAAp4IbmlybxQdk9Bpkz8M4Qyx+RAFKaG9NuvU=
52-
github.com/arduino/go-properties-orderedmap v1.7.1 h1:HQ9Pn/mk3+XyfrE39EEvaZwJkrvgiVSY5Oq3JSEfOR4=
53-
github.com/arduino/go-properties-orderedmap v1.7.1/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
52+
github.com/arduino/go-properties-orderedmap v1.8.0 h1:wEfa6hHdpezrVOh787OmClsf/Kd8qB+zE3P2Xbrn0CQ=
53+
github.com/arduino/go-properties-orderedmap v1.8.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
5454
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b h1:9hDi4F2st6dbLC3y4i02zFT5quS4X6iioWifGlVwfy4=
5555
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b/go.mod h1:uwGy5PpN4lqW97FiLnbcx+xx8jly5YuPMJWfVwwjJiQ=
5656
github.com/arduino/go-win32-utils v1.0.0 h1:/cXB86sOJxOsCHP7sQmXGLkdValwJt56mIwOHYxgQjQ=

‎internal/integrationtest/debug/debug_test.go

+54-6
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,12 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli
106106
require.NoError(t, err)
107107

108108
// Build sketch
109-
fqbn := "my:samd:my"
110-
_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--format", "json")
109+
_, _, err = cli.Run("compile", "-b", "my:samd:my", sketchPath.String(), "--format", "json")
111110
require.NoError(t, err)
112111

113112
{
114113
// Starts debugger
115-
jsonDebugOut, _, err := cli.Run("debug", "-b", fqbn, "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json")
114+
jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my", "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json")
116115
require.NoError(t, err)
117116
debugOut := requirejson.Parse(t, jsonDebugOut)
118117
debugOut.MustContain(`
@@ -128,7 +127,8 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli
128127
"scripts": [
129128
"first",
130129
"second",
131-
"third"
130+
"third",
131+
"fourth"
132132
]
133133
},
134134
"svd_file": "svd-file",
@@ -153,7 +153,7 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli
153153

154154
// Starts debugger with another programmer
155155
{
156-
jsonDebugOut, _, err := cli.Run("debug", "-b", fqbn, "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json")
156+
jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json")
157157
require.NoError(t, err)
158158
debugOut := requirejson.Parse(t, jsonDebugOut)
159159
debugOut.MustContain(`
@@ -169,7 +169,8 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli
169169
"scripts": [
170170
"first",
171171
"second",
172-
"cold_ice_script"
172+
"cold_ice_script",
173+
"fourth"
173174
]
174175
},
175176
"svd_file": "svd-file",
@@ -190,5 +191,52 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli
190191
]
191192
}
192193
}`)
194+
195+
{
196+
// Starts debugger with an old-style openocd script definition
197+
jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my2", "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json")
198+
require.NoError(t, err)
199+
debugOut := requirejson.Parse(t, jsonDebugOut)
200+
debugOut.MustContain(`
201+
{
202+
"toolchain": "gcc",
203+
"toolchain_path": "gcc-path",
204+
"toolchain_prefix": "gcc-prefix",
205+
"server": "openocd",
206+
"server_path": "openocd-path",
207+
"server_configuration": {
208+
"path": "openocd-path",
209+
"scripts_dir": "openocd-scripts-dir",
210+
"scripts": [
211+
"single-script"
212+
]
213+
},
214+
"svd_file": "svd-file"
215+
}`)
216+
}
217+
218+
{
219+
// Starts debugger with mixed old and new-style openocd script definition
220+
jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my2", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json")
221+
require.NoError(t, err)
222+
debugOut := requirejson.Parse(t, jsonDebugOut)
223+
debugOut.MustContain(`
224+
{
225+
"toolchain": "gcc",
226+
"toolchain_path": "gcc-path",
227+
"toolchain_prefix": "gcc-prefix",
228+
"server": "openocd",
229+
"server_path": "openocd-path",
230+
"server_configuration": {
231+
"path": "openocd-path",
232+
"scripts_dir": "openocd-scripts-dir",
233+
"scripts": [
234+
"cold_ice_script"
235+
]
236+
},
237+
"svd_file": "svd-file"
238+
}`)
239+
}
240+
193241
}
194242
}

‎internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt

+35
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ my.debug.server.openocd.script=
3333
my.debug.server.openocd.scripts.0=first
3434
my.debug.server.openocd.scripts.1=second
3535
my.debug.server.openocd.scripts.2=third
36+
my.debug.server.openocd.scripts.5=fourth
3637
my.debug.cortex-debug.custom.postAttachCommands.0=set remote hardware-watchpoint-limit 2
3738
my.debug.cortex-debug.custom.postAttachCommands.1=monitor reset halt
3839
my.debug.cortex-debug.custom.postAttachCommands.2=monitor gdb_sync
@@ -44,3 +45,37 @@ my.debug.cortex-debug.custom.overrideRestartCommands.2=thb setup
4445
my.debug.cortex-debug.custom.overrideRestartCommands.3=c
4546
my.debug.cortex-debug.custom.anotherStringParamer=hellooo
4647
my.debug.svd_file=svd-file
48+
49+
my2.name=My Cool Board
50+
my2.vid.0=0x2341
51+
my2.pid.0=0x804e
52+
my2.upload_port.0.vid=0x2341
53+
my2.upload_port.0.pid=0x804e
54+
my2.upload.tool=bossac
55+
my2.upload.tool.default=bossac
56+
my2.upload.tool.network=arduino_ota
57+
my2.upload.protocol=sam-ba
58+
my2.upload.maximum_size=262144
59+
my2.upload.maximum_data_size=32768
60+
my2.upload.use_1200bps_touch=true
61+
my2.upload.wait_for_upload_port=true
62+
my2.upload.native_usb=true
63+
my2.build.mcu=cortex-m0plus
64+
my2.build.f_cpu=48000000L
65+
my2.build.usb_product="Arduino MKR1000"
66+
my2.build.usb_manufacturer="Arduino LLC"
67+
my2.build.board=SAMD_MY
68+
my2.build.core=arduino:arduino
69+
my2.build.extra_flags=-DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ {build.usb_flags}
70+
my2.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
71+
my2.build.openocdscript=openocd_scripts/arduino_zero.cfg
72+
my2.build.variant=arduino:mkr1000
73+
my2.build.vid=0x2341
74+
my2.build.pid=0x804e
75+
76+
my2.debug.toolchain.path=gcc-path
77+
my2.debug.toolchain.prefix=gcc-prefix
78+
my2.debug.server.openocd.path=openocd-path
79+
my2.debug.server.openocd.scripts_dir=openocd-scripts-dir
80+
my2.debug.server.openocd.script=single-script
81+
my2.debug.svd_file=svd-file

0 commit comments

Comments
 (0)
Please sign in to comment.