Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc/gdbserial: add environment variables to configure rr invocation #3726

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Documentation/usage/dlv_backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ are:
lldb Uses lldb-server or debugserver.
rr Uses mozilla rr (https://github.com/mozilla/rr).

Some backends can be configured using environment variables:

* DELVE_DEBUGSERVER_PATH specifies the path of the debugserver executable for the lldb backend
* DELVE_RR_RECORD_FLAGS specifies additional flags used when calling 'rr record'
* DELVE_RR_REPLAY_FLAGS specifies additional flags used when calling 'rr replay'


### Options
Expand Down
5 changes: 5 additions & 0 deletions cmd/dlv/cmds/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ are:
lldb Uses lldb-server or debugserver.
rr Uses mozilla rr (https://github.com/mozilla/rr).

Some backends can be configured using environment variables:

* DELVE_DEBUGSERVER_PATH specifies the path of the debugserver executable for the lldb backend
* DELVE_RR_RECORD_FLAGS specifies additional flags used when calling 'rr record'
* DELVE_RR_REPLAY_FLAGS specifies additional flags used when calling 'rr replay'
`})

rootCommand.AddCommand(&cobra.Command{
Expand Down
7 changes: 7 additions & 0 deletions pkg/proc/gdbserial/rr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import (
"github.com/go-delve/delve/pkg/proc"
)

const (
delveRecordFlagsEnvVar = "DELVE_RR_RECORD_FLAGS"
delveReplayFlagsEnvVar = "DELVE_RR_REPLAY_FLAGS"
)

// RecordAsync configures rr to record the execution of the specified
// program. Returns a run function which will actually record the program, a
// stop function which will prematurely terminate the recording of the
Expand All @@ -31,6 +36,7 @@ func RecordAsync(cmd []string, wd string, quiet bool, stdin string, stdout proc.

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

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