Skip to content

Fix paths handling for gdb #597

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 4 commits into from
Feb 26, 2020
Merged
Changes from all 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
16 changes: 16 additions & 0 deletions commands/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@ func Debug(ctx context.Context, req *dbg.DebugConfigReq, inStream io.Reader, out
return nil, errors.Wrap(err, "Cannot get command line for tool")
}

// Transform every path to forward slashes (on Windows some tools further
// escapes the command line so the backslash "\" gets in the way).
for i, param := range commandLine {
commandLine[i] = filepath.ToSlash(param)
}

// Run Tool
entry := logrus.NewEntry(logrus.StandardLogger())
for i, param := range commandLine {
entry = entry.WithField(fmt.Sprintf("param%d", i), param)
}
entry.Debug("Executing debugger")

cmd, err := executils.Command(commandLine)
if err != nil {
return nil, errors.Wrap(err, "Cannot execute debug tool")
Expand Down Expand Up @@ -224,6 +236,10 @@ func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager)

// Build recipe for tool
recipe := toolProperties.Get("debug.pattern")
// REMOVEME: hotfix for samd core 1.8.5
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` {
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"`
}
cmdLine := toolProperties.ExpandPropsInString(recipe)
cmdArgs, err := properties.SplitQuotedString(cmdLine, `"'`, false)
if err != nil {
Expand Down