Skip to content

Commit a07258b

Browse files
authored
Change gRPC DebugConfigRequest port field type (#1414)
1 parent 372b881 commit a07258b

File tree

8 files changed

+160
-145
lines changed

8 files changed

+160
-145
lines changed

Diff for: cli/debug/debug.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os/signal"
2323
"sort"
2424

25+
"github.com/arduino/arduino-cli/arduino/sketch"
2526
"github.com/arduino/arduino-cli/cli/arguments"
2627
"github.com/arduino/arduino-cli/cli/errorcodes"
2728
"github.com/arduino/arduino-cli/cli/feedback"
@@ -38,7 +39,7 @@ import (
3839

3940
var (
4041
fqbn string
41-
port string
42+
port arguments.Port
4243
verbose bool
4344
verify bool
4445
interpreter string
@@ -60,7 +61,7 @@ func NewCommand() *cobra.Command {
6061
}
6162

6263
debugCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno"))
63-
debugCommand.Flags().StringVarP(&port, "port", "p", "", tr("Debug port, e.g.: COM10 or /dev/ttyACM0"))
64+
port.AddToCommand(debugCommand)
6465
debugCommand.Flags().StringVarP(&programmer, "programmer", "P", "", tr("Programmer to use for debugging"))
6566
debugCommand.Flags().StringVar(&interpreter, "interpreter", "console", fmt.Sprintf(tr("Debug interpreter e.g.: %s, %s, %s, %s, %s"), "console", "mi", "mi1", "mi2", "mi3"))
6667
debugCommand.Flags().StringVarP(&importDir, "input-dir", "", "", tr("Directory containing binaries for debug."))
@@ -77,12 +78,21 @@ func run(command *cobra.Command, args []string) {
7778
path = args[0]
7879
}
7980
sketchPath := arguments.InitSketchPath(path)
80-
81+
sk, err := sketch.New(sketchPath)
82+
if err != nil {
83+
feedback.Errorf(tr("Error during Debug: %v"), err)
84+
os.Exit(errorcodes.ErrGeneric)
85+
}
86+
discoveryPort, err := port.GetPort(instance, sk)
87+
if err != nil {
88+
feedback.Errorf(tr("Error during Debug: %v"), err)
89+
os.Exit(errorcodes.ErrGeneric)
90+
}
8191
debugConfigRequested := &dbg.DebugConfigRequest{
8292
Instance: instance,
8393
Fqbn: fqbn,
8494
SketchPath: sketchPath.String(),
85-
Port: port,
95+
Port: discoveryPort.ToRPC(),
8696
Interpreter: interpreter,
8797
ImportDir: importDir,
8898
Programmer: programmer,

Diff for: client_example/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,9 @@ func callDebugger(debugStreamingOpenClient dbg.DebugService_DebugClient, instanc
10091009
Instance: &rpc.Instance{Id: instance.GetId()},
10101010
Fqbn: "arduino:samd:mkr1000",
10111011
SketchPath: filepath.Join(currDir, "hello"),
1012-
Port: "none",
1012+
Port: &rpc.Port{
1013+
Address: "none",
1014+
},
10131015
}})
10141016
if err != nil {
10151017
log.Fatalf("Send error: %s\n", err)

Diff for: commands/debug/debug_info.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,10 @@ func getDebugProperties(req *debug.DebugConfigRequest, pm *packagemanager.Packag
130130

131131
// Set debug port property
132132
port := req.GetPort()
133-
if port != "" {
134-
toolProperties.Set("debug.port", port)
135-
if strings.HasPrefix(port, "/dev/") {
136-
toolProperties.Set("debug.port.file", port[5:])
137-
} else {
138-
toolProperties.Set("debug.port.file", port)
139-
}
133+
if port.GetAddress() != "" {
134+
toolProperties.Set("debug.port", port.Address)
135+
portFile := strings.TrimPrefix(port.Address, "/dev/")
136+
toolProperties.Set("debug.port.file", portFile)
140137
}
141138

142139
// Extract and expand all debugging properties

Diff for: docs/UPGRADING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Here you can find a list of migration guides to handle breaking changes between
44

55
## Unreleased
66

7-
### gRPC interface `UploadRequest`, `UploadUsingProgrammerRequest`, `BurnBootloaderRequest`, `DetectedPort` field changes
7+
### gRPC interface `DebugConfigRequest`, `UploadRequest`, `UploadUsingProgrammerRequest`, `BurnBootloaderRequest`, `DetectedPort` field changes
88

9-
`UploadRequest`, `UploadUsingProgrammerRequest` and `BurnBootloaderRequest` had their `port` field change from type
10-
`string` to `Port`.
9+
`DebugConfigRequest`, `UploadRequest`, `UploadUsingProgrammerRequest` and `BurnBootloaderRequest` had their `port` field
10+
change from type `string` to `Port`.
1111

1212
`Port` contains the following information:
1313

Diff for: i18n/data/en.po

+21-23
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ msgstr "%s already downloaded"
4545
msgid "%s and %s cannot be used together"
4646
msgstr "%s and %s cannot be used together"
4747

48-
#: cli/debug/debug.go:149
48+
#: cli/debug/debug.go:159
4949
msgid "%s custom configurations"
5050
msgstr "%s custom configurations"
5151

@@ -413,22 +413,18 @@ msgstr "Creates a zip file containing all sketch files."
413413
msgid "Creates or updates the configuration file in the data directory or custom directory with the current configuration settings."
414414
msgstr "Creates or updates the configuration file in the data directory or custom directory with the current configuration settings."
415415

416-
#: cli/debug/debug.go:55
416+
#: cli/debug/debug.go:56
417417
msgid "Debug Arduino sketches."
418418
msgstr "Debug Arduino sketches."
419419

420-
#: cli/debug/debug.go:56
420+
#: cli/debug/debug.go:57
421421
msgid "Debug Arduino sketches. (this command opens an interactive gdb session)"
422422
msgstr "Debug Arduino sketches. (this command opens an interactive gdb session)"
423423

424-
#: cli/debug/debug.go:65
424+
#: cli/debug/debug.go:66
425425
msgid "Debug interpreter e.g.: %s, %s, %s, %s, %s"
426426
msgstr "Debug interpreter e.g.: %s, %s, %s, %s, %s"
427427

428-
#: cli/debug/debug.go:63
429-
msgid "Debug port, e.g.: COM10 or /dev/ttyACM0"
430-
msgstr "Debug port, e.g.: COM10 or /dev/ttyACM0"
431-
432428
#: cli/board/details.go:124
433429
msgid "Debugging supported:"
434430
msgstr "Debugging supported:"
@@ -466,7 +462,7 @@ msgstr "Detecting libraries used..."
466462
msgid "Detects and displays a list of boards connected to the current computer."
467463
msgstr "Detects and displays a list of boards connected to the current computer."
468464

469-
#: cli/debug/debug.go:66
465+
#: cli/debug/debug.go:67
470466
msgid "Directory containing binaries for debug."
471467
msgstr "Directory containing binaries for debug."
472468

@@ -583,7 +579,9 @@ msgstr "Error downloading %[1]s: %[2]v"
583579
msgid "Error downloading tool %s"
584580
msgstr "Error downloading tool %s"
585581

586-
#: cli/debug/debug.go:111
582+
#: cli/debug/debug.go:83
583+
#: cli/debug/debug.go:88
584+
#: cli/debug/debug.go:121
587585
msgid "Error during Debug: %v"
588586
msgstr "Error during Debug: %v"
589587

@@ -620,8 +618,8 @@ msgstr "Error during uninstall: %v"
620618
msgid "Error during upgrade: %v"
621619
msgstr "Error during upgrade: %v"
622620

623-
#: cli/debug/debug.go:95
624-
#: cli/debug/debug.go:98
621+
#: cli/debug/debug.go:105
622+
#: cli/debug/debug.go:108
625623
msgid "Error getting Debug info: %v"
626624
msgstr "Error getting Debug info: %v"
627625

@@ -809,7 +807,7 @@ msgstr "Examples for library %s"
809807
msgid "Examples:"
810808
msgstr "Examples:"
811809

812-
#: cli/debug/debug.go:130
810+
#: cli/debug/debug.go:140
813811
msgid "Executable to debug"
814812
msgstr "Executable to debug"
815813

@@ -869,16 +867,16 @@ msgstr "Force skip of post-install scripts (if the CLI is running interactively)
869867
#: cli/board/details.go:50
870868
#: cli/burnbootloader/burnbootloader.go:53
871869
#: cli/compile/compile.go:85
872-
#: cli/debug/debug.go:62
870+
#: cli/debug/debug.go:63
873871
#: cli/upload/upload.go:58
874872
msgid "Fully Qualified Board Name, e.g.: arduino:avr:uno"
875873
msgstr "Fully Qualified Board Name, e.g.: arduino:avr:uno"
876874

877-
#: cli/debug/debug.go:144
875+
#: cli/debug/debug.go:154
878876
msgid "GDB Server path"
879877
msgstr "GDB Server path"
880878

881-
#: cli/debug/debug.go:143
879+
#: cli/debug/debug.go:153
882880
msgid "GDB Server type"
883881
msgstr "GDB Server type"
884882

@@ -1436,7 +1434,7 @@ msgstr "Prints the current configuration."
14361434
msgid "Programmer name"
14371435
msgstr "Programmer name"
14381436

1439-
#: cli/debug/debug.go:64
1437+
#: cli/debug/debug.go:65
14401438
msgid "Programmer to use for debugging"
14411439
msgstr "Programmer to use for debugging"
14421440

@@ -1571,7 +1569,7 @@ msgstr "Show library names only."
15711569
msgid "Show list of available programmers"
15721570
msgstr "Show list of available programmers"
15731571

1574-
#: cli/debug/debug.go:67
1572+
#: cli/debug/debug.go:68
15751573
msgid "Show metadata about the debug session instead of starting the debugger."
15761574
msgstr "Show metadata about the debug session instead of starting the debugger."
15771575

@@ -1735,19 +1733,19 @@ msgstr "This commands shows a list of installed cores and/or libraries\n"
17351733
msgid "Tool %s already installed"
17361734
msgstr "Tool %s already installed"
17371735

1738-
#: cli/debug/debug.go:138
1736+
#: cli/debug/debug.go:148
17391737
msgid "Toolchain custom configurations"
17401738
msgstr "Toolchain custom configurations"
17411739

1742-
#: cli/debug/debug.go:132
1740+
#: cli/debug/debug.go:142
17431741
msgid "Toolchain path"
17441742
msgstr "Toolchain path"
17451743

1746-
#: cli/debug/debug.go:133
1744+
#: cli/debug/debug.go:143
17471745
msgid "Toolchain prefix"
17481746
msgstr "Toolchain prefix"
17491747

1750-
#: cli/debug/debug.go:131
1748+
#: cli/debug/debug.go:141
17511749
msgid "Toolchain type"
17521750
msgstr "Toolchain type"
17531751

@@ -2278,7 +2276,7 @@ msgstr "creating temp file for index signature download: %s"
22782276
msgid "data section exceeds available space in board"
22792277
msgstr "data section exceeds available space in board"
22802278

2281-
#: commands/debug/debug_info.go:149
2279+
#: commands/debug/debug_info.go:146
22822280
msgid "debugging not supported for board %s"
22832281
msgstr "debugging not supported for board %s"
22842282

Diff for: i18n/rice-box.go

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

0 commit comments

Comments
 (0)