Skip to content

Commit c506f6a

Browse files
authored
[breaking] gRPC API: Removed 'debug' service in favor of 'commands' service (#2349)
1 parent dc5c56e commit c506f6a

File tree

17 files changed

+1316
-1404
lines changed

17 files changed

+1316
-1404
lines changed

Diff for: Taskfile.yml

-2
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,12 @@ tasks:
238238
cmds:
239239
- '{{ default "protoc" .PROTOC_BINARY }} --proto_path=rpc --go_out=./rpc --go_opt=paths=source_relative --go-grpc_out=./rpc --go-grpc_opt=paths=source_relative ./rpc/cc/arduino/cli/commands/v1/*.proto'
240240
- '{{ default "protoc" .PROTOC_BINARY }} --proto_path=rpc --go_out=./rpc --go_opt=paths=source_relative --go-grpc_out=./rpc --go-grpc_opt=paths=source_relative ./rpc/cc/arduino/cli/settings/v1/*.proto'
241-
- '{{ default "protoc" .PROTOC_BINARY }} --proto_path=rpc --go_out=./rpc --go_opt=paths=source_relative --go-grpc_out=./rpc --go-grpc_opt=paths=source_relative ./rpc/cc/arduino/cli/debug/v1/*.proto'
242241

243242
protoc:docs:
244243
desc: Generate docs for protobuf definitions
245244
cmds:
246245
- '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,commands.md --proto_path=rpc ./rpc/cc/arduino/cli/commands/v1/*.proto'
247246
- '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,settings.md --proto_path=rpc ./rpc/cc/arduino/cli/settings/v1/*.proto'
248-
- '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,debug.md --proto_path=rpc ./rpc/cc/arduino/cli/debug/v1/*.proto'
249247

250248
docs:include-configuration-json-schema:
251249
desc: Copy configuration JSON schema to make it available in documentation

Diff for: client_example/main.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"time"
3030

3131
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
32-
dbg "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
3332
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/settings/v1"
3433
"google.golang.org/grpc"
3534
"google.golang.org/grpc/credentials/insecure"
@@ -955,11 +954,11 @@ func callLibUninstall(client rpc.ArduinoCoreServiceClient, instance *rpc.Instanc
955954
}
956955
}
957956

958-
func callDebugger(debugStreamingOpenClient dbg.DebugService_DebugClient, instance *rpc.Instance) {
957+
func callDebugger(debugStreamingOpenClient rpc.ArduinoCoreService_DebugClient, instance *rpc.Instance) {
959958
currDir, _ := os.Getwd()
960959
log.Printf("Send debug request")
961-
err := debugStreamingOpenClient.Send(&dbg.DebugRequest{
962-
DebugRequest: &dbg.DebugConfigRequest{
960+
err := debugStreamingOpenClient.Send(&rpc.DebugRequest{
961+
DebugRequest: &rpc.GetDebugConfigRequest{
963962
Instance: &rpc.Instance{Id: instance.GetId()},
964963
Fqbn: "arduino:samd:mkr1000",
965964
SketchPath: filepath.Join(currDir, "hello"),
@@ -974,7 +973,7 @@ func callDebugger(debugStreamingOpenClient dbg.DebugService_DebugClient, instanc
974973
waitForPrompt(debugStreamingOpenClient, "(gdb)")
975974
// Wait for gdb to init and show the prompt
976975
log.Printf("Send 'info registers' rcommand")
977-
err = debugStreamingOpenClient.Send(&dbg.DebugRequest{Data: []byte("info registers\n")})
976+
err = debugStreamingOpenClient.Send(&rpc.DebugRequest{Data: []byte("info registers\n")})
978977
if err != nil {
979978
log.Fatalf("Send error: %s\n", err)
980979
}
@@ -984,7 +983,7 @@ func callDebugger(debugStreamingOpenClient dbg.DebugService_DebugClient, instanc
984983

985984
// Send quit command to gdb
986985
log.Printf("Send 'quit' command")
987-
err = debugStreamingOpenClient.Send(&dbg.DebugRequest{Data: []byte("quit\n")})
986+
err = debugStreamingOpenClient.Send(&rpc.DebugRequest{Data: []byte("quit\n")})
988987
if err != nil {
989988
log.Fatalf("Send error: %s\n", err)
990989
}
@@ -997,7 +996,7 @@ func callDebugger(debugStreamingOpenClient dbg.DebugService_DebugClient, instanc
997996
}
998997
}
999998

1000-
func waitForPrompt(debugStreamingOpenClient dbg.DebugService_DebugClient, prompt string) {
999+
func waitForPrompt(debugStreamingOpenClient rpc.ArduinoCoreService_DebugClient, prompt string) {
10011000
var buffer bytes.Buffer
10021001
for {
10031002
compResp, err := debugStreamingOpenClient.Recv()

Diff for: commands/daemon/debug.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,14 @@ import (
2020
"os"
2121

2222
cmd "github.com/arduino/arduino-cli/commands/debug"
23-
dbg "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
23+
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2424
"github.com/pkg/errors"
2525
)
2626

27-
// DebugService implements the `Debug` service
28-
type DebugService struct {
29-
dbg.UnimplementedDebugServiceServer
30-
}
31-
3227
// Debug returns a stream response that can be used to fetch data from the
3328
// target. The first message passed through the `Debug` request must
3429
// contain DebugRequest configuration params, not data.
35-
func (s *DebugService) Debug(stream dbg.DebugService_DebugServer) error {
36-
30+
func (s *ArduinoCoreServerImpl) Debug(stream rpc.ArduinoCoreService_DebugServer) error {
3731
// Grab the first message
3832
msg, err := stream.Recv()
3933
if err != nil {
@@ -49,7 +43,7 @@ func (s *DebugService) Debug(stream dbg.DebugService_DebugServer) error {
4943
// Launch debug recipe attaching stdin and out to grpc streaming
5044
signalChan := make(chan os.Signal)
5145
defer close(signalChan)
52-
outStream := feedStreamTo(func(data []byte) { stream.Send(&dbg.DebugResponse{Data: data}) })
46+
outStream := feedStreamTo(func(data []byte) { stream.Send(&rpc.DebugResponse{Data: data}) })
5347
resp, debugErr := cmd.Debug(stream.Context(), req,
5448
consumeStreamFrom(func() ([]byte, error) {
5549
command, err := stream.Recv()
@@ -68,6 +62,6 @@ func (s *DebugService) Debug(stream dbg.DebugService_DebugServer) error {
6862
}
6963

7064
// GetDebugConfig return metadata about a debug session
71-
func (s *DebugService) GetDebugConfig(ctx context.Context, req *dbg.DebugConfigRequest) (*dbg.GetDebugConfigResponse, error) {
65+
func (s *ArduinoCoreServerImpl) GetDebugConfig(ctx context.Context, req *rpc.GetDebugConfigRequest) (*rpc.GetDebugConfigResponse, error) {
7266
return cmd.GetDebugConfig(ctx, req)
7367
}

Diff for: commands/debug/debug.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/arduino/arduino-cli/commands"
3030
"github.com/arduino/arduino-cli/executils"
3131
"github.com/arduino/arduino-cli/i18n"
32-
dbg "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
32+
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3333
"github.com/arduino/go-paths-helper"
3434
"github.com/sirupsen/logrus"
3535
)
@@ -42,7 +42,7 @@ var tr = i18n.Tr
4242
// grpc Out <- tool stdOut
4343
// grpc Out <- tool stdErr
4444
// It also implements tool process lifecycle management
45-
func Debug(ctx context.Context, req *dbg.DebugConfigRequest, inStream io.Reader, out io.Writer, interrupt <-chan os.Signal) (*dbg.DebugResponse, error) {
45+
func Debug(ctx context.Context, req *rpc.GetDebugConfigRequest, inStream io.Reader, out io.Writer, interrupt <-chan os.Signal) (*rpc.DebugResponse, error) {
4646

4747
// Get debugging command line to run debugger
4848
pme, release := commands.GetPackageManagerExplorer(req)
@@ -75,7 +75,7 @@ func Debug(ctx context.Context, req *dbg.DebugConfigRequest, inStream io.Reader,
7575
// Get stdIn pipe from tool
7676
in, err := cmd.StdinPipe()
7777
if err != nil {
78-
return &dbg.DebugResponse{Error: err.Error()}, nil
78+
return &rpc.DebugResponse{Error: err.Error()}, nil
7979
}
8080
defer in.Close()
8181

@@ -85,7 +85,7 @@ func Debug(ctx context.Context, req *dbg.DebugConfigRequest, inStream io.Reader,
8585

8686
// Start the debug command
8787
if err := cmd.Start(); err != nil {
88-
return &dbg.DebugResponse{Error: err.Error()}, nil
88+
return &rpc.DebugResponse{Error: err.Error()}, nil
8989
}
9090

9191
if interrupt != nil {
@@ -111,13 +111,13 @@ func Debug(ctx context.Context, req *dbg.DebugConfigRequest, inStream io.Reader,
111111

112112
// Wait for process to finish
113113
if err := cmd.Wait(); err != nil {
114-
return &dbg.DebugResponse{Error: err.Error()}, nil
114+
return &rpc.DebugResponse{Error: err.Error()}, nil
115115
}
116-
return &dbg.DebugResponse{}, nil
116+
return &rpc.DebugResponse{}, nil
117117
}
118118

119119
// getCommandLine compose a debug command represented by a core recipe
120-
func getCommandLine(req *dbg.DebugConfigRequest, pme *packagemanager.Explorer) ([]string, error) {
120+
func getCommandLine(req *rpc.GetDebugConfigRequest, pme *packagemanager.Explorer) ([]string, error) {
121121
debugInfo, err := getDebugProperties(req, pme)
122122
if err != nil {
123123
return nil, err

Diff for: commands/debug/debug_info.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import (
2424
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
2525
"github.com/arduino/arduino-cli/arduino/sketch"
2626
"github.com/arduino/arduino-cli/commands"
27-
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
27+
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2828
"github.com/arduino/go-paths-helper"
2929
"github.com/arduino/go-properties-orderedmap"
3030
"github.com/sirupsen/logrus"
3131
)
3232

3333
// GetDebugConfig returns metadata to start debugging with the specified board
34-
func GetDebugConfig(ctx context.Context, req *debug.DebugConfigRequest) (*debug.GetDebugConfigResponse, error) {
34+
func GetDebugConfig(ctx context.Context, req *rpc.GetDebugConfigRequest) (*rpc.GetDebugConfigResponse, error) {
3535
pme, release := commands.GetPackageManagerExplorer(req)
3636
if pme == nil {
3737
return nil, &arduino.InvalidInstanceError{}
@@ -40,7 +40,7 @@ func GetDebugConfig(ctx context.Context, req *debug.DebugConfigRequest) (*debug.
4040
return getDebugProperties(req, pme)
4141
}
4242

43-
func getDebugProperties(req *debug.DebugConfigRequest, pme *packagemanager.Explorer) (*debug.GetDebugConfigResponse, error) {
43+
func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Explorer) (*rpc.GetDebugConfigResponse, error) {
4444
// TODO: make a generic function to extract sketch from request
4545
// and remove duplication in commands/compile.go
4646
if req.GetSketchPath() == "" {
@@ -150,7 +150,7 @@ func getDebugProperties(req *debug.DebugConfigRequest, pme *packagemanager.Explo
150150

151151
server := debugProperties.Get("server")
152152
toolchain := debugProperties.Get("toolchain")
153-
return &debug.GetDebugConfigResponse{
153+
return &rpc.GetDebugConfigResponse{
154154
Executable: debugProperties.Get("executable"),
155155
Server: server,
156156
ServerPath: debugProperties.Get("server." + server + ".path"),

Diff for: commands/debug/debug_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
2525
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
26-
dbg "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
2726
"github.com/arduino/go-paths-helper"
2827
"github.com/stretchr/testify/assert"
2928
"github.com/stretchr/testify/require"
@@ -47,7 +46,7 @@ func TestGetCommandLine(t *testing.T) {
4746
}
4847

4948
// Arduino Zero has an integrated debugger port, anc it could be debugged directly using USB
50-
req := &dbg.DebugConfigRequest{
49+
req := &rpc.GetDebugConfigRequest{
5150
Instance: &rpc.Instance{Id: 1},
5251
Fqbn: "arduino-test:samd:arduino_zero_edbg",
5352
SketchPath: sketchPath.String(),
@@ -71,7 +70,7 @@ func TestGetCommandLine(t *testing.T) {
7170

7271
// Other samd boards such as mkr1000 can be debugged using an external tool such as Atmel ICE connected to
7372
// the board debug port
74-
req2 := &dbg.DebugConfigRequest{
73+
req2 := &rpc.GetDebugConfigRequest{
7574
Instance: &rpc.Instance{Id: 1},
7675
Fqbn: "arduino-test:samd:mkr1000",
7776
SketchPath: sketchPath.String(),

Diff for: docs/UPGRADING.md

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

55
## 0.35.0
66

7+
### gRPC service `cc.arduino.cli.debug.v1` moved to `cc.arduino.cli.commands.v1`.
8+
9+
The gRPC service `cc.arduino.cli.debug.v1` has been removed and all gRPC messages and rpc calls have been moved to
10+
`cc.arduino.cli.commands.v1`.
11+
12+
The gRPC message `DebugConfigRequest` has been renamed to the proper `GetDebugConfigRequest`.
13+
14+
All the generated API has been updated as well.
15+
716
### The gRPC `cc.arduino.cli.commands.v1.BoardListWatchRequest` command request has been changed.
817

918
The gRPC message `BoardListWatchRequest` has been changed from:

Diff for: internal/cli/daemon/daemon.go

-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/arduino/arduino-cli/i18n"
3030
"github.com/arduino/arduino-cli/internal/cli/feedback"
3131
srv_commands "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
32-
srv_debug "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
3332
srv_settings "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/settings/v1"
3433
"github.com/arduino/arduino-cli/version"
3534
"github.com/arduino/go-paths-helper"
@@ -111,9 +110,6 @@ func runDaemonCommand(cmd *cobra.Command, args []string) {
111110
// Register the settings service
112111
srv_settings.RegisterSettingsServiceServer(s, &daemon.SettingsService{})
113112

114-
// Register the debug session service
115-
srv_debug.RegisterDebugServiceServer(s, &daemon.DebugService{})
116-
117113
if !daemonize {
118114
// When parent process ends terminate also the daemon
119115
go feedback.ExitWhenParentProcessEnds()

Diff for: internal/cli/debug/debug.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/arduino/arduino-cli/internal/cli/feedback"
2929
"github.com/arduino/arduino-cli/internal/cli/instance"
3030
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
31-
dbg "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
3231
"github.com/arduino/arduino-cli/table"
3332
"github.com/arduino/go-properties-orderedmap"
3433
"github.com/fatih/color"
@@ -82,7 +81,7 @@ func runDebugCommand(command *cobra.Command, args []string) {
8281
feedback.FatalError(err, feedback.ErrGeneric)
8382
}
8483
fqbn, port := arguments.CalculateFQBNAndPort(&portArgs, &fqbnArg, instance, sk.GetDefaultFqbn(), sk.GetDefaultPort(), sk.GetDefaultProtocol())
85-
debugConfigRequested := &dbg.DebugConfigRequest{
84+
debugConfigRequested := &rpc.GetDebugConfigRequest{
8685
Instance: instance,
8786
Fqbn: fqbn,
8887
SketchPath: sketchPath.String(),
@@ -118,7 +117,7 @@ func runDebugCommand(command *cobra.Command, args []string) {
118117
}
119118

120119
type debugInfoResult struct {
121-
info *dbg.GetDebugConfigResponse
120+
info *rpc.GetDebugConfigResponse
122121
}
123122

124123
func (r *debugInfoResult) Data() interface{} {

Diff for: mkdocs.yml

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ nav:
101101
- gRPC reference:
102102
- commands: rpc/commands.md
103103
- settings: rpc/settings.md
104-
- debug: rpc/debug.md
105104
- configuration.md
106105
- Integration options: integration-options.md
107106
- sketch-build-process.md

0 commit comments

Comments
 (0)