debugger: do not fail continue when breakpoint var can't be evaluated

If one of the expressions that are automatically evaluated when a
breakpoint is hit can't be evaluated breakpoint information collection
should continue and the error should be returned for that specific
expression instead of the whole command.
This commit is contained in:
aarzilli 2017-06-23 14:11:51 +02:00 committed by Derek Parker
parent 9348492c58
commit e9e0830054
2 changed files with 22 additions and 2 deletions

@ -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 {

@ -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()")
})
}