提交 e9e08300 编写于 作者: A aarzilli 提交者: Derek Parker

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.
上级 9348492c
......@@ -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()")
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册