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

service/debugger: evaluate breakpoint vars on g-less threads #3759

Merged
merged 1 commit into from
Jul 1, 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
2 changes: 1 addition & 1 deletion cmd/dlv/dlv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ func TestTraceBreakpointExists(t *testing.T) {
// We always set breakpoints on some runtime functions at startup, so this would return with
// a breakpoints exists error.
// TODO: Perhaps we shouldn't be setting these default breakpoints in trace mode, however.
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "issue573.go"), "runtime.*")
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(t.TempDir(), "__debug"), filepath.Join(fixtures, "issue573.go"), "runtime.*panic")
rdr, err := cmd.StderrPipe()
assertNoError(err, t, "stderr pipe")
defer rdr.Close()
Expand Down
8 changes: 7 additions & 1 deletion service/debugger/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,13 @@ func (d *Debugger) collectBreakpointInformation(apiThread *api.Thread, thread pr

s, err := proc.GoroutineScope(tgt, thread)
if err != nil {
return err
var errNoGoroutine proc.ErrNoGoroutine
if errors.As(err, &errNoGoroutine) {
s, err = proc.ThreadScope(tgt, thread)
}
if err != nil {
return err
}
}

if len(bp.Variables) > 0 {
Expand Down
14 changes: 14 additions & 0 deletions service/test/integration2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3153,3 +3153,17 @@ func TestNextInstruction(t *testing.T) {
}
})
}

func TestBreakpointVariablesWithoutG(t *testing.T) {
// Tests that evaluating variables on a breakpoint that is hit on a thread
// without a goroutine does not cause an error.
withTestClient2("math", t, func(c service.Client) {
_, err := c.CreateBreakpoint(&api.Breakpoint{
FunctionName: "runtime.mallocgc",
LoadArgs: &normalLoadConfig,
})
assertNoError(err, t, "CreateBreakpoint")
state := <-c.Continue()
assertNoError(state.Err, t, "Continue()")
})
}