Skip to content

Commit

Permalink
service/debugger: evaluate breakpoint vars on g-less threads
Browse files Browse the repository at this point in the history
Use a thread scope to evaluate breakpoint variables if the current
thread does not have an associated goroutine.

Fixes go-delve#3758
  • Loading branch information
aarzilli committed Jun 26, 2024
1 parent a4196f3 commit 9eecb2e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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()")
})
}

0 comments on commit 9eecb2e

Please sign in to comment.