From 4c6e007a02a65c12a71c34bf9a097a8eb5a4dd73 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 4 Oct 2023 13:43:36 +0200 Subject: [PATCH 1/8] Improved specification of debug configuration --- commands/debug/debug.go | 9 +- commands/debug/debug_info.go | 34 ++- docs/UPGRADING.md | 37 +++ internal/cli/debug/debug.go | 93 +++++-- rpc/cc/arduino/cli/commands/v1/debug.pb.go | 305 +++++++++++++++------ rpc/cc/arduino/cli/commands/v1/debug.proto | 18 +- 6 files changed, 375 insertions(+), 121 deletions(-) diff --git a/commands/debug/debug.go b/commands/debug/debug.go index 69715f2814b..0681b77c53f 100644 --- a/commands/debug/debug.go +++ b/commands/debug/debug.go @@ -158,13 +158,18 @@ func getCommandLine(req *rpc.GetDebugConfigRequest, pme *packagemanager.Explorer // Extract path to GDB Server switch debugInfo.GetServer() { case "openocd": + var openocdConf rpc.DebugOpenOCDServerConfiguration + if err := debugInfo.ServerConfiguration.UnmarshalTo(&openocdConf); err != nil { + return nil, err + } + serverCmd := fmt.Sprintf(`target extended-remote | "%s"`, debugInfo.ServerPath) - if cfg := debugInfo.ServerConfiguration["scripts_dir"]; cfg != "" { + if cfg := openocdConf.GetScriptsDir(); cfg != "" { serverCmd += fmt.Sprintf(` -s "%s"`, cfg) } - if script := debugInfo.ServerConfiguration["script"]; script != "" { + for _, script := range openocdConf.GetScripts() { serverCmd += fmt.Sprintf(` --file "%s"`, script) } diff --git a/commands/debug/debug_info.go b/commands/debug/debug_info.go index 89940001ea7..081188aab52 100644 --- a/commands/debug/debug_info.go +++ b/commands/debug/debug_info.go @@ -28,6 +28,7 @@ import ( "github.com/arduino/go-paths-helper" "github.com/arduino/go-properties-orderedmap" "github.com/sirupsen/logrus" + "google.golang.org/protobuf/types/known/anypb" ) // GetDebugConfig returns metadata to start debugging with the specified board @@ -150,14 +151,43 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl server := debugProperties.Get("server") toolchain := debugProperties.Get("toolchain") + + var serverConfiguration anypb.Any + switch server { + case "openocd": + openocdProperties := debugProperties.SubTree("server." + server) + scripts := openocdProperties.ExtractSubIndexLists("scripts") + if s := openocdProperties.Get("script"); s != "" { + // backward compatibility + scripts = append(scripts, s) + } + openocdConf := &rpc.DebugOpenOCDServerConfiguration{ + Path: openocdProperties.Get("path"), + ScriptsDir: openocdProperties.Get("scripts_dir"), + Scripts: scripts, + } + if err := serverConfiguration.MarshalFrom(openocdConf); err != nil { + return nil, err + } + } + + var toolchainConfiguration anypb.Any + switch toolchain { + case "gcc": + gccConf := &rpc.DebugGCCToolchainConfiguration{} + if err := toolchainConfiguration.MarshalFrom(gccConf); err != nil { + return nil, err + } + } + return &rpc.GetDebugConfigResponse{ Executable: debugProperties.Get("executable"), Server: server, ServerPath: debugProperties.Get("server." + server + ".path"), - ServerConfiguration: debugProperties.SubTree("server." + server).AsMap(), + ServerConfiguration: &serverConfiguration, Toolchain: toolchain, ToolchainPath: debugProperties.Get("toolchain.path"), ToolchainPrefix: debugProperties.Get("toolchain.prefix"), - ToolchainConfiguration: debugProperties.SubTree("toolchain." + toolchain).AsMap(), + ToolchainConfiguration: &toolchainConfiguration, }, nil } diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index e2a953334a8..6b12115c0ff 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -4,6 +4,43 @@ Here you can find a list of migration guides to handle breaking changes between ## 0.35.0 +### CLI `debug --info` changed JSON output. + +The string field `server_configuration.script` is now an array and has been renamed `scripts`, here an example: + +```json +{ + "executable": "/tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.elf", + "toolchain": "gcc", + "toolchain_path": "/home/user/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/", + "toolchain_prefix": "arm-none-eabi-", + "server": "openocd", + "server_path": "/home/user/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd", + "server_configuration": { + "path": "/home/user/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd", + "scripts_dir": "/home/user/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/share/openocd/scripts/", + "scripts": [ + "/home/user/Workspace/arduino-cli/internal/integrationtest/debug/testdata/hardware/my/samd/variants/arduino:mkr1000/openocd_scripts/arduino_zero.cfg" + ] + } +} +``` + +### gRPC `cc.arduino.cli.commands.v1.GetDebugConfigResponse` message has been changed. + +The fields `toolchain_configuration` and `server_configuration` are no more generic `map` but they have +changed type to `goog.protobuf.Any`, the concrete type is assigned at runtime based on the value of `toolchain` and +`server` fields respectively. + +For the moment: + +- only `gcc` is supported for `toolchain`, and the concrete type for `toolchain_configuration` is + `DebugGCCToolchainConfiguration`. +- only `openocd` is supported for `server`, and the concrete type for `server_configuration` is + `DebugOpenOCDServerConfiguration` + +More concrete type may be added in the future as more servers/toolchains support is implemented. + ### gRPC service `cc.arduino.cli.debug.v1` moved to `cc.arduino.cli.commands.v1`. The gRPC service `cc.arduino.cli.debug.v1` has been removed and all gRPC messages and rpc calls have been moved to diff --git a/internal/cli/debug/debug.go b/internal/cli/debug/debug.go index 0787bb6f139..d1fee3e0b9f 100644 --- a/internal/cli/debug/debug.go +++ b/internal/cli/debug/debug.go @@ -19,7 +19,6 @@ import ( "context" "os" "os/signal" - "sort" "github.com/arduino/arduino-cli/commands/debug" "github.com/arduino/arduino-cli/commands/sketch" @@ -29,7 +28,6 @@ import ( "github.com/arduino/arduino-cli/internal/cli/instance" rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" "github.com/arduino/arduino-cli/table" - "github.com/arduino/go-properties-orderedmap" "github.com/fatih/color" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -96,7 +94,7 @@ func runDebugCommand(command *cobra.Command, args []string) { if res, err := debug.GetDebugConfig(context.Background(), debugConfigRequested); err != nil { feedback.Fatal(tr("Error getting Debug info: %v", err), feedback.ErrBadArgument) } else { - feedback.PrintResult(&debugInfoResult{res}) + feedback.PrintResult(newDebugInfoResult(res)) } } else { @@ -117,40 +115,83 @@ func runDebugCommand(command *cobra.Command, args []string) { } type debugInfoResult struct { - info *rpc.GetDebugConfigResponse + Executable string `json:"executable,omitempty"` + Toolchain string `json:"toolchain,omitempty"` + ToolchainPath string `json:"toolchain_path,omitempty"` + ToolchainPrefix string `json:"toolchain_prefix,omitempty"` + ToolchainConfig any `json:"toolchain_configuration,omitempty"` + Server string `json:"server,omitempty"` + ServerPath string `json:"server_path,omitempty"` + ServerConfig any `json:"server_configuration,omitempty"` +} + +type openOcdServerConfigResult struct { + Path string `json:"path,omitempty"` + ScriptsDir string `json:"scripts_dir,omitempty"` + Scripts []string `json:"scripts,omitempty"` +} + +func newDebugInfoResult(info *rpc.GetDebugConfigResponse) *debugInfoResult { + var toolchaingConfig interface{} + var serverConfig interface{} + switch info.Server { + case "openocd": + var openocdConf rpc.DebugOpenOCDServerConfiguration + if err := info.GetServerConfiguration().UnmarshalTo(&openocdConf); err != nil { + feedback.Fatal(tr("Error during Debug: %v", err), feedback.ErrGeneric) + } + serverConfig = &openOcdServerConfigResult{ + Path: openocdConf.Path, + ScriptsDir: openocdConf.ScriptsDir, + Scripts: openocdConf.Scripts, + } + } + return &debugInfoResult{ + Executable: info.Executable, + Toolchain: info.Toolchain, + ToolchainPath: info.ToolchainPath, + ToolchainPrefix: info.ToolchainPrefix, + ToolchainConfig: toolchaingConfig, + Server: info.Server, + ServerPath: info.ServerPath, + ServerConfig: serverConfig, + } } func (r *debugInfoResult) Data() interface{} { - return r.info + return r } func (r *debugInfoResult) String() string { t := table.New() green := color.New(color.FgHiGreen) dimGreen := color.New(color.FgGreen) - t.AddRow(tr("Executable to debug"), table.NewCell(r.info.GetExecutable(), green)) - t.AddRow(tr("Toolchain type"), table.NewCell(r.info.GetToolchain(), green)) - t.AddRow(tr("Toolchain path"), table.NewCell(r.info.GetToolchainPath(), dimGreen)) - t.AddRow(tr("Toolchain prefix"), table.NewCell(r.info.GetToolchainPrefix(), dimGreen)) - if len(r.info.GetToolchainConfiguration()) > 0 { - conf := properties.NewFromHashmap(r.info.GetToolchainConfiguration()) - keys := conf.Keys() - sort.Strings(keys) - t.AddRow(tr("Toolchain custom configurations")) - for _, k := range keys { - t.AddRow(table.NewCell(" - "+k, dimGreen), table.NewCell(conf.Get(k), dimGreen)) - } + t.AddRow(tr("Executable to debug"), table.NewCell(r.Executable, green)) + t.AddRow(tr("Toolchain type"), table.NewCell(r.Toolchain, green)) + t.AddRow(tr("Toolchain path"), table.NewCell(r.ToolchainPath, dimGreen)) + t.AddRow(tr("Toolchain prefix"), table.NewCell(r.ToolchainPrefix, dimGreen)) + switch r.Toolchain { + case "gcc": + // no options available at the moment... + default: } - t.AddRow(tr("GDB Server type"), table.NewCell(r.info.GetServer(), green)) - t.AddRow(tr("GDB Server path"), table.NewCell(r.info.GetServerPath(), dimGreen)) - if len(r.info.GetServerConfiguration()) > 0 { - conf := properties.NewFromHashmap(r.info.GetServerConfiguration()) - keys := conf.Keys() - sort.Strings(keys) - t.AddRow(tr("Configuration options for %s", r.info.GetServer())) - for _, k := range keys { - t.AddRow(table.NewCell(" - "+k, dimGreen), table.NewCell(conf.Get(k), dimGreen)) + t.AddRow(tr("Server type"), table.NewCell(r.Server, green)) + t.AddRow(tr("Server path"), table.NewCell(r.ServerPath, dimGreen)) + + switch r.Server { + case "openocd": + t.AddRow(tr("Configuration options for %s", r.Server)) + openocdConf := r.ServerConfig.(*openOcdServerConfigResult) + if openocdConf.Path != "" { + t.AddRow(" - Path", table.NewCell(openocdConf.Path, dimGreen)) + } + if openocdConf.ScriptsDir != "" { + t.AddRow(" - Scripts Directory", table.NewCell(openocdConf.ScriptsDir, dimGreen)) + } + for _, script := range openocdConf.Scripts { + t.AddRow(" - Script", table.NewCell(script, dimGreen)) } + default: } return t.Render() } diff --git a/rpc/cc/arduino/cli/commands/v1/debug.pb.go b/rpc/cc/arduino/cli/commands/v1/debug.pb.go index 1d2296f6112..593770db80c 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/debug.pb.go @@ -24,6 +24,7 @@ package commands import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" reflect "reflect" sync "sync" ) @@ -291,9 +292,9 @@ type GetDebugConfigResponse struct { // The GDB server directory ServerPath string `protobuf:"bytes,6,opt,name=server_path,json=serverPath,proto3" json:"server_path,omitempty"` // Extra configuration parameters wrt toolchain - ToolchainConfiguration map[string]string `protobuf:"bytes,7,rep,name=toolchain_configuration,json=toolchainConfiguration,proto3" json:"toolchain_configuration,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + ToolchainConfiguration *anypb.Any `protobuf:"bytes,7,opt,name=toolchain_configuration,json=toolchainConfiguration,proto3" json:"toolchain_configuration,omitempty"` // Extra configuration parameters wrt GDB server - ServerConfiguration map[string]string `protobuf:"bytes,8,rep,name=server_configuration,json=serverConfiguration,proto3" json:"server_configuration,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + ServerConfiguration *anypb.Any `protobuf:"bytes,8,opt,name=server_configuration,json=serverConfiguration,proto3" json:"server_configuration,omitempty"` } func (x *GetDebugConfigResponse) Reset() { @@ -370,20 +371,126 @@ func (x *GetDebugConfigResponse) GetServerPath() string { return "" } -func (x *GetDebugConfigResponse) GetToolchainConfiguration() map[string]string { +func (x *GetDebugConfigResponse) GetToolchainConfiguration() *anypb.Any { if x != nil { return x.ToolchainConfiguration } return nil } -func (x *GetDebugConfigResponse) GetServerConfiguration() map[string]string { +func (x *GetDebugConfigResponse) GetServerConfiguration() *anypb.Any { if x != nil { return x.ServerConfiguration } return nil } +// Configurations specific for the 'gcc' toolchain +type DebugGCCToolchainConfiguration struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DebugGCCToolchainConfiguration) Reset() { + *x = DebugGCCToolchainConfiguration{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_commands_v1_debug_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugGCCToolchainConfiguration) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugGCCToolchainConfiguration) ProtoMessage() {} + +func (x *DebugGCCToolchainConfiguration) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_commands_v1_debug_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugGCCToolchainConfiguration.ProtoReflect.Descriptor instead. +func (*DebugGCCToolchainConfiguration) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_commands_v1_debug_proto_rawDescGZIP(), []int{4} +} + +// Configuration specific for the 'openocd` server +type DebugOpenOCDServerConfiguration struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // path to openocd + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + // path to openocd scripts + ScriptsDir string `protobuf:"bytes,2,opt,name=scripts_dir,json=scriptsDir,proto3" json:"scripts_dir,omitempty"` + // list of scripts to execute by openocd + Scripts []string `protobuf:"bytes,3,rep,name=scripts,proto3" json:"scripts,omitempty"` +} + +func (x *DebugOpenOCDServerConfiguration) Reset() { + *x = DebugOpenOCDServerConfiguration{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_commands_v1_debug_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugOpenOCDServerConfiguration) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugOpenOCDServerConfiguration) ProtoMessage() {} + +func (x *DebugOpenOCDServerConfiguration) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_commands_v1_debug_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugOpenOCDServerConfiguration.ProtoReflect.Descriptor instead. +func (*DebugOpenOCDServerConfiguration) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_commands_v1_debug_proto_rawDescGZIP(), []int{5} +} + +func (x *DebugOpenOCDServerConfiguration) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *DebugOpenOCDServerConfiguration) GetScriptsDir() string { + if x != nil { + return x.ScriptsDir + } + return "" +} + +func (x *DebugOpenOCDServerConfiguration) GetScripts() []string { + if x != nil { + return x.Scripts + } + return nil +} + var File_cc_arduino_cli_commands_v1_debug_proto protoreflect.FileDescriptor var file_cc_arduino_cli_commands_v1_debug_proto_rawDesc = []byte{ @@ -396,84 +503,79 @@ var file_cc_arduino_cli_commands_v1_debug_proto_rawDesc = []byte{ 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x56, 0x0a, 0x0d, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, - 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x62, - 0x75, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, - 0x0c, 0x64, 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x72, - 0x75, 0x70, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x73, 0x65, 0x6e, 0x64, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x72, 0x75, 0x70, 0x74, 0x22, 0xa5, 0x02, 0x0a, 0x15, 0x47, 0x65, 0x74, - 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, - 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6b, 0x65, 0x74, - 0x63, 0x68, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, - 0x6b, 0x65, 0x74, 0x63, 0x68, 0x50, 0x61, 0x74, 0x68, 0x12, 0x34, 0x0a, 0x04, 0x70, 0x6f, 0x72, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xa1, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x56, 0x0a, 0x0d, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, - 0x20, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x72, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, - 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, - 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x6d, 0x65, 0x72, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x6d, 0x65, 0x72, - 0x22, 0x39, 0x0a, 0x0d, 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xfe, 0x04, 0x0a, 0x16, - 0x47, 0x65, 0x74, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, - 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, - 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x6f, 0x6c, 0x63, - 0x68, 0x61, 0x69, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, - 0x6e, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x6f, - 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x74, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x74, - 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, - 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1f, - 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x50, 0x61, 0x74, 0x68, 0x12, - 0x87, 0x01, 0x0a, 0x17, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x4e, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, - 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, - 0x65, 0x74, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, + 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0c, 0x64, 0x65, 0x62, 0x75, + 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x25, 0x0a, 0x0e, + 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x72, 0x75, 0x70, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x73, 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x72, + 0x75, 0x70, 0x74, 0x22, 0xa5, 0x02, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x44, 0x65, 0x62, 0x75, 0x67, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, + 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, + 0x71, 0x62, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6b, 0x65, 0x74, 0x63, 0x68, 0x5f, 0x70, 0x61, + 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6b, 0x65, 0x74, 0x63, 0x68, + 0x50, 0x61, 0x74, 0x68, 0x12, 0x34, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, + 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x50, 0x6f, 0x72, 0x74, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, + 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x70, + 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x6d, 0x65, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x6d, 0x65, 0x72, 0x22, 0x39, 0x0a, 0x0d, 0x44, + 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xf9, 0x02, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x44, 0x65, + 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x12, + 0x25, 0x0a, 0x0e, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x70, 0x61, 0x74, + 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x50, 0x61, 0x74, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0f, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x50, 0x72, 0x65, 0x66, 0x69, + 0x78, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x50, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x17, 0x74, 0x6f, + 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x74, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x7e, 0x0a, 0x14, 0x73, 0x65, 0x72, + 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x47, 0x0a, 0x14, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4b, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x13, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x49, 0x0a, 0x1b, 0x54, 0x6f, 0x6f, - 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x46, 0x0a, 0x18, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x48, 0x5a, 0x46, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, - 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, - 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, - 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x13, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x22, 0x20, 0x0a, 0x1e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x47, 0x43, 0x43, 0x54, 0x6f, + 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x70, 0x0a, 0x1f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x4f, 0x70, 0x65, + 0x6e, 0x4f, 0x43, 0x44, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x44, 0x69, 0x72, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, + 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, + 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -490,21 +592,22 @@ func file_cc_arduino_cli_commands_v1_debug_proto_rawDescGZIP() []byte { var file_cc_arduino_cli_commands_v1_debug_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_cc_arduino_cli_commands_v1_debug_proto_goTypes = []interface{}{ - (*DebugRequest)(nil), // 0: cc.arduino.cli.commands.v1.DebugRequest - (*GetDebugConfigRequest)(nil), // 1: cc.arduino.cli.commands.v1.GetDebugConfigRequest - (*DebugResponse)(nil), // 2: cc.arduino.cli.commands.v1.DebugResponse - (*GetDebugConfigResponse)(nil), // 3: cc.arduino.cli.commands.v1.GetDebugConfigResponse - nil, // 4: cc.arduino.cli.commands.v1.GetDebugConfigResponse.ToolchainConfigurationEntry - nil, // 5: cc.arduino.cli.commands.v1.GetDebugConfigResponse.ServerConfigurationEntry - (*Instance)(nil), // 6: cc.arduino.cli.commands.v1.Instance - (*Port)(nil), // 7: cc.arduino.cli.commands.v1.Port + (*DebugRequest)(nil), // 0: cc.arduino.cli.commands.v1.DebugRequest + (*GetDebugConfigRequest)(nil), // 1: cc.arduino.cli.commands.v1.GetDebugConfigRequest + (*DebugResponse)(nil), // 2: cc.arduino.cli.commands.v1.DebugResponse + (*GetDebugConfigResponse)(nil), // 3: cc.arduino.cli.commands.v1.GetDebugConfigResponse + (*DebugGCCToolchainConfiguration)(nil), // 4: cc.arduino.cli.commands.v1.DebugGCCToolchainConfiguration + (*DebugOpenOCDServerConfiguration)(nil), // 5: cc.arduino.cli.commands.v1.DebugOpenOCDServerConfiguration + (*Instance)(nil), // 6: cc.arduino.cli.commands.v1.Instance + (*Port)(nil), // 7: cc.arduino.cli.commands.v1.Port + (*anypb.Any)(nil), // 8: google.protobuf.Any } var file_cc_arduino_cli_commands_v1_debug_proto_depIdxs = []int32{ 1, // 0: cc.arduino.cli.commands.v1.DebugRequest.debug_request:type_name -> cc.arduino.cli.commands.v1.GetDebugConfigRequest 6, // 1: cc.arduino.cli.commands.v1.GetDebugConfigRequest.instance:type_name -> cc.arduino.cli.commands.v1.Instance 7, // 2: cc.arduino.cli.commands.v1.GetDebugConfigRequest.port:type_name -> cc.arduino.cli.commands.v1.Port - 4, // 3: cc.arduino.cli.commands.v1.GetDebugConfigResponse.toolchain_configuration:type_name -> cc.arduino.cli.commands.v1.GetDebugConfigResponse.ToolchainConfigurationEntry - 5, // 4: cc.arduino.cli.commands.v1.GetDebugConfigResponse.server_configuration:type_name -> cc.arduino.cli.commands.v1.GetDebugConfigResponse.ServerConfigurationEntry + 8, // 3: cc.arduino.cli.commands.v1.GetDebugConfigResponse.toolchain_configuration:type_name -> google.protobuf.Any + 8, // 4: cc.arduino.cli.commands.v1.GetDebugConfigResponse.server_configuration:type_name -> google.protobuf.Any 5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name @@ -568,6 +671,30 @@ func file_cc_arduino_cli_commands_v1_debug_proto_init() { return nil } } + file_cc_arduino_cli_commands_v1_debug_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DebugGCCToolchainConfiguration); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cc_arduino_cli_commands_v1_debug_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DebugOpenOCDServerConfiguration); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ diff --git a/rpc/cc/arduino/cli/commands/v1/debug.proto b/rpc/cc/arduino/cli/commands/v1/debug.proto index a95a6379166..f3d42f1d460 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.proto +++ b/rpc/cc/arduino/cli/commands/v1/debug.proto @@ -21,6 +21,7 @@ option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/ import "cc/arduino/cli/commands/v1/common.proto"; import "cc/arduino/cli/commands/v1/port.proto"; +import "google/protobuf/any.proto"; // The top-level message sent by the client for the `Debug` method. // Multiple `DebugRequest` messages can be sent but the first message @@ -87,7 +88,20 @@ message GetDebugConfigResponse { // The GDB server directory string server_path = 6; // Extra configuration parameters wrt toolchain - map toolchain_configuration = 7; + google.protobuf.Any toolchain_configuration = 7; // Extra configuration parameters wrt GDB server - map server_configuration = 8; + google.protobuf.Any server_configuration = 8; +} + +// Configurations specific for the 'gcc' toolchain +message DebugGCCToolchainConfiguration {} + +// Configuration specific for the 'openocd` server +message DebugOpenOCDServerConfiguration { + // path to openocd + string path = 1; + // path to openocd scripts + string scripts_dir = 2; + // list of scripts to execute by openocd + repeated string scripts = 3; } From 8e0e201a34c3507d57444bf5618688201164da5a Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 4 Oct 2023 16:29:42 +0200 Subject: [PATCH 2/8] Added integration test --- internal/integrationtest/debug/debug_test.go | 44 +++++++++++++++++++ .../testdata/hardware/my/samd/boards.txt | 35 +++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index f58665d8166..64b038264f5 100644 --- a/internal/integrationtest/debug/debug_test.go +++ b/internal/integrationtest/debug/debug_test.go @@ -19,7 +19,9 @@ import ( "testing" "github.com/arduino/arduino-cli/internal/integrationtest" + "github.com/arduino/go-paths-helper" "github.com/stretchr/testify/require" + "go.bug.st/testifyjson/requirejson" ) func TestDebug(t *testing.T) { @@ -37,6 +39,7 @@ func TestDebug(t *testing.T) { integrationtest.CLISubtests{ {"Start", testDebuggerStarts}, {"WithPdeSketchStarts", testDebuggerWithPdeSketchStarts}, + {"DebugInformation", testAllDebugInformation}, }.Run(t, env, cli) } @@ -88,3 +91,44 @@ func testDebuggerWithPdeSketchStarts(t *testing.T, env *integrationtest.Environm _, _, err = cli.Run("debug", "-b", fqbn, "-P", programmer, filePde.String(), "--info") require.NoError(t, err) } + +func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { + // Create sketch for testing + sketchPath := cli.DataDir().Join("DebuggerStartTest") + defer sketchPath.RemoveAll() + _, _, err := cli.Run("sketch", "new", sketchPath.String()) + require.NoError(t, err) + + // Install custom core + customHw, err := paths.New("testdata", "hardware").Abs() + require.NoError(t, err) + err = customHw.CopyDirTo(cli.SketchbookDir().Join("hardware")) + require.NoError(t, err) + + // Build sketch + fqbn := "my:samd:my" + _, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--format", "json") + require.NoError(t, err) + + // Starts debugger + jsonDebugOut, _, err := cli.Run("debug", "-b", fqbn, "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json") + require.NoError(t, err) + debugOut := requirejson.Parse(t, jsonDebugOut) + debugOut.MustContain(` + { + "toolchain": "gcc", + "toolchain_path": "gcc-path", + "toolchain_prefix": "gcc-prefix", + "server": "openocd", + "server_path": "openocd-path", + "server_configuration": { + "path": "openocd-path", + "scripts_dir": "openocd-scripts-dir", + "scripts": [ + "first", + "second", + "third" + ] + } + }`) +} diff --git a/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt new file mode 100644 index 00000000000..24915e52702 --- /dev/null +++ b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt @@ -0,0 +1,35 @@ +my.name=My Cool Board +my.vid.0=0x2341 +my.pid.0=0x804e +my.upload_port.0.vid=0x2341 +my.upload_port.0.pid=0x804e +my.upload.tool=bossac +my.upload.tool.default=bossac +my.upload.tool.network=arduino_ota +my.upload.protocol=sam-ba +my.upload.maximum_size=262144 +my.upload.maximum_data_size=32768 +my.upload.use_1200bps_touch=true +my.upload.wait_for_upload_port=true +my.upload.native_usb=true +my.build.mcu=cortex-m0plus +my.build.f_cpu=48000000L +my.build.usb_product="Arduino MKR1000" +my.build.usb_manufacturer="Arduino LLC" +my.build.board=SAMD_MY +my.build.core=arduino:arduino +my.build.extra_flags=-DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ {build.usb_flags} +my.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +my.build.openocdscript=openocd_scripts/arduino_zero.cfg +my.build.variant=arduino:mkr1000 +my.build.vid=0x2341 +my.build.pid=0x804e + +my.debug.toolchain.path=gcc-path +my.debug.toolchain.prefix=gcc-prefix +my.debug.server.openocd.path=openocd-path +my.debug.server.openocd.scripts_dir=openocd-scripts-dir +my.debug.server.openocd.script= +my.debug.server.openocd.scripts.0=first +my.debug.server.openocd.scripts.1=second +my.debug.server.openocd.scripts.2=third From 78197c062abb3221b418d0ee37de7f73a09821e9 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 4 Oct 2023 17:12:32 +0200 Subject: [PATCH 3/8] Added the possibility to provide cortex-debug custom configs --- commands/debug/debug_info.go | 46 +++++++++++++++++++ internal/cli/debug/debug.go | 41 ++++++++++------- internal/integrationtest/debug/debug_test.go | 16 +++++++ .../testdata/hardware/my/samd/boards.txt | 10 ++++ rpc/cc/arduino/cli/commands/v1/debug.pb.go | 46 ++++++++++++------- rpc/cc/arduino/cli/commands/v1/debug.proto | 3 ++ 6 files changed, 130 insertions(+), 32 deletions(-) diff --git a/commands/debug/debug_info.go b/commands/debug/debug_info.go index 081188aab52..89e19e6b58e 100644 --- a/commands/debug/debug_info.go +++ b/commands/debug/debug_info.go @@ -17,6 +17,8 @@ package debug import ( "context" + "encoding/json" + "regexp" "strings" "github.com/arduino/arduino-cli/arduino" @@ -180,6 +182,10 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl } } + cortexDebugCustomJson := "" + if cortexDebugProps := debugProperties.SubTree("cortex-debug.custom"); cortexDebugProps.Size() > 0 { + cortexDebugCustomJson = convertToJsonMap(cortexDebugProps) + } return &rpc.GetDebugConfigResponse{ Executable: debugProperties.Get("executable"), Server: server, @@ -189,5 +195,45 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl ToolchainPath: debugProperties.Get("toolchain.path"), ToolchainPrefix: debugProperties.Get("toolchain.prefix"), ToolchainConfiguration: &toolchainConfiguration, + CortexDebugCustomJson: cortexDebugCustomJson, }, nil } + +// Extract a JSON from a given properies.Map and converts key-indexed arrays +// like: +// +// my.indexed.array.0=first +// my.indexed.array.1=second +// my.indexed.array.2=third +// +// into the corresponding JSON arrays. +func convertToJsonMap(in *properties.Map) string { + // XXX: Maybe this method could be a good candidate for propertis.Map? + + // Find the values that should be kept as is, and the indexed arrays + // that should be later converted into arrays. + arraysKeys := map[string]bool{} + stringKeys := []string{} + trailingNumberMatcher := regexp.MustCompile(`^(.*)\.[0-9]+$`) + for _, k := range in.Keys() { + match := trailingNumberMatcher.FindAllStringSubmatch(k, -1) + if len(match) > 0 && len(match[0]) > 1 { + arraysKeys[match[0][1]] = true + } else { + stringKeys = append(stringKeys, k) + } + } + + // Compose a map that can be later marshaled into JSON keeping + // the arrays where they are expected to be. + res := map[string]any{} + for _, k := range stringKeys { + res[k] = in.Get(k) + } + for k := range arraysKeys { + res[k] = in.ExtractSubIndexLists(k) + } + + data, _ := json.MarshalIndent(res, "", " ") + return string(data) +} diff --git a/internal/cli/debug/debug.go b/internal/cli/debug/debug.go index d1fee3e0b9f..1d2c36da07d 100644 --- a/internal/cli/debug/debug.go +++ b/internal/cli/debug/debug.go @@ -17,6 +17,7 @@ package debug import ( "context" + "encoding/json" "os" "os/signal" @@ -115,14 +116,15 @@ func runDebugCommand(command *cobra.Command, args []string) { } type debugInfoResult struct { - Executable string `json:"executable,omitempty"` - Toolchain string `json:"toolchain,omitempty"` - ToolchainPath string `json:"toolchain_path,omitempty"` - ToolchainPrefix string `json:"toolchain_prefix,omitempty"` - ToolchainConfig any `json:"toolchain_configuration,omitempty"` - Server string `json:"server,omitempty"` - ServerPath string `json:"server_path,omitempty"` - ServerConfig any `json:"server_configuration,omitempty"` + Executable string `json:"executable,omitempty"` + Toolchain string `json:"toolchain,omitempty"` + ToolchainPath string `json:"toolchain_path,omitempty"` + ToolchainPrefix string `json:"toolchain_prefix,omitempty"` + ToolchainConfig any `json:"toolchain_configuration,omitempty"` + Server string `json:"server,omitempty"` + ServerPath string `json:"server_path,omitempty"` + ServerConfig any `json:"server_configuration,omitempty"` + CortexDebugCustomConfig any `json:"cortex-debug_custom_configuration,omitempty"` } type openOcdServerConfigResult struct { @@ -146,15 +148,22 @@ func newDebugInfoResult(info *rpc.GetDebugConfigResponse) *debugInfoResult { Scripts: openocdConf.Scripts, } } + var cortexDebugCustomConfig any + if info.CortexDebugCustomJson != "" { + if err := json.Unmarshal([]byte(info.CortexDebugCustomJson), &cortexDebugCustomConfig); err != nil { + feedback.Fatal(tr("Error during Debug: %v", err), feedback.ErrGeneric) + } + } return &debugInfoResult{ - Executable: info.Executable, - Toolchain: info.Toolchain, - ToolchainPath: info.ToolchainPath, - ToolchainPrefix: info.ToolchainPrefix, - ToolchainConfig: toolchaingConfig, - Server: info.Server, - ServerPath: info.ServerPath, - ServerConfig: serverConfig, + Executable: info.Executable, + Toolchain: info.Toolchain, + ToolchainPath: info.ToolchainPath, + ToolchainPrefix: info.ToolchainPrefix, + ToolchainConfig: toolchaingConfig, + Server: info.Server, + ServerPath: info.ServerPath, + ServerConfig: serverConfig, + CortexDebugCustomConfig: cortexDebugCustomConfig, } } diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index 64b038264f5..730ddd4f40a 100644 --- a/internal/integrationtest/debug/debug_test.go +++ b/internal/integrationtest/debug/debug_test.go @@ -129,6 +129,22 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli "second", "third" ] + }, + "cortex-debug_custom_configuration": { + "anotherStringParamer": "hellooo", + "overrideRestartCommands": [ + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "c" + ], + "postAttachCommands": [ + "set remote hardware-watchpoint-limit 2", + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "c" + ] } }`) } diff --git a/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt index 24915e52702..a1aeaf22e57 100644 --- a/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt +++ b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt @@ -33,3 +33,13 @@ my.debug.server.openocd.script= my.debug.server.openocd.scripts.0=first my.debug.server.openocd.scripts.1=second my.debug.server.openocd.scripts.2=third +my.debug.cortex-debug.custom.postAttachCommands.0=set remote hardware-watchpoint-limit 2 +my.debug.cortex-debug.custom.postAttachCommands.1=monitor reset halt +my.debug.cortex-debug.custom.postAttachCommands.2=monitor gdb_sync +my.debug.cortex-debug.custom.postAttachCommands.3=thb setup +my.debug.cortex-debug.custom.postAttachCommands.4=c +my.debug.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt +my.debug.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync +my.debug.cortex-debug.custom.overrideRestartCommands.2=thb setup +my.debug.cortex-debug.custom.overrideRestartCommands.3=c +my.debug.cortex-debug.custom.anotherStringParamer=hellooo diff --git a/rpc/cc/arduino/cli/commands/v1/debug.pb.go b/rpc/cc/arduino/cli/commands/v1/debug.pb.go index 593770db80c..91b59d2edac 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/debug.pb.go @@ -295,6 +295,9 @@ type GetDebugConfigResponse struct { ToolchainConfiguration *anypb.Any `protobuf:"bytes,7,opt,name=toolchain_configuration,json=toolchainConfiguration,proto3" json:"toolchain_configuration,omitempty"` // Extra configuration parameters wrt GDB server ServerConfiguration *anypb.Any `protobuf:"bytes,8,opt,name=server_configuration,json=serverConfiguration,proto3" json:"server_configuration,omitempty"` + // cortex-debug custom JSON configuration, it is provided as is from + // the platform developers. + CortexDebugCustomJson string `protobuf:"bytes,9,opt,name=cortex_debug_custom_json,json=cortexDebugCustomJson,proto3" json:"cortex_debug_custom_json,omitempty"` } func (x *GetDebugConfigResponse) Reset() { @@ -385,6 +388,13 @@ func (x *GetDebugConfigResponse) GetServerConfiguration() *anypb.Any { return nil } +func (x *GetDebugConfigResponse) GetCortexDebugCustomJson() string { + if x != nil { + return x.CortexDebugCustomJson + } + return "" +} + // Configurations specific for the 'gcc' toolchain type DebugGCCToolchainConfiguration struct { state protoimpl.MessageState @@ -537,7 +547,7 @@ var file_cc_arduino_cli_commands_v1_debug_proto_rawDesc = []byte{ 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xf9, 0x02, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x44, 0x65, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xb2, 0x03, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, @@ -561,21 +571,25 @@ var file_cc_arduino_cli_commands_v1_debug_proto_rawDesc = []byte{ 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x13, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0x20, 0x0a, 0x1e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x47, 0x43, 0x43, 0x54, 0x6f, - 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x70, 0x0a, 0x1f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x4f, 0x70, 0x65, - 0x6e, 0x4f, 0x43, 0x44, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x44, 0x69, 0x72, 0x12, 0x18, 0x0a, 0x07, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, - 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x18, 0x63, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x64, 0x65, 0x62, + 0x75, 0x67, 0x5f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x63, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x44, 0x65, 0x62, 0x75, + 0x67, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4a, 0x73, 0x6f, 0x6e, 0x22, 0x20, 0x0a, 0x1e, 0x44, + 0x65, 0x62, 0x75, 0x67, 0x47, 0x43, 0x43, 0x54, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x70, 0x0a, + 0x1f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x4f, 0x70, 0x65, 0x6e, 0x4f, 0x43, 0x44, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x5f, + 0x64, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x73, 0x44, 0x69, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x42, + 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, + 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, + 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, + 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/rpc/cc/arduino/cli/commands/v1/debug.proto b/rpc/cc/arduino/cli/commands/v1/debug.proto index f3d42f1d460..435fe824561 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.proto +++ b/rpc/cc/arduino/cli/commands/v1/debug.proto @@ -91,6 +91,9 @@ message GetDebugConfigResponse { google.protobuf.Any toolchain_configuration = 7; // Extra configuration parameters wrt GDB server google.protobuf.Any server_configuration = 8; + // cortex-debug custom JSON configuration, it is provided as is from + // the platform developers. + string cortex_debug_custom_json = 9; } // Configurations specific for the 'gcc' toolchain From 9bf152335832bbd8f539e24e014c9e84b7422103 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 4 Oct 2023 17:39:38 +0200 Subject: [PATCH 4/8] Added svd-file debug option --- commands/debug/debug_info.go | 1 + internal/cli/debug/debug.go | 5 +++ internal/integrationtest/debug/debug_test.go | 1 + .../testdata/hardware/my/samd/boards.txt | 1 + rpc/cc/arduino/cli/commands/v1/debug.pb.go | 44 ++++++++++++------- rpc/cc/arduino/cli/commands/v1/debug.proto | 2 + 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/commands/debug/debug_info.go b/commands/debug/debug_info.go index 89e19e6b58e..8f9c442611a 100644 --- a/commands/debug/debug_info.go +++ b/commands/debug/debug_info.go @@ -191,6 +191,7 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl Server: server, ServerPath: debugProperties.Get("server." + server + ".path"), ServerConfiguration: &serverConfiguration, + SvdFile: debugProperties.Get("svd_file"), Toolchain: toolchain, ToolchainPath: debugProperties.Get("toolchain.path"), ToolchainPrefix: debugProperties.Get("toolchain.prefix"), diff --git a/internal/cli/debug/debug.go b/internal/cli/debug/debug.go index 1d2c36da07d..40d04f28b5e 100644 --- a/internal/cli/debug/debug.go +++ b/internal/cli/debug/debug.go @@ -124,6 +124,7 @@ type debugInfoResult struct { Server string `json:"server,omitempty"` ServerPath string `json:"server_path,omitempty"` ServerConfig any `json:"server_configuration,omitempty"` + SvdFile string `json:"svd_file,omitempty"` CortexDebugCustomConfig any `json:"cortex-debug_custom_configuration,omitempty"` } @@ -163,6 +164,7 @@ func newDebugInfoResult(info *rpc.GetDebugConfigResponse) *debugInfoResult { Server: info.Server, ServerPath: info.ServerPath, ServerConfig: serverConfig, + SvdFile: info.SvdFile, CortexDebugCustomConfig: cortexDebugCustomConfig, } } @@ -179,6 +181,9 @@ func (r *debugInfoResult) String() string { t.AddRow(tr("Toolchain type"), table.NewCell(r.Toolchain, green)) t.AddRow(tr("Toolchain path"), table.NewCell(r.ToolchainPath, dimGreen)) t.AddRow(tr("Toolchain prefix"), table.NewCell(r.ToolchainPrefix, dimGreen)) + if r.SvdFile != "" { + t.AddRow(tr("SVD file path"), table.NewCell(r.SvdFile, dimGreen)) + } switch r.Toolchain { case "gcc": // no options available at the moment... diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index 730ddd4f40a..18b0493e575 100644 --- a/internal/integrationtest/debug/debug_test.go +++ b/internal/integrationtest/debug/debug_test.go @@ -130,6 +130,7 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli "third" ] }, + "svd_file": "svd-file", "cortex-debug_custom_configuration": { "anotherStringParamer": "hellooo", "overrideRestartCommands": [ diff --git a/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt index a1aeaf22e57..3ef42eb8179 100644 --- a/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt +++ b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt @@ -43,3 +43,4 @@ my.debug.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync my.debug.cortex-debug.custom.overrideRestartCommands.2=thb setup my.debug.cortex-debug.custom.overrideRestartCommands.3=c my.debug.cortex-debug.custom.anotherStringParamer=hellooo +my.debug.svd_file=svd-file diff --git a/rpc/cc/arduino/cli/commands/v1/debug.pb.go b/rpc/cc/arduino/cli/commands/v1/debug.pb.go index 91b59d2edac..609c888c5f1 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/debug.pb.go @@ -298,6 +298,8 @@ type GetDebugConfigResponse struct { // cortex-debug custom JSON configuration, it is provided as is from // the platform developers. CortexDebugCustomJson string `protobuf:"bytes,9,opt,name=cortex_debug_custom_json,json=cortexDebugCustomJson,proto3" json:"cortex_debug_custom_json,omitempty"` + // the SVD file to use + SvdFile string `protobuf:"bytes,10,opt,name=svd_file,json=svdFile,proto3" json:"svd_file,omitempty"` } func (x *GetDebugConfigResponse) Reset() { @@ -395,6 +397,13 @@ func (x *GetDebugConfigResponse) GetCortexDebugCustomJson() string { return "" } +func (x *GetDebugConfigResponse) GetSvdFile() string { + if x != nil { + return x.SvdFile + } + return "" +} + // Configurations specific for the 'gcc' toolchain type DebugGCCToolchainConfiguration struct { state protoimpl.MessageState @@ -547,7 +556,7 @@ var file_cc_arduino_cli_commands_v1_debug_proto_rawDesc = []byte{ 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xb2, 0x03, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x44, 0x65, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xcd, 0x03, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, @@ -574,22 +583,23 @@ var file_cc_arduino_cli_commands_v1_debug_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x18, 0x63, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x63, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x44, 0x65, 0x62, 0x75, - 0x67, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4a, 0x73, 0x6f, 0x6e, 0x22, 0x20, 0x0a, 0x1e, 0x44, - 0x65, 0x62, 0x75, 0x67, 0x47, 0x43, 0x43, 0x54, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x70, 0x0a, - 0x1f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x4f, 0x70, 0x65, 0x6e, 0x4f, 0x43, 0x44, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x5f, - 0x64, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x73, 0x44, 0x69, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x42, - 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, - 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, - 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, - 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, - 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x67, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4a, 0x73, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x73, + 0x76, 0x64, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, + 0x76, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x22, 0x20, 0x0a, 0x1e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x47, + 0x43, 0x43, 0x54, 0x6f, 0x6f, 0x6c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x70, 0x0a, 0x1f, 0x44, 0x65, 0x62, 0x75, + 0x67, 0x4f, 0x70, 0x65, 0x6e, 0x4f, 0x43, 0x44, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, + 0x1f, 0x0a, 0x0b, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x44, 0x69, 0x72, + 0x12, 0x18, 0x0a, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, + 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/rpc/cc/arduino/cli/commands/v1/debug.proto b/rpc/cc/arduino/cli/commands/v1/debug.proto index 435fe824561..b183abb0410 100644 --- a/rpc/cc/arduino/cli/commands/v1/debug.proto +++ b/rpc/cc/arduino/cli/commands/v1/debug.proto @@ -94,6 +94,8 @@ message GetDebugConfigResponse { // cortex-debug custom JSON configuration, it is provided as is from // the platform developers. string cortex_debug_custom_json = 9; + // the SVD file to use + string svd_file = 10; } // Configurations specific for the 'gcc' toolchain From a015979ce7615fb3a77e91c83b019ad03c689bb1 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 4 Oct 2023 18:11:48 +0200 Subject: [PATCH 5/8] Added textual print of custom cortex-debug config --- internal/cli/debug/debug.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/cli/debug/debug.go b/internal/cli/debug/debug.go index 40d04f28b5e..a2e2f78bbae 100644 --- a/internal/cli/debug/debug.go +++ b/internal/cli/debug/debug.go @@ -207,5 +207,10 @@ func (r *debugInfoResult) String() string { } default: } + if r.CortexDebugCustomConfig != nil { + t.AddRow(tr("Custom configuration for cortex-debug IDE plugin:")) + data, _ := json.MarshalIndent(r.CortexDebugCustomConfig, " ", " ") + return t.Render() + " " + string(data) + } return t.Render() } From 510ae54306f81f0b4aa1ed2cbeec0dd69ae839fb Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 5 Oct 2023 17:44:56 +0200 Subject: [PATCH 6/8] Updated docs --- docs/platform-specification.md | 63 +++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/docs/platform-specification.md b/docs/platform-specification.md index 98921400f66..3dad47df61c 100644 --- a/docs/platform-specification.md +++ b/docs/platform-specification.md @@ -1335,13 +1335,74 @@ the [core platform](#platform-terminology) is not used at all in defining the re actions. When using Arduino development software other than the Arduino IDE, the handling of properties from the core platform's platform.txt is done as usual. -### Sketch debugging configuration +## Sketch debugging configuration Starting from Arduino CLI 0.9.0 / Arduino IDE 2.x, sketch debugging support is available for platforms. The debug action is triggered when the user clicks the Debug button in the Arduino IDE or runs the [`arduino-cli debug`](commands/arduino-cli_debug.md) command. +Since opening a debug session requires the orchestration of numerous tools, the CLI/IDE will take care of that duty: +differently from the upload actions, there is no need for the platform to provide debug recipes, the only requirement is +to provide some debug configuration directives. + +### Debugger configuration directives + +All the debug directives are grouped under the `debug.*` directives. Here is the complete list of the supported +directives: + +- `debug.toolchain`: is a unique identifier of the required toolchain, currently we support `gcc` (and compatible) only +- `debug.toolchain.path`: is the absolute path to the toolchain directory +- `debug.toolchain.prefix`: is the prefix of the toolchain (for example `arm-none-eabi-`) +- `debug.server`: is a unique identifier of the required debug server, currently we support only `openocd` +- `debug.svd_file`: is the absolute path to the SVD descriptor. + +OpenOCD server specific confgiurations: + +- `debug.server.openocd.path`: is the absolute path to the OpenOCD directory +- `debug.server.openocd.scripts_dir`: is the absolute path to the OpenOCD scripts directory +- `debug.server.openocd.scripts.N`: is a list of OpenOCD scripts to run (where N is a number starting from 0) + +### Custom config for Cortext-debug plugin for Arduino IDE + +The Arduino IDE uses cortex-debug plugin to start a debugging session. The IDE creates a `launch.json` file that is +needed to start the debugging via the cortex-debug plugin. To give the platform developers more flexibility, it is +allowed to pass any extra arbitrary setup to `launch.json` generated by the IDE. To allow this the directives under the +group `debug.cortex-debug.custom.*` are converted into JSON and added to the generated `launch.json` as-is. Moreover, if +a directive has a key with a numeric suffix, it is converted into a JSON array. + +For example the following directives: + +``` +debug.cortex-debug.custom.postAttachCommands.0=set remote hardware-watchpoint-limit 2 +debug.cortex-debug.custom.postAttachCommands.1=monitor reset halt +debug.cortex-debug.custom.postAttachCommands.2=monitor gdb_sync +debug.cortex-debug.custom.postAttachCommands.3=thb setup +debug.cortex-debug.custom.postAttachCommands.4=c +debug.cortex-debug.custom.overrideRestartCommands.0=monitor reset halt +debug.cortex-debug.custom.overrideRestartCommands.1=monitor gdb_sync +debug.cortex-debug.custom.overrideRestartCommands.2=thb setup +debug.cortex-debug.custom.overrideRestartCommands.3=c +``` + +will result in the following JSON to be merged in the Arduino IDE generated `launch.json`: + +```json +{ + "anotherStringParamer": "hellooo", + "overrideRestartCommands": ["monitor reset halt", "monitor gdb_sync", "thb setup", "c"], + "postAttachCommands": [ + "set remote hardware-watchpoint-limit 2", + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "c" + ] +} +``` + +### Optimization level for debugging + The compiler optimization level that is appropriate for normal usage will often not provide a good experience while debugging. For this reason, it may be helpful to use different compiler flags when compiling a sketch for use with the debugger. The flags for use when compiling for debugging can be defined via the **compiler.optimization_flags.debug** From 32d46c03eda6dec26e8b1733ceaad5cb31a102bf Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 9 Oct 2023 14:23:33 +0200 Subject: [PATCH 7/8] Apply suggestions from code review Co-authored-by: Umberto Baldi <34278123+umbynos@users.noreply.github.com> --- docs/platform-specification.md | 3 +-- internal/cli/debug/debug.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/platform-specification.md b/docs/platform-specification.md index 3dad47df61c..52fa4379942 100644 --- a/docs/platform-specification.md +++ b/docs/platform-specification.md @@ -1357,7 +1357,7 @@ directives: - `debug.server`: is a unique identifier of the required debug server, currently we support only `openocd` - `debug.svd_file`: is the absolute path to the SVD descriptor. -OpenOCD server specific confgiurations: +OpenOCD server specific configurations: - `debug.server.openocd.path`: is the absolute path to the OpenOCD directory - `debug.server.openocd.scripts_dir`: is the absolute path to the OpenOCD scripts directory @@ -1389,7 +1389,6 @@ will result in the following JSON to be merged in the Arduino IDE generated `lau ```json { - "anotherStringParamer": "hellooo", "overrideRestartCommands": ["monitor reset halt", "monitor gdb_sync", "thb setup", "c"], "postAttachCommands": [ "set remote hardware-watchpoint-limit 2", diff --git a/internal/cli/debug/debug.go b/internal/cli/debug/debug.go index a2e2f78bbae..69d9ddd716c 100644 --- a/internal/cli/debug/debug.go +++ b/internal/cli/debug/debug.go @@ -135,7 +135,7 @@ type openOcdServerConfigResult struct { } func newDebugInfoResult(info *rpc.GetDebugConfigResponse) *debugInfoResult { - var toolchaingConfig interface{} + var toolchainConfig interface{} var serverConfig interface{} switch info.Server { case "openocd": @@ -160,7 +160,7 @@ func newDebugInfoResult(info *rpc.GetDebugConfigResponse) *debugInfoResult { Toolchain: info.Toolchain, ToolchainPath: info.ToolchainPath, ToolchainPrefix: info.ToolchainPrefix, - ToolchainConfig: toolchaingConfig, + ToolchainConfig: toolchainConfig, Server: info.Server, ServerPath: info.ServerPath, ServerConfig: serverConfig, From f088a76252454445779b282030e44a97efe21ee1 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 9 Oct 2023 14:44:59 +0200 Subject: [PATCH 8/8] Added integration test for programmer selection --- internal/integrationtest/debug/debug_test.go | 117 ++++++++++++------ .../testdata/hardware/my/samd/programmers.txt | 4 + 2 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 internal/integrationtest/debug/testdata/hardware/my/samd/programmers.txt diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index 18b0493e575..8dd63279109 100644 --- a/internal/integrationtest/debug/debug_test.go +++ b/internal/integrationtest/debug/debug_test.go @@ -110,42 +110,85 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli _, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--format", "json") require.NoError(t, err) - // Starts debugger - jsonDebugOut, _, err := cli.Run("debug", "-b", fqbn, "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json") - require.NoError(t, err) - debugOut := requirejson.Parse(t, jsonDebugOut) - debugOut.MustContain(` { - "toolchain": "gcc", - "toolchain_path": "gcc-path", - "toolchain_prefix": "gcc-prefix", - "server": "openocd", - "server_path": "openocd-path", - "server_configuration": { - "path": "openocd-path", - "scripts_dir": "openocd-scripts-dir", - "scripts": [ - "first", - "second", - "third" - ] - }, - "svd_file": "svd-file", - "cortex-debug_custom_configuration": { - "anotherStringParamer": "hellooo", - "overrideRestartCommands": [ - "monitor reset halt", - "monitor gdb_sync", - "thb setup", - "c" - ], - "postAttachCommands": [ - "set remote hardware-watchpoint-limit 2", - "monitor reset halt", - "monitor gdb_sync", - "thb setup", - "c" - ] - } - }`) + // Starts debugger + jsonDebugOut, _, err := cli.Run("debug", "-b", fqbn, "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json") + require.NoError(t, err) + debugOut := requirejson.Parse(t, jsonDebugOut) + debugOut.MustContain(` + { + "toolchain": "gcc", + "toolchain_path": "gcc-path", + "toolchain_prefix": "gcc-prefix", + "server": "openocd", + "server_path": "openocd-path", + "server_configuration": { + "path": "openocd-path", + "scripts_dir": "openocd-scripts-dir", + "scripts": [ + "first", + "second", + "third" + ] + }, + "svd_file": "svd-file", + "cortex-debug_custom_configuration": { + "anotherStringParamer": "hellooo", + "overrideRestartCommands": [ + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "c" + ], + "postAttachCommands": [ + "set remote hardware-watchpoint-limit 2", + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "c" + ] + } + }`) + } + + // Starts debugger with another programmer + { + jsonDebugOut, _, err := cli.Run("debug", "-b", fqbn, "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json") + require.NoError(t, err) + debugOut := requirejson.Parse(t, jsonDebugOut) + debugOut.MustContain(` + { + "toolchain": "gcc", + "toolchain_path": "gcc-path", + "toolchain_prefix": "gcc-prefix", + "server": "openocd", + "server_path": "openocd-path", + "server_configuration": { + "path": "openocd-path", + "scripts_dir": "openocd-scripts-dir", + "scripts": [ + "first", + "second", + "cold_ice_script" + ] + }, + "svd_file": "svd-file", + "cortex-debug_custom_configuration": { + "anotherStringParamer": "hellooo", + "overrideRestartCommands": [ + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "c" + ], + "postAttachCommands": [ + "set remote hardware-watchpoint-limit 2", + "monitor reset halt", + "monitor gdb_sync", + "thb setup", + "c" + ] + } + }`) + } } diff --git a/internal/integrationtest/debug/testdata/hardware/my/samd/programmers.txt b/internal/integrationtest/debug/testdata/hardware/my/samd/programmers.txt new file mode 100644 index 00000000000..bc27e71a3ca --- /dev/null +++ b/internal/integrationtest/debug/testdata/hardware/my/samd/programmers.txt @@ -0,0 +1,4 @@ + +# this programmer overrides the third script +my_cold_ice.name=Cold ICE Tea +my_cold_ice.debug.server.openocd.scripts.2=cold_ice_script