Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d14711e

Browse files
committed
Moved function and removed useless file
1 parent a88fe8c commit d14711e

File tree

2 files changed

+82
-107
lines changed

2 files changed

+82
-107
lines changed

‎commands/service_debug.go‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ import (
1919
"context"
2020
"errors"
2121
"os"
22+
"path/filepath"
23+
"runtime"
2224
"sync/atomic"
2325

26+
"github.com/arduino/arduino-cli/internal/arduino/cores/packagemanager"
2427
"github.com/arduino/arduino-cli/internal/i18n"
2528
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2629
"google.golang.org/grpc/metadata"
@@ -178,3 +181,82 @@ func (s *arduinoCoreServerImpl) Debug(stream rpc.ArduinoCoreService_DebugServer)
178181
}
179182
return sendResult(&rpc.DebugResponse_Result{})
180183
}
184+
185+
// getCommandLine compose a debug command represented by a core recipe
186+
func getCommandLine(req *rpc.GetDebugConfigRequest, pme *packagemanager.Explorer) ([]string, error) {
187+
debugInfo, err := getDebugProperties(req, pme, false)
188+
if err != nil {
189+
return nil, err
190+
}
191+
192+
cmdArgs := []string{}
193+
add := func(s string) { cmdArgs = append(cmdArgs, s) }
194+
195+
// Add path to GDB Client to command line
196+
var gdbPath *paths.Path
197+
switch debugInfo.GetToolchain() {
198+
case "gcc":
199+
gdbexecutable := debugInfo.GetToolchainPrefix() + "-gdb"
200+
if runtime.GOOS == "windows" {
201+
gdbexecutable += ".exe"
202+
}
203+
gdbPath = paths.New(debugInfo.GetToolchainPath()).Join(gdbexecutable)
204+
default:
205+
return nil, &cmderrors.FailedDebugError{Message: i18n.Tr("Toolchain '%s' is not supported", debugInfo.GetToolchain())}
206+
}
207+
add(gdbPath.String())
208+
209+
// Set GDB interpreter (default value should be "console")
210+
gdbInterpreter := req.GetInterpreter()
211+
if gdbInterpreter == "" {
212+
gdbInterpreter = "console"
213+
}
214+
add("--interpreter=" + gdbInterpreter)
215+
if gdbInterpreter != "console" {
216+
add("-ex")
217+
add("set pagination off")
218+
}
219+
220+
// Add extra GDB execution commands
221+
add("-ex")
222+
add("set remotetimeout 5")
223+
224+
// Extract path to GDB Server
225+
switch debugInfo.GetServer() {
226+
case "openocd":
227+
var openocdConf rpc.DebugOpenOCDServerConfiguration
228+
if err := debugInfo.GetServerConfiguration().UnmarshalTo(&openocdConf); err != nil {
229+
return nil, err
230+
}
231+
232+
serverCmd := fmt.Sprintf(`target extended-remote | "%s"`, debugInfo.GetServerPath())
233+
234+
if cfg := openocdConf.GetScriptsDir(); cfg != "" {
235+
serverCmd += fmt.Sprintf(` -s "%s"`, cfg)
236+
}
237+
238+
for _, script := range openocdConf.GetScripts() {
239+
serverCmd += fmt.Sprintf(` --file "%s"`, script)
240+
}
241+
242+
serverCmd += ` -c "gdb_port pipe"`
243+
serverCmd += ` -c "telnet_port 0"`
244+
245+
add("-ex")
246+
add(serverCmd)
247+
248+
default:
249+
return nil, &cmderrors.FailedDebugError{Message: i18n.Tr("GDB server '%s' is not supported", debugInfo.GetServer())}
250+
}
251+
252+
// Add executable
253+
add(debugInfo.GetExecutable())
254+
255+
// Transform every path to forward slashes (on Windows some tools further
256+
// escapes the command line so the backslash "\" gets in the way).
257+
for i, param := range cmdArgs {
258+
cmdArgs[i] = filepath.ToSlash(param)
259+
}
260+
261+
return cmdArgs, nil
262+
}

‎commands/service_debug_run.go‎

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /