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..8f9c442611a 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" @@ -28,6 +30,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 +153,88 @@ 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 + } + } + + cortexDebugCustomJson := "" + if cortexDebugProps := debugProperties.SubTree("cortex-debug.custom"); cortexDebugProps.Size() > 0 { + cortexDebugCustomJson = convertToJsonMap(cortexDebugProps) + } return &rpc.GetDebugConfigResponse{ Executable: debugProperties.Get("executable"), Server: server, ServerPath: debugProperties.Get("server." + server + ".path"), - ServerConfiguration: debugProperties.SubTree("server." + server).AsMap(), + ServerConfiguration: &serverConfiguration, + SvdFile: debugProperties.Get("svd_file"), Toolchain: toolchain, ToolchainPath: debugProperties.Get("toolchain.path"), ToolchainPrefix: debugProperties.Get("toolchain.prefix"), - ToolchainConfiguration: debugProperties.SubTree("toolchain." + toolchain).AsMap(), + 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/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/docs/platform-specification.md b/docs/platform-specification.md index 98921400f66..52fa4379942 100644 --- a/docs/platform-specification.md +++ b/docs/platform-specification.md @@ -1335,13 +1335,73 @@ 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 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 +- `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 +{ + "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** diff --git a/internal/cli/debug/debug.go b/internal/cli/debug/debug.go index 0787bb6f139..69d9ddd716c 100644 --- a/internal/cli/debug/debug.go +++ b/internal/cli/debug/debug.go @@ -17,9 +17,9 @@ package debug import ( "context" + "encoding/json" "os" "os/signal" - "sort" "github.com/arduino/arduino-cli/commands/debug" "github.com/arduino/arduino-cli/commands/sketch" @@ -29,7 +29,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 +95,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 +116,101 @@ 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"` + SvdFile string `json:"svd_file,omitempty"` + CortexDebugCustomConfig any `json:"cortex-debug_custom_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 toolchainConfig 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, + } + } + 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: toolchainConfig, + Server: info.Server, + ServerPath: info.ServerPath, + ServerConfig: serverConfig, + SvdFile: info.SvdFile, + CortexDebugCustomConfig: cortexDebugCustomConfig, + } } 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)) + if r.SvdFile != "" { + t.AddRow(tr("SVD file path"), table.NewCell(r.SvdFile, dimGreen)) } - 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)) + switch r.Toolchain { + case "gcc": + // no options available at the moment... + default: + } + 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: + } + 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() } diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index f58665d8166..8dd63279109 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,104 @@ 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" + ] + }, + "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/boards.txt b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt new file mode 100644 index 00000000000..3ef42eb8179 --- /dev/null +++ b/internal/integrationtest/debug/testdata/hardware/my/samd/boards.txt @@ -0,0 +1,46 @@ +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 +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 +my.debug.svd_file=svd-file 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 diff --git a/rpc/cc/arduino/cli/commands/v1/debug.pb.go b/rpc/cc/arduino/cli/commands/v1/debug.pb.go index 1d2296f6112..609c888c5f1 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,14 @@ 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"` + // 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() { @@ -370,20 +376,140 @@ 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 } +func (x *GetDebugConfigResponse) GetCortexDebugCustomJson() string { + if x != nil { + return x.CortexDebugCustomJson + } + 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 + 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 +522,84 @@ 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, 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, + 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, 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, 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 ( @@ -490,21 +616,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 +695,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..b183abb0410 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,25 @@ 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; + // 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 +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; }