Skip to content

Commit 40670aa

Browse files
authored
proc/gdbserial: add environment variables to configure rr invocation (go-delve#3726)
Adds two environment variables to configure rr invocations. Fixes go-delve#3670
1 parent 35ebb08 commit 40670aa

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

Documentation/usage/dlv_backend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ are:
1212
lldb Uses lldb-server or debugserver.
1313
rr Uses mozilla rr (https://github.com/mozilla/rr).
1414

15+
Some backends can be configured using environment variables:
16+
17+
* DELVE_DEBUGSERVER_PATH specifies the path of the debugserver executable for the lldb backend
18+
* DELVE_RR_RECORD_FLAGS specifies additional flags used when calling 'rr record'
19+
* DELVE_RR_REPLAY_FLAGS specifies additional flags used when calling 'rr replay'
1520

1621

1722
### Options

cmd/dlv/cmds/commands.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ are:
456456
lldb Uses lldb-server or debugserver.
457457
rr Uses mozilla rr (https://github.com/mozilla/rr).
458458
459+
Some backends can be configured using environment variables:
460+
461+
* DELVE_DEBUGSERVER_PATH specifies the path of the debugserver executable for the lldb backend
462+
* DELVE_RR_RECORD_FLAGS specifies additional flags used when calling 'rr record'
463+
* DELVE_RR_REPLAY_FLAGS specifies additional flags used when calling 'rr replay'
459464
`})
460465

461466
rootCommand.AddCommand(&cobra.Command{

pkg/proc/gdbserial/rr.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import (
1515
"github.com/go-delve/delve/pkg/proc"
1616
)
1717

18+
const (
19+
delveRecordFlagsEnvVar = "DELVE_RR_RECORD_FLAGS"
20+
delveReplayFlagsEnvVar = "DELVE_RR_REPLAY_FLAGS"
21+
)
22+
1823
// RecordAsync configures rr to record the execution of the specified
1924
// program. Returns a run function which will actually record the program, a
2025
// stop function which will prematurely terminate the recording of the
@@ -31,6 +36,7 @@ func RecordAsync(cmd []string, wd string, quiet bool, stdin string, stdout proc.
3136

3237
args := make([]string, 0, len(cmd)+2)
3338
args = append(args, "record", "--print-trace-dir=3")
39+
args = append(args, config.SplitQuotedFields(os.Getenv(delveRecordFlagsEnvVar), '"')...)
3440
args = append(args, cmd...)
3541
rrcmd := exec.Command("rr", args...)
3642
var closefn func()
@@ -141,6 +147,7 @@ func Replay(tracedir string, quiet, deleteOnDetach bool, debugInfoDirs []string,
141147
if rrOnProcessPid != 0 {
142148
args = append(args, fmt.Sprintf("--onprocess=%d", rrOnProcessPid))
143149
}
150+
args = append(args, config.SplitQuotedFields(os.Getenv(delveReplayFlagsEnvVar), '\'')...)
144151
args = append(args, tracedir)
145152

146153
rrcmd := exec.Command("rr", args...)

0 commit comments

Comments
 (0)