Skip to content

Commit e4d02b4

Browse files
cmagliersora
authored and
rsora
committed
Fix paths handling for gdb (#597)
* When running debugger always use forward slash in paths * Add more debugging output when running debugger commandline * Temporary fix for arduino.samd core 1.8.5 * Fix gdb timeout on Windows (cherry picked from commit 561618a)
1 parent f0b72bd commit e4d02b4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

commands/debug/debug.go

+16
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,19 @@ func Debug(ctx context.Context, req *dbg.DebugConfigReq, inStream io.Reader, out
5151
return nil, errors.Wrap(err, "Cannot get command line for tool")
5252
}
5353

54+
// Transform every path to forward slashes (on Windows some tools further
55+
// escapes the command line so the backslash "\" gets in the way).
56+
for i, param := range commandLine {
57+
commandLine[i] = filepath.ToSlash(param)
58+
}
59+
5460
// Run Tool
61+
entry := logrus.NewEntry(logrus.StandardLogger())
62+
for i, param := range commandLine {
63+
entry = entry.WithField(fmt.Sprintf("param%d", i), param)
64+
}
65+
entry.Debug("Executing debugger")
66+
5567
cmd, err := executils.Command(commandLine)
5668
if err != nil {
5769
return nil, errors.Wrap(err, "Cannot execute debug tool")
@@ -224,6 +236,10 @@ func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager)
224236

225237
// Build recipe for tool
226238
recipe := toolProperties.Get("debug.pattern")
239+
// REMOVEME: hotfix for samd core 1.8.5
240+
if recipe == `"{path}/{cmd}" --interpreter=mi2 -ex "set pagination off" -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"' {build.path}/{build.project_name}.elf` {
241+
recipe = `"{path}/{cmd}" --interpreter=mi2 -ex "set remotetimeout 5" -ex "set pagination off" -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"' "{build.path}/{build.project_name}.elf"`
242+
}
227243
cmdLine := toolProperties.ExpandPropsInString(recipe)
228244
cmdArgs, err := properties.SplitQuotedString(cmdLine, `"'`, false)
229245
if err != nil {

0 commit comments

Comments
 (0)