Skip to content

Commit 1bc0bd5

Browse files
author
rsora
committed
Remove hotfix adding --interpreter flag
1 parent 97c4f00 commit 1bc0bd5

File tree

7 files changed

+97
-244
lines changed

7 files changed

+97
-244
lines changed

cli/debug/debug.go

+15-11
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@ import (
2424
"github.com/arduino/arduino-cli/cli/feedback"
2525
"github.com/arduino/arduino-cli/cli/instance"
2626
"github.com/arduino/arduino-cli/commands/debug"
27+
rpc "github.com/arduino/arduino-cli/rpc/commands"
2728
dbg "github.com/arduino/arduino-cli/rpc/debug"
2829
"github.com/arduino/go-paths-helper"
2930
"github.com/sirupsen/logrus"
3031
"github.com/spf13/cobra"
3132
)
3233

3334
var (
34-
fqbn string
35-
port string
36-
verbose bool
37-
verify bool
38-
importFile string
35+
fqbn string
36+
port string
37+
verbose bool
38+
verify bool
39+
interpreter string
40+
importFile string
3941
)
4042

4143
// NewCommand created a new `upload` command
@@ -50,7 +52,8 @@ func NewCommand() *cobra.Command {
5052
}
5153

5254
debugCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
53-
debugCommand.Flags().StringVarP(&port, "port", "p", "", "Upload port, e.g.: COM10 or /dev/ttyACM0")
55+
debugCommand.Flags().StringVarP(&port, "port", "p", "", "Debug port, e.g.: COM10 or /dev/ttyACM0")
56+
debugCommand.Flags().StringVar(&interpreter, "interpreter", "console", "Debug interpreter e.g.: console, mi, mi1, mi2, mi3")
5457
debugCommand.Flags().StringVarP(&importFile, "input", "i", "", "Input file to be uploaded for debug.")
5558

5659
return debugCommand
@@ -74,11 +77,12 @@ func run(command *cobra.Command, args []string) {
7477
signal.Notify(ctrlc, os.Interrupt)
7578

7679
if _, err := debug.Debug(context.Background(), &dbg.DebugConfigReq{
77-
Instance: &dbg.Instance{Id: instance.GetId()},
78-
Fqbn: fqbn,
79-
SketchPath: sketchPath.String(),
80-
Port: port,
81-
ImportFile: importFile,
80+
Instance: &rpc.Instance{Id: instance.GetId()},
81+
Fqbn: fqbn,
82+
SketchPath: sketchPath.String(),
83+
Port: port,
84+
Interpreter: interpreter,
85+
ImportFile: importFile,
8286
}, os.Stdin, os.Stdout, ctrlc); err != nil {
8387
feedback.Errorf("Error during Debug: %v", err)
8488
os.Exit(errorcodes.ErrGeneric)

commands/debug/debug.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager)
126126
return nil, errors.Wrap(err, "opening sketch")
127127
}
128128

129-
// FIXME: make a specification on how a port is specified via command line
130-
port := req.GetPort()
131-
if port == "" {
132-
return nil, fmt.Errorf("no debug port provided")
133-
}
134-
135129
fqbnIn := req.GetFqbn()
136130
if fqbnIn == "" && sketch != nil && sketch.Metadata != nil {
137131
fqbnIn = sketch.Metadata.CPU.Fqbn
@@ -227,19 +221,27 @@ func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager)
227221
}
228222

229223
// Set debug port property
230-
toolProperties.Set("debug.port", port)
231-
if strings.HasPrefix(port, "/dev/") {
232-
toolProperties.Set("debug.port.file", port[5:])
224+
port := req.GetPort()
225+
if port != "" {
226+
toolProperties.Set("debug.port", port)
227+
if strings.HasPrefix(port, "/dev/") {
228+
toolProperties.Set("debug.port.file", port[5:])
229+
} else {
230+
toolProperties.Set("debug.port.file", port)
231+
}
232+
}
233+
234+
// Set debugger interpreter (default value should be "console")
235+
interpreter := req.GetInterpreter()
236+
if interpreter != "" {
237+
toolProperties.Set("interpreter", interpreter)
233238
} else {
234-
toolProperties.Set("debug.port.file", port)
239+
toolProperties.Set("interpreter", "console")
235240
}
236241

237242
// Build recipe for tool
238243
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-
}
244+
243245
cmdLine := toolProperties.ExpandPropsInString(recipe)
244246
cmdArgs, err := properties.SplitQuotedString(cmdLine, `"'`, false)
245247
if err != nil {

rpc/commands/commands.pb.go

+4-86
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)