proc,service,terminal: eval expressions in the scope of a deferred call

Add ability to evaluate variables on the scope of a deferred call's
argument frame.
This commit is contained in:
aarzilli
2018-07-10 12:15:11 +02:00
committed by Derek Parker
parent d2904322fa
commit b59032516e
11 changed files with 193 additions and 63 deletions

View File

@ -433,7 +433,7 @@ func Test1ClientServer_infoLocals(t *testing.T) {
if state.Err != nil {
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
}
locals, err := c.ListLocalVariables(api.EvalScope{-1, 0})
locals, err := c.ListLocalVariables(api.EvalScope{-1, 0, 0})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
@ -461,7 +461,7 @@ func Test1ClientServer_infoArgs(t *testing.T) {
if regs == "" {
t.Fatal("Expected string showing registers values, got empty string")
}
locals, err := c.ListFunctionArgs(api.EvalScope{-1, 0})
locals, err := c.ListFunctionArgs(api.EvalScope{-1, 0, 0})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
@ -687,7 +687,7 @@ func Test1ClientServer_EvalVariable(t *testing.T) {
t.Fatalf("Continue(): %v\n", state.Err)
}
var1, err := c.EvalVariable(api.EvalScope{-1, 0}, "a1")
var1, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "a1")
assertNoError(err, t, "EvalVariable")
t.Logf("var1: %s", var1.SinglelineString())
@ -706,9 +706,9 @@ func Test1ClientServer_SetVariable(t *testing.T) {
t.Fatalf("Continue(): %v\n", state.Err)
}
assertNoError(c.SetVariable(api.EvalScope{-1, 0}, "a2", "8"), t, "SetVariable()")
assertNoError(c.SetVariable(api.EvalScope{-1, 0, 0}, "a2", "8"), t, "SetVariable()")
a2, err := c.EvalVariable(api.EvalScope{-1, 0}, "a2")
a2, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "a2")
if err != nil {
t.Fatalf("Could not evaluate variable: %v", err)
}
@ -835,10 +835,10 @@ func Test1Issue355(t *testing.T) {
assertError(err, t, "ListThreads()")
_, err = c.GetThread(tid)
assertError(err, t, "GetThread()")
assertError(c.SetVariable(api.EvalScope{gid, 0}, "a", "10"), t, "SetVariable()")
_, err = c.ListLocalVariables(api.EvalScope{gid, 0})
assertError(c.SetVariable(api.EvalScope{gid, 0, 0}, "a", "10"), t, "SetVariable()")
_, err = c.ListLocalVariables(api.EvalScope{gid, 0, 0})
assertError(err, t, "ListLocalVariables()")
_, err = c.ListFunctionArgs(api.EvalScope{gid, 0})
_, err = c.ListFunctionArgs(api.EvalScope{gid, 0, 0})
assertError(err, t, "ListFunctionArgs()")
_, err = c.ListRegisters()
assertError(err, t, "ListRegisters()")
@ -846,9 +846,9 @@ func Test1Issue355(t *testing.T) {
assertError(err, t, "ListGoroutines()")
_, err = c.Stacktrace(gid, 10, false)
assertError(err, t, "Stacktrace()")
_, err = c.FindLocation(api.EvalScope{gid, 0}, "+1")
_, err = c.FindLocation(api.EvalScope{gid, 0, 0}, "+1")
assertError(err, t, "FindLocation()")
_, err = c.DisassemblePC(api.EvalScope{-1, 0}, 0x40100, api.IntelFlavour)
_, err = c.DisassemblePC(api.EvalScope{-1, 0, 0}, 0x40100, api.IntelFlavour)
assertError(err, t, "DisassemblePC()")
})
}
@ -863,12 +863,12 @@ func Test1Disasm(t *testing.T) {
state := <-ch
assertNoError(state.Err, t, "Continue()")
locs, err := c.FindLocation(api.EvalScope{-1, 0}, "main.main")
locs, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "main.main")
assertNoError(err, t, "FindLocation()")
if len(locs) != 1 {
t.Fatalf("wrong number of locations for main.main: %d", len(locs))
}
d1, err := c.DisassemblePC(api.EvalScope{-1, 0}, locs[0].PC, api.IntelFlavour)
d1, err := c.DisassemblePC(api.EvalScope{-1, 0, 0}, locs[0].PC, api.IntelFlavour)
assertNoError(err, t, "DisassemblePC()")
if len(d1) < 2 {
t.Fatalf("wrong size of disassembly: %d", len(d1))
@ -876,7 +876,7 @@ func Test1Disasm(t *testing.T) {
pcstart := d1[0].Loc.PC
pcend := d1[len(d1)-1].Loc.PC + uint64(len(d1[len(d1)-1].Bytes))
d2, err := c.DisassembleRange(api.EvalScope{-1, 0}, pcstart, pcend, api.IntelFlavour)
d2, err := c.DisassembleRange(api.EvalScope{-1, 0, 0}, pcstart, pcend, api.IntelFlavour)
assertNoError(err, t, "DisassembleRange()")
if len(d1) != len(d2) {
@ -885,7 +885,7 @@ func Test1Disasm(t *testing.T) {
t.Fatal("mismatched length between disassemble pc and disassemble range")
}
d3, err := c.DisassemblePC(api.EvalScope{-1, 0}, state.CurrentThread.PC, api.IntelFlavour)
d3, err := c.DisassemblePC(api.EvalScope{-1, 0, 0}, state.CurrentThread.PC, api.IntelFlavour)
assertNoError(err, t, "DisassemblePC() - second call")
if len(d1) != len(d3) {
@ -929,7 +929,7 @@ func Test1Disasm(t *testing.T) {
state, err := c.StepInstruction()
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
d3, err = c.DisassemblePC(api.EvalScope{-1, 0}, state.CurrentThread.PC, api.IntelFlavour)
d3, err = c.DisassemblePC(api.EvalScope{-1, 0, 0}, state.CurrentThread.PC, api.IntelFlavour)
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
curinstr := getCurinstr(d3)
@ -992,7 +992,7 @@ func Test1ClientServer_CondBreakpoint(t *testing.T) {
state := <-c.Continue()
assertNoError(state.Err, t, "Continue()")
nvar, err := c.EvalVariable(api.EvalScope{-1, 0}, "n")
nvar, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "n")
assertNoError(err, t, "EvalVariable()")
if nvar.SinglelineString() != "7" {
@ -1096,14 +1096,14 @@ func Test1TypesCommand(t *testing.T) {
func Test1Issue406(t *testing.T) {
withTestClient1("issue406", t, func(c *rpc1.RPCClient) {
locs, err := c.FindLocation(api.EvalScope{-1, 0}, "issue406.go:146")
locs, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "issue406.go:146")
assertNoError(err, t, "FindLocation()")
_, err = c.CreateBreakpoint(&api.Breakpoint{Addr: locs[0].PC})
assertNoError(err, t, "CreateBreakpoint()")
ch := c.Continue()
state := <-ch
assertNoError(state.Err, t, "Continue()")
v, err := c.EvalVariable(api.EvalScope{-1, 0}, "cfgtree")
v, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "cfgtree")
assertNoError(err, t, "EvalVariable()")
vs := v.MultilineString("")
t.Logf("cfgtree formats to: %s\n", vs)