Skip to content

Commit 60109a1

Browse files
committed
debugger: Fixed command line tests
1 parent 8065455 commit 60109a1

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

commands/debug/debug.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"io"
2222
"os"
2323
"path/filepath"
24+
"runtime"
2425
"time"
2526

2627
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
@@ -121,7 +122,11 @@ func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager)
121122
var gdbPath *paths.Path
122123
switch debugInfo.GetToolchain() {
123124
case "gcc":
124-
gdbPath = paths.New(debugInfo.ToolchainPath).Join(debugInfo.ToolchainPrefix + "gdb")
125+
gdbexecutable := debugInfo.ToolchainPrefix + "gdb"
126+
if runtime.GOOS == "windows" {
127+
gdbexecutable += ".exe"
128+
}
129+
gdbPath = paths.New(debugInfo.ToolchainPath).Join(gdbexecutable)
125130
default:
126131
return nil, errors.Errorf("unsupported toolchain '%s'", debugInfo.GetToolchain())
127132
}
@@ -131,8 +136,9 @@ func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager)
131136
gdbInterpreter := req.GetInterpreter()
132137
if gdbInterpreter == "" {
133138
gdbInterpreter = "console"
134-
} else {
135-
add("--interpreter=" + gdbInterpreter)
139+
}
140+
add("--interpreter=" + gdbInterpreter)
141+
if gdbInterpreter != "console" {
136142
add("-ex")
137143
add("set pagination off")
138144
}

commands/debug/debug_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ func TestGetCommandLine(t *testing.T) {
5353
SketchPath: sketchPath.String(),
5454
}
5555

56-
goldCommand := fmt.Sprintf("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin//arm-none-eabi-gdb%s", dataDir, toolExtension) +
57-
" --interpreter=console -ex target extended-remote |" +
58-
fmt.Sprintf(" %s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd%s", dataDir, toolExtension) +
56+
goldCommand := fmt.Sprintf("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-gdb%s", dataDir, toolExtension) +
57+
" --interpreter=console -ex set remotetimeout 5 -ex target extended-remote |" +
58+
fmt.Sprintf(" \"%s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd%s\"", dataDir, toolExtension) +
5959
fmt.Sprintf(" -s \"%s/arduino-test/tools/openocd/0.10.0-arduino7/share/openocd/scripts/\"", dataDir) +
6060
fmt.Sprintf(" --file \"%s/arduino-test/samd/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\"", customHardware) +
61-
fmt.Sprintf(" -c \"gdb_port pipe\" -c \"telnet_port 0\" -c init -c halt %s/build/arduino-test.samd.arduino_zero_edbg/hello.ino.elf", sketchPath)
61+
fmt.Sprintf(" -c \"gdb_port pipe\" -c \"telnet_port 0\" %s/build/arduino-test.samd.arduino_zero_edbg/hello.ino.elf", sketchPath)
6262

6363
command, err := getCommandLine(req, pm)
6464
require.Nil(t, err)
@@ -74,12 +74,12 @@ func TestGetCommandLine(t *testing.T) {
7474
Interpreter: "mi1",
7575
}
7676

77-
goldCommand2 := fmt.Sprintf("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin//arm-none-eabi-gdb%s", dataDir, toolExtension) +
78-
" --interpreter=mi1 -ex target extended-remote |" +
79-
fmt.Sprintf(" %s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd%s", dataDir, toolExtension) +
77+
goldCommand2 := fmt.Sprintf("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-gdb%s", dataDir, toolExtension) +
78+
" --interpreter=mi1 -ex set pagination off -ex set remotetimeout 5 -ex target extended-remote |" +
79+
fmt.Sprintf(" \"%s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd%s\"", dataDir, toolExtension) +
8080
fmt.Sprintf(" -s \"%s/arduino-test/tools/openocd/0.10.0-arduino7/share/openocd/scripts/\"", dataDir) +
8181
fmt.Sprintf(" --file \"%s/arduino-test/samd/variants/mkr1000/openocd_scripts/arduino_zero.cfg\"", customHardware) +
82-
fmt.Sprintf(" -c \"gdb_port pipe\" -c \"telnet_port 0\" -c init -c halt %s/build/arduino-test.samd.mkr1000/hello.ino.elf", sketchPath)
82+
fmt.Sprintf(" -c \"gdb_port pipe\" -c \"telnet_port 0\" %s/build/arduino-test.samd.mkr1000/hello.ino.elf", sketchPath)
8383

8484
command2, err := getCommandLine(req2, pm)
8585
assert.Nil(t, err)

commands/debug/testdata/custom_hardware/arduino-test/samd/boards.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ arduino_zero_edbg.name=Arduino Zero (Programming Port)
2020
arduino_zero_edbg.vid.0=0x03eb
2121
arduino_zero_edbg.pid.0=0x2157
2222

23-
arduino_zero_edbg.debug.tool=gdb-openocd
2423
arduino_zero_edbg.upload.tool=openocd
2524
arduino_zero_edbg.upload.protocol=sam-ba
2625
arduino_zero_edbg.upload.maximum_size=262144
@@ -55,7 +54,6 @@ mkr1000.pid.2=0x824e
5554
mkr1000.vid.3=0x2341
5655
mkr1000.pid.3=0x024e
5756

58-
mkr1000.debug.tool=gdb-openocd
5957
mkr1000.upload.tool=bossac
6058
mkr1000.upload.protocol=sam-ba
6159
mkr1000.upload.maximum_size=262144

commands/debug/testdata/custom_hardware/arduino-test/samd/platform.txt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_ou
113113
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
114114
recipe.size.regex=\.text\s+([0-9]+).*
115115

116+
117+
# Debugger configuration (general options)
118+
# ----------------------------------------
119+
# EXPERIMENTAL feature:
120+
# - this is alpha and may be subject to change without notice
121+
debug.executable={build.path}/{build.project_name}.elf
122+
debug.toolchain=gcc
123+
debug.toolchain.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
124+
debug.toolchain.prefix=arm-none-eabi-
125+
debug.server=openocd
126+
debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd
127+
debug.server.openocd.path.windows={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd.exe
128+
debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/
129+
debug.server.openocd.script={runtime.platform.path}/variants/{build.variant}/{build.openocdscript}
130+
131+
116132
# Upload/Debug tools
117133
# ------------------
118134

@@ -219,13 +235,3 @@ tools.openocd-withbootsize.erase.pattern=
219235
tools.openocd-withbootsize.bootloader.params.verbose=-d2
220236
tools.openocd-withbootsize.bootloader.params.quiet=-d0
221237
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
222-
223-
#
224-
# GDB (Debugger)
225-
#
226-
227-
tools.gdb-openocd.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
228-
tools.gdb-openocd.cmd=arm-none-eabi-gdb
229-
tools.gdb-openocd.cmd.windows=arm-none-eabi-gdb.exe
230-
tools.gdb-openocd.interpreter=console
231-
tools.gdb-openocd.debug.pattern="{path}/{cmd}" --interpreter={interpreter} -ex 'target extended-remote | {tools.openocd.path}/{tools.openocd.cmd} -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0" -c init -c halt' {build.path}/{build.project_name}.elf

0 commit comments

Comments
 (0)