Skip to content

[breaking] Change gRPC DebugConfigRequest port field type #1414

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 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
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
18 changes: 14 additions & 4 deletions cli/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os/signal"
"sort"

"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/arduino-cli/cli/arguments"
"github.com/arduino/arduino-cli/cli/errorcodes"
"github.com/arduino/arduino-cli/cli/feedback"
Expand All @@ -38,7 +39,7 @@ import (

var (
fqbn string
port string
port arguments.Port
verbose bool
verify bool
interpreter string
Expand All @@ -60,7 +61,7 @@ func NewCommand() *cobra.Command {
}

debugCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno"))
debugCommand.Flags().StringVarP(&port, "port", "p", "", tr("Debug port, e.g.: COM10 or /dev/ttyACM0"))
port.AddToCommand(debugCommand)
debugCommand.Flags().StringVarP(&programmer, "programmer", "P", "", tr("Programmer to use for debugging"))
debugCommand.Flags().StringVar(&interpreter, "interpreter", "console", fmt.Sprintf(tr("Debug interpreter e.g.: %s, %s, %s, %s, %s"), "console", "mi", "mi1", "mi2", "mi3"))
debugCommand.Flags().StringVarP(&importDir, "input-dir", "", "", tr("Directory containing binaries for debug."))
Expand All @@ -77,12 +78,21 @@ func run(command *cobra.Command, args []string) {
path = args[0]
}
sketchPath := arguments.InitSketchPath(path)

sk, err := sketch.New(sketchPath)
if err != nil {
feedback.Errorf(tr("Error during Debug: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}
discoveryPort, err := port.GetPort(instance, sk)
if err != nil {
feedback.Errorf(tr("Error during Debug: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}
debugConfigRequested := &dbg.DebugConfigRequest{
Instance: instance,
Fqbn: fqbn,
SketchPath: sketchPath.String(),
Port: port,
Port: discoveryPort.ToRPC(),
Interpreter: interpreter,
ImportDir: importDir,
Programmer: programmer,
Expand Down
4 changes: 3 additions & 1 deletion client_example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,9 @@ func callDebugger(debugStreamingOpenClient dbg.DebugService_DebugClient, instanc
Instance: &rpc.Instance{Id: instance.GetId()},
Fqbn: "arduino:samd:mkr1000",
SketchPath: filepath.Join(currDir, "hello"),
Port: "none",
Port: &rpc.Port{
Address: "none",
},
}})
if err != nil {
log.Fatalf("Send error: %s\n", err)
Expand Down
11 changes: 4 additions & 7 deletions commands/debug/debug_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,10 @@ func getDebugProperties(req *debug.DebugConfigRequest, pm *packagemanager.Packag

// Set debug port property
port := req.GetPort()
if port != "" {
toolProperties.Set("debug.port", port)
if strings.HasPrefix(port, "/dev/") {
toolProperties.Set("debug.port.file", port[5:])
} else {
toolProperties.Set("debug.port.file", port)
}
if port.GetAddress() != "" {
toolProperties.Set("debug.port", port.Address)
portFile := strings.TrimPrefix(port.Address, "/dev/")
toolProperties.Set("debug.port.file", portFile)
}

// Extract and expand all debugging properties
Expand Down
6 changes: 3 additions & 3 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Here you can find a list of migration guides to handle breaking changes between

## Unreleased

### gRPC interface `UploadRequest`, `UploadUsingProgrammerRequest`, `BurnBootloaderRequest`, `DetectedPort` field changes
### gRPC interface `DebugConfigRequest`, `UploadRequest`, `UploadUsingProgrammerRequest`, `BurnBootloaderRequest`, `DetectedPort` field changes

`UploadRequest`, `UploadUsingProgrammerRequest` and `BurnBootloaderRequest` had their `port` field change from type
`string` to `Port`.
`DebugConfigRequest`, `UploadRequest`, `UploadUsingProgrammerRequest` and `BurnBootloaderRequest` had their `port` field
change from type `string` to `Port`.

`Port` contains the following information:

Expand Down
44 changes: 21 additions & 23 deletions i18n/data/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ msgstr "%s already downloaded"
msgid "%s and %s cannot be used together"
msgstr "%s and %s cannot be used together"

#: cli/debug/debug.go:149
#: cli/debug/debug.go:159
msgid "%s custom configurations"
msgstr "%s custom configurations"

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

#: cli/debug/debug.go:55
#: cli/debug/debug.go:56
msgid "Debug Arduino sketches."
msgstr "Debug Arduino sketches."

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

#: cli/debug/debug.go:65
#: cli/debug/debug.go:66
msgid "Debug interpreter e.g.: %s, %s, %s, %s, %s"
msgstr "Debug interpreter e.g.: %s, %s, %s, %s, %s"

#: cli/debug/debug.go:63
msgid "Debug port, e.g.: COM10 or /dev/ttyACM0"
msgstr "Debug port, e.g.: COM10 or /dev/ttyACM0"

#: cli/board/details.go:124
msgid "Debugging supported:"
msgstr "Debugging supported:"
Expand Down Expand Up @@ -466,7 +462,7 @@ msgstr "Detecting libraries used..."
msgid "Detects and displays a list of boards connected to the current computer."
msgstr "Detects and displays a list of boards connected to the current computer."

#: cli/debug/debug.go:66
#: cli/debug/debug.go:67
msgid "Directory containing binaries for debug."
msgstr "Directory containing binaries for debug."

Expand Down Expand Up @@ -583,7 +579,9 @@ msgstr "Error downloading %[1]s: %[2]v"
msgid "Error downloading tool %s"
msgstr "Error downloading tool %s"

#: cli/debug/debug.go:111
#: cli/debug/debug.go:83
#: cli/debug/debug.go:88
#: cli/debug/debug.go:121
msgid "Error during Debug: %v"
msgstr "Error during Debug: %v"

Expand Down Expand Up @@ -620,8 +618,8 @@ msgstr "Error during uninstall: %v"
msgid "Error during upgrade: %v"
msgstr "Error during upgrade: %v"

#: cli/debug/debug.go:95
#: cli/debug/debug.go:98
#: cli/debug/debug.go:105
#: cli/debug/debug.go:108
msgid "Error getting Debug info: %v"
msgstr "Error getting Debug info: %v"

Expand Down Expand Up @@ -809,7 +807,7 @@ msgstr "Examples for library %s"
msgid "Examples:"
msgstr "Examples:"

#: cli/debug/debug.go:130
#: cli/debug/debug.go:140
msgid "Executable to debug"
msgstr "Executable to debug"

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

#: cli/debug/debug.go:144
#: cli/debug/debug.go:154
msgid "GDB Server path"
msgstr "GDB Server path"

#: cli/debug/debug.go:143
#: cli/debug/debug.go:153
msgid "GDB Server type"
msgstr "GDB Server type"

Expand Down Expand Up @@ -1436,7 +1434,7 @@ msgstr "Prints the current configuration."
msgid "Programmer name"
msgstr "Programmer name"

#: cli/debug/debug.go:64
#: cli/debug/debug.go:65
msgid "Programmer to use for debugging"
msgstr "Programmer to use for debugging"

Expand Down Expand Up @@ -1571,7 +1569,7 @@ msgstr "Show library names only."
msgid "Show list of available programmers"
msgstr "Show list of available programmers"

#: cli/debug/debug.go:67
#: cli/debug/debug.go:68
msgid "Show metadata about the debug session instead of starting the debugger."
msgstr "Show metadata about the debug session instead of starting the debugger."

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

#: cli/debug/debug.go:138
#: cli/debug/debug.go:148
msgid "Toolchain custom configurations"
msgstr "Toolchain custom configurations"

#: cli/debug/debug.go:132
#: cli/debug/debug.go:142
msgid "Toolchain path"
msgstr "Toolchain path"

#: cli/debug/debug.go:133
#: cli/debug/debug.go:143
msgid "Toolchain prefix"
msgstr "Toolchain prefix"

#: cli/debug/debug.go:131
#: cli/debug/debug.go:141
msgid "Toolchain type"
msgstr "Toolchain type"

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

#: commands/debug/debug_info.go:149
#: commands/debug/debug_info.go:146
msgid "debugging not supported for board %s"
msgstr "debugging not supported for board %s"

Expand Down
8 changes: 4 additions & 4 deletions i18n/rice-box.go

Large diffs are not rendered by default.

Loading