Skip to content

Commit ee03f7b

Browse files
committed
Debug: added programmer selection flag
1 parent f60193c commit ee03f7b

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

cli/debug/debug.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var (
4343
interpreter string
4444
importDir string
4545
printInfo bool
46+
programmer string
4647
)
4748

4849
// NewCommand created a new `upload` command
@@ -51,13 +52,14 @@ func NewCommand() *cobra.Command {
5152
Use: "debug",
5253
Short: "Debug Arduino sketches.",
5354
Long: "Debug Arduino sketches. (this command opens an interactive gdb session)",
54-
Example: " " + os.Args[0] + " debug -b arduino:samd:mkr1000 /home/user/Arduino/MySketch",
55+
Example: " " + os.Args[0] + " debug -b arduino:samd:mkr1000 -P atmel_ice /home/user/Arduino/MySketch",
5556
Args: cobra.MaximumNArgs(1),
5657
Run: run,
5758
}
5859

5960
debugCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
6061
debugCommand.Flags().StringVarP(&port, "port", "p", "", "Debug port, e.g.: COM10 or /dev/ttyACM0")
62+
debugCommand.Flags().StringVarP(&programmer, "programmer", "P", "", "Programmer to use for debugging")
6163
debugCommand.Flags().StringVar(&interpreter, "interpreter", "console", "Debug interpreter e.g.: console, mi, mi1, mi2, mi3")
6264
debugCommand.Flags().StringVarP(&importDir, "input-dir", "", "", "Directory containing binaries for debug.")
6365
debugCommand.Flags().BoolVarP(&printInfo, "info", "I", false, "Show metadata about the debug session instead of starting the debugger.")
@@ -85,6 +87,7 @@ func run(command *cobra.Command, args []string) {
8587
Port: port,
8688
Interpreter: interpreter,
8789
ImportDir: importDir,
90+
Programmer: programmer,
8891
}
8992

9093
if printInfo {

commands/debug/debug_info.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ func getDebugProperties(req *debug.DebugConfigReq, pm *packagemanager.PackageMan
105105
}
106106
}
107107

108+
if req.GetProgrammer() != "" {
109+
if p, ok := platformRelease.Programmers[req.GetProgrammer()]; ok {
110+
toolProperties.Merge(p.Properties)
111+
} else if refP, ok := referencedPlatformRelease.Programmers[req.GetProgrammer()]; ok {
112+
toolProperties.Merge(refP.Properties)
113+
} else {
114+
return nil, fmt.Errorf("programmer '%s' not found", req.GetProgrammer())
115+
}
116+
}
117+
108118
var importPath *paths.Path
109119
if importDir := req.GetImportDir(); importDir != "" {
110120
importPath = paths.New(importDir)

rpc/debug/debug.pb.go

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/debug/debug.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ message DebugConfigReq {
6868
// specified, the executable is assumed to be in
6969
// `{sketch_path}/build/{fqbn}/`.
7070
string import_dir = 8;
71+
// The programmer to use for debugging.
72+
string programmer = 9;
7173
}
7274

7375
//

0 commit comments

Comments
 (0)