diff --git a/service/debugger/debugger.go b/service/debugger/debugger.go index 877217ccb6d5d9663e1281e303ea0a5e16ad9b98..de71ef783d7654b38628ccd6f61746e2eacee88e 100644 --- a/service/debugger/debugger.go +++ b/service/debugger/debugger.go @@ -594,6 +594,12 @@ func (d *Debugger) collectBreakpointInformation(state *api.DebuggerState) error if !found { return fmt.Errorf("could not find thread %d", state.Threads[i].ID) } + + if len(bp.Variables) == 0 && bp.LoadArgs == nil && bp.LoadLocals == nil { + // don't try to create goroutine scope if there is nothing to load + continue + } + s, err := proc.GoroutineScope(thread) if err != nil { return err @@ -605,9 +611,10 @@ func (d *Debugger) collectBreakpointInformation(state *api.DebuggerState) error for i := range bp.Variables { v, err := s.EvalVariable(bp.Variables[i], proc.LoadConfig{true, 1, 64, 64, -1}) if err != nil { - return err + bpi.Variables[i] = api.Variable{Name: bp.Variables[i], Unreadable: fmt.Sprintf("eval error: %v", err)} + } else { + bpi.Variables[i] = *api.ConvertVar(v) } - bpi.Variables[i] = *api.ConvertVar(v) } if bp.LoadArgs != nil { if vars, err := s.FunctionArguments(*api.LoadConfigToProc(bp.LoadArgs)); err == nil { diff --git a/service/test/integration2_test.go b/service/test/integration2_test.go index 1eddd758956064bed09caf80ea1cac6709962123..a691f3d0ba8cd94e27b36f40500eccdde9a07bca 100644 --- a/service/test/integration2_test.go +++ b/service/test/integration2_test.go @@ -1371,3 +1371,16 @@ func TestClientServer_collectBreakpointInfoOnNext(t *testing.T) { } }) } + +func TestClientServer_collectBreakpointInfoError(t *testing.T) { + protest.AllowRecording(t) + withTestClient2("testnextprog", t, func(c service.Client) { + _, err := c.CreateBreakpoint(&api.Breakpoint{ + Addr: findLocationHelper(t, c, "testnextprog.go:23", false, 1, 0)[0], + Variables: []string{"nonexistentvariable", "j"}, + LoadLocals: &normalLoadConfig}) + assertNoError(err, t, "CreateBreakpoint()") + state := <-c.Continue() + assertNoError(state.Err, t, "Continue()") + }) +}