From ccd438c65f5054553f49c21f603ee4a677191020 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Tue, 24 Mar 2020 09:16:58 -0700 Subject: [PATCH] pkg/proc: Move proc exec funcs to Target methods --- pkg/proc/fncall.go | 2 +- pkg/proc/gdbserial/rr_test.go | 36 +-- pkg/proc/proc.go | 26 +-- pkg/proc/proc_test.go | 388 ++++++++++++++++----------------- pkg/proc/proc_unix_test.go | 4 +- pkg/proc/scope_test.go | 4 +- pkg/proc/variable_test.go | 4 +- service/debugger/debugger.go | 22 +- service/test/variables_test.go | 46 ++-- 9 files changed, 266 insertions(+), 266 deletions(-) diff --git a/pkg/proc/fncall.go b/pkg/proc/fncall.go index e2005aa3..eac9c2fa 100644 --- a/pkg/proc/fncall.go +++ b/pkg/proc/fncall.go @@ -186,7 +186,7 @@ func EvalExpressionWithCalls(t *Target, g *G, expr string, retLoadCfg LoadConfig contReq, ok := <-continueRequest if contReq.cont { - return Continue(t) + return t.Continue() } return finishEvalExpressionWithCalls(t, g, contReq, ok) diff --git a/pkg/proc/gdbserial/rr_test.go b/pkg/proc/gdbserial/rr_test.go index 7e2be946..e949b67a 100644 --- a/pkg/proc/gdbserial/rr_test.go +++ b/pkg/proc/gdbserial/rr_test.go @@ -71,23 +71,23 @@ func TestRestartAfterExit(t *testing.T) { protest.AllowRecording(t) withTestRecording("testnextprog", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") loc, err := p.CurrentThread().Location() assertNoError(err, t, "CurrentThread().Location()") - err = proc.Continue(p) + err = p.Continue() if _, isexited := err.(proc.ErrProcessExited); err == nil || !isexited { t.Fatalf("program did not exit: %v", err) } assertNoError(p.Restart(""), t, "Restart") - assertNoError(proc.Continue(p), t, "Continue (after restart)") + assertNoError(p.Continue(), t, "Continue (after restart)") loc2, err := p.CurrentThread().Location() assertNoError(err, t, "CurrentThread().Location() (after restart)") if loc2.Line != loc.Line { t.Fatalf("stopped at %d (expected %d)", loc2.Line, loc.Line) } - err = proc.Continue(p) + err = p.Continue() if _, isexited := err.(proc.ErrProcessExited); err == nil || !isexited { t.Fatalf("program did not exit (after exit): %v", err) } @@ -98,19 +98,19 @@ func TestRestartDuringStop(t *testing.T) { protest.AllowRecording(t) withTestRecording("testnextprog", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") loc, err := p.CurrentThread().Location() assertNoError(err, t, "CurrentThread().Location()") assertNoError(p.Restart(""), t, "Restart") - assertNoError(proc.Continue(p), t, "Continue (after restart)") + assertNoError(p.Continue(), t, "Continue (after restart)") loc2, err := p.CurrentThread().Location() assertNoError(err, t, "CurrentThread().Location() (after restart)") if loc2.Line != loc.Line { t.Fatalf("stopped at %d (expected %d)", loc2.Line, loc.Line) } - err = proc.Continue(p) + err = p.Continue() if _, isexited := err.(proc.ErrProcessExited); err == nil || !isexited { t.Fatalf("program did not exit (after exit): %v", err) } @@ -139,7 +139,7 @@ func TestReverseBreakpointCounts(t *testing.T) { protest.AllowRecording(t) withTestRecording("bpcountstest", t, func(p *proc.Target, fixture protest.Fixture) { endbp := setFileBreakpoint(p, t, fixture, 28) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") loc, _ := p.CurrentThread().Location() if loc.PC != endbp.Addr { t.Fatalf("did not reach end of main.main function: %s:%d (%#x)", loc.File, loc.Line, loc.PC) @@ -152,7 +152,7 @@ func TestReverseBreakpointCounts(t *testing.T) { countLoop: for { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") loc, _ := p.CurrentThread().Location() switch loc.PC { case startbp.Addr: @@ -195,7 +195,7 @@ func TestCheckpoints(t *testing.T) { withTestRecording("continuetestprog", t, func(p *proc.Target, fixture protest.Fixture) { // Continues until start of main.main, record output of 'when' bp := setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") when0, loc0 := getPosition(p, t) t.Logf("when0: %q (%#x) %x", when0, loc0.PC, p.CurrentThread().ThreadID()) @@ -212,8 +212,8 @@ func TestCheckpoints(t *testing.T) { } // Move forward with next, check that the output of 'when' changes - assertNoError(proc.Next(p), t, "First Next") - assertNoError(proc.Next(p), t, "Second Next") + assertNoError(p.Next(), t, "First Next") + assertNoError(p.Next(), t, "Second Next") when1, loc1 := getPosition(p, t) t.Logf("when1: %q (%#x) %x", when1, loc1.PC, p.CurrentThread().ThreadID()) if loc0.PC == loc1.PC { @@ -238,8 +238,8 @@ func TestCheckpoints(t *testing.T) { } // Move forward with next again, check that the output of 'when' matches - assertNoError(proc.Next(p), t, "First Next") - assertNoError(proc.Next(p), t, "Second Next") + assertNoError(p.Next(), t, "First Next") + assertNoError(p.Next(), t, "Second Next") when3, loc3 := getPosition(p, t) t.Logf("when3: %q (%#x)", when3, loc3.PC) if loc3.PC != loc1.PC { @@ -256,8 +256,8 @@ func TestCheckpoints(t *testing.T) { p.Restart(fmt.Sprintf("c%d", cpid)) g, _ = proc.FindGoroutine(p, 1) p.SwitchGoroutine(g) - assertNoError(proc.Next(p), t, "First Next") - assertNoError(proc.Next(p), t, "Second Next") + assertNoError(p.Next(), t, "First Next") + assertNoError(p.Next(), t, "Second Next") when4, loc4 := getPosition(p, t) t.Logf("when4: %q (%#x)", when4, loc4.PC) if loc4.PC != loc1.PC { @@ -282,10 +282,10 @@ func TestIssue1376(t *testing.T) { protest.AllowRecording(t) withTestRecording("continuetestprog", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue (forward)") + assertNoError(p.Continue(), t, "Continue (forward)") _, err := p.ClearBreakpoint(bp.Addr) assertNoError(err, t, "ClearBreakpoint") assertNoError(p.ChangeDirection(proc.Backward), t, "Switching to backward direction") - assertNoError(proc.Continue(p), t, "Continue (backward)") + assertNoError(p.Continue(), t, "Continue (backward)") }) } diff --git a/pkg/proc/proc.go b/pkg/proc/proc.go index 5b831c17..e3465479 100644 --- a/pkg/proc/proc.go +++ b/pkg/proc/proc.go @@ -24,7 +24,7 @@ func (err *ErrNoSourceForPC) Error() string { } // Next continues execution until the next source line. -func Next(dbp *Target) (err error) { +func (dbp *Target) Next() (err error) { if _, err := dbp.Valid(); err != nil { return err } @@ -37,13 +37,13 @@ func Next(dbp *Target) (err error) { return } - return Continue(dbp) + return dbp.Continue() } // Continue continues execution of the debugged // process. It will continue until it hits a breakpoint // or is otherwise stopped. -func Continue(dbp *Target) error { +func (dbp *Target) Continue() error { if _, err := dbp.Valid(); err != nil { return err } @@ -151,7 +151,7 @@ func Continue(dbp *Target) error { if err := dbp.ClearInternalBreakpoints(); err != nil { return err } - return StepInstruction(dbp) + return dbp.StepInstruction() } default: curthread.Common().returnValues = curbp.Breakpoint.returnInfo.Collect(curthread) @@ -257,7 +257,7 @@ func stepInstructionOut(dbp *Target, curthread Thread, fnname1, fnname2 string) // Step will continue until another source line is reached. // Will step into functions. -func Step(dbp *Target) (err error) { +func (dbp *Target) Step() (err error) { if _, err := dbp.Valid(); err != nil { return err } @@ -276,10 +276,10 @@ func Step(dbp *Target) (err error) { if bp := dbp.CurrentThread().Breakpoint().Breakpoint; bp != nil && bp.Kind == StepBreakpoint && dbp.GetDirection() == Backward { dbp.ClearInternalBreakpoints() - return StepInstruction(dbp) + return dbp.StepInstruction() } - return Continue(dbp) + return dbp.Continue() } // sameGoroutineCondition returns an expression that evaluates to true when @@ -325,7 +325,7 @@ func andFrameoffCondition(cond ast.Expr, frameoff int64) ast.Expr { // StepOut will continue until the current goroutine exits the // function currently being executed or a deferred function is executed -func StepOut(dbp *Target) error { +func (dbp *Target) StepOut() error { backward := dbp.GetDirection() == Backward if _, err := dbp.Valid(); err != nil { return err @@ -355,7 +355,7 @@ func StepOut(dbp *Target) error { } success = true - return Continue(dbp) + return dbp.Continue() } sameGCond := sameGoroutineCondition(selg) @@ -367,7 +367,7 @@ func StepOut(dbp *Target) error { } success = true - return Continue(dbp) + return dbp.Continue() } var deferpc uint64 @@ -397,14 +397,14 @@ func StepOut(dbp *Target) error { } success = true - return Continue(dbp) + return dbp.Continue() } // StepInstruction will continue the current thread for exactly // one instruction. This method affects only the thread // associated with the selected goroutine. All other // threads will remain stopped. -func StepInstruction(dbp *Target) (err error) { +func (dbp *Target) StepInstruction() (err error) { thread := dbp.CurrentThread() g := dbp.SelectedGoroutine() if g != nil { @@ -414,7 +414,7 @@ func StepInstruction(dbp *Target) (err error) { sameGoroutineCondition(dbp.SelectedGoroutine())); err != nil { return err } - return Continue(dbp) + return dbp.Continue() } thread = g.Thread } diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index 8415e7f0..50febc46 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -139,7 +139,7 @@ func assertLineNumber(p *proc.Target, t *testing.T, lineno int, descr string) (s func TestExit(t *testing.T) { protest.AllowRecording(t) withTestProcess("continuetestprog", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() pe, ok := err.(proc.ErrProcessExited) if !ok { t.Fatalf("Continue() returned unexpected error type %s", err) @@ -157,8 +157,8 @@ func TestExitAfterContinue(t *testing.T) { protest.AllowRecording(t) withTestProcess("continuetestprog", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.sayhi") - assertNoError(proc.Continue(p), t, "First Continue()") - err := proc.Continue(p) + assertNoError(p.Continue(), t, "First Continue()") + err := p.Continue() pe, ok := err.(proc.ErrProcessExited) if !ok { t.Fatalf("Continue() returned unexpected error type %s", pe) @@ -238,7 +238,7 @@ func TestHalt(t *testing.T) { stopChan := make(chan interface{}, 1) withTestProcess("loopprog", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.loop") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") if p, ok := p.Process.(*native.Process); ok { for _, th := range p.ThreadList() { _, err := th.Registers(false) @@ -252,7 +252,7 @@ func TestHalt(t *testing.T) { stopChan <- p.RequestManualStop() }() p.ResumeNotify(resumeChan) - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") retVal := <-stopChan if err, ok := retVal.(error); ok && err != nil { @@ -280,7 +280,7 @@ func TestStep(t *testing.T) { protest.AllowRecording(t) withTestProcess("testprog", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.helloworld") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") regs := getRegisters(p, t) rip := regs.PC() @@ -299,7 +299,7 @@ func TestBreakpoint(t *testing.T) { protest.AllowRecording(t) withTestProcess("testprog", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFunctionBreakpoint(p, t, "main.helloworld") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") regs, err := p.CurrentThread().Registers(false) assertNoError(err, t, "Registers") @@ -321,7 +321,7 @@ func TestBreakpointInSeparateGoRoutine(t *testing.T) { withTestProcess("testthreads", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.anotherthread") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") regs, err := p.CurrentThread().Registers(false) assertNoError(err, t, "Registers") @@ -440,22 +440,22 @@ func testseq2Args(wd string, args []string, buildFlags protest.BuildFlags, t *te if traceTestseq2 { t.Log("next") } - assertNoError(proc.Next(p), t, "Next() returned an error") + assertNoError(p.Next(), t, "Next() returned an error") case contStep: if traceTestseq2 { t.Log("step") } - assertNoError(proc.Step(p), t, "Step() returned an error") + assertNoError(p.Step(), t, "Step() returned an error") case contStepout: if traceTestseq2 { t.Log("stepout") } - assertNoError(proc.StepOut(p), t, "StepOut() returned an error") + assertNoError(p.StepOut(), t, "StepOut() returned an error") case contContinue: if traceTestseq2 { t.Log("continue") } - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") if i == 0 { if traceTestseq2 { t.Log("clearing initial breakpoint") @@ -468,28 +468,28 @@ func testseq2Args(wd string, args []string, buildFlags protest.BuildFlags, t *te t.Log("reverse-next") } assertNoError(p.ChangeDirection(proc.Backward), t, "direction switch") - assertNoError(proc.Next(p), t, "reverse Next() returned an error") + assertNoError(p.Next(), t, "reverse Next() returned an error") assertNoError(p.ChangeDirection(proc.Forward), t, "direction switch") case contReverseStep: if traceTestseq2 { t.Log("reverse-step") } assertNoError(p.ChangeDirection(proc.Backward), t, "direction switch") - assertNoError(proc.Step(p), t, "reverse Step() returned an error") + assertNoError(p.Step(), t, "reverse Step() returned an error") assertNoError(p.ChangeDirection(proc.Forward), t, "direction switch") case contReverseStepout: if traceTestseq2 { t.Log("reverse-stepout") } assertNoError(p.ChangeDirection(proc.Backward), t, "direction switch") - assertNoError(proc.StepOut(p), t, "reverse StepOut() returned an error") + assertNoError(p.StepOut(), t, "reverse StepOut() returned an error") assertNoError(p.ChangeDirection(proc.Forward), t, "direction switch") case contContinueToBreakpoint: bp := setFileBreakpoint(p, t, fixture.Source, tc.pos.(int)) if traceTestseq2 { t.Log("continue") } - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") _, err := p.ClearBreakpoint(bp.Addr) assertNoError(err, t, "ClearBreakpoint() returned an error") } @@ -581,7 +581,7 @@ func TestNextConcurrent(t *testing.T) { protest.AllowRecording(t) withTestProcess("parallel_next", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFunctionBreakpoint(p, t, "main.sayhi") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") f, ln := currentLineNumber(p, t) initV := evalVariable(p, t, "n") initVval, _ := constant.Int64Val(initV.Value) @@ -596,7 +596,7 @@ func TestNextConcurrent(t *testing.T) { if ln != tc.begin { t.Fatalf("Program not stopped at correct spot expected %d was %s:%d", tc.begin, filepath.Base(f), ln) } - assertNoError(proc.Next(p), t, "Next() returned an error") + assertNoError(p.Next(), t, "Next() returned an error") f, ln = assertLineNumber(p, t, tc.end, "Program did not continue to the expected location") v := evalVariable(p, t, "n") vval, _ := constant.Int64Val(v.Value) @@ -620,7 +620,7 @@ func TestNextConcurrentVariant2(t *testing.T) { protest.AllowRecording(t) withTestProcess("parallel_next", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.sayhi") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") f, ln := currentLineNumber(p, t) initV := evalVariable(p, t, "n") initVval, _ := constant.Int64Val(initV.Value) @@ -634,7 +634,7 @@ func TestNextConcurrentVariant2(t *testing.T) { if ln != tc.begin { t.Fatalf("Program not stopped at correct spot expected %d was %s:%d", tc.begin, filepath.Base(f), ln) } - assertNoError(proc.Next(p), t, "Next() returned an error") + assertNoError(p.Next(), t, "Next() returned an error") var vval int64 for { v := evalVariable(p, t, "n") @@ -651,7 +651,7 @@ func TestNextConcurrentVariant2(t *testing.T) { if vval == initVval { t.Fatal("Initial breakpoint triggered twice for the same goroutine") } - assertNoError(proc.Continue(p), t, "Continue 2") + assertNoError(p.Continue(), t, "Continue 2") } } f, ln = assertLineNumber(p, t, tc.end, "Program did not continue to the expected location") @@ -709,7 +709,7 @@ func TestNextNetHTTP(t *testing.T) { } http.Get("http://127.0.0.1:9191") }() - if err := proc.Continue(p); err != nil { + if err := p.Continue(); err != nil { t.Fatal(err) } f, ln := currentLineNumber(p, t) @@ -718,7 +718,7 @@ func TestNextNetHTTP(t *testing.T) { t.Fatalf("Program not stopped at correct spot expected %d was %s:%d", tc.begin, filepath.Base(f), ln) } - assertNoError(proc.Next(p), t, "Next() returned an error") + assertNoError(p.Next(), t, "Next() returned an error") f, ln = assertLineNumber(p, t, tc.end, "Program did not continue to correct next location") } @@ -727,7 +727,7 @@ func TestNextNetHTTP(t *testing.T) { func TestRuntimeBreakpoint(t *testing.T) { withTestProcess("testruntimebreakpoint", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() if err != nil { t.Fatal(err) } @@ -756,7 +756,7 @@ func TestFindReturnAddress(t *testing.T) { protest.AllowRecording(t) withTestProcess("testnextprog", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 24) - err := proc.Continue(p) + err := p.Continue() if err != nil { t.Fatal(err) } @@ -776,7 +776,7 @@ func TestFindReturnAddressTopOfStackFn(t *testing.T) { withTestProcess("testreturnaddress", t, func(p *proc.Target, fixture protest.Fixture) { fnName := "runtime.rt0_go" setFunctionBreakpoint(p, t, fnName) - if err := proc.Continue(p); err != nil { + if err := p.Continue(); err != nil { t.Fatal(err) } if _, err := returnAddress(p.CurrentThread()); err == nil { @@ -794,7 +794,7 @@ func TestSwitchThread(t *testing.T) { t.Fatal("Expected error for invalid thread id") } setFunctionBreakpoint(p, t, "main.main") - err = proc.Continue(p) + err = p.Continue() if err != nil { t.Fatal(err) } @@ -833,8 +833,8 @@ func TestCGONext(t *testing.T) { protest.AllowRecording(t) withTestProcess("cgotest", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue()") - assertNoError(proc.Next(p), t, "Next()") + assertNoError(p.Continue(), t, "Continue()") + assertNoError(p.Next(), t, "Next()") }) } @@ -862,7 +862,7 @@ func TestStacktrace(t *testing.T) { bp := setFunctionBreakpoint(p, t, "main.stacktraceme") for i := range stacks { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") locations, err := proc.ThreadStacktrace(p.CurrentThread(), 40) assertNoError(err, t, "Stacktrace()") @@ -883,13 +883,13 @@ func TestStacktrace(t *testing.T) { } p.ClearBreakpoint(bp.Addr) - proc.Continue(p) + p.Continue() }) } func TestStacktrace2(t *testing.T) { withTestProcess("retstack", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") locations, err := proc.ThreadStacktrace(p.CurrentThread(), 40) assertNoError(err, t, "Stacktrace()") @@ -900,7 +900,7 @@ func TestStacktrace2(t *testing.T) { t.Fatalf("Stack error at main.f()\n%v\n", locations) } - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") locations, err = proc.ThreadStacktrace(p.CurrentThread(), 40) assertNoError(err, t, "Stacktrace()") if !stackMatch([]loc{{-1, "main.g"}, {17, "main.main"}}, locations, false) { @@ -950,7 +950,7 @@ func TestStacktraceGoroutine(t *testing.T) { withTestProcess("goroutinestackprog", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFunctionBreakpoint(p, t, "main.stacktraceme") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") gs, _, err := proc.GoroutinesInfo(p, 0, 0) assertNoError(err, t, "GoroutinesInfo") @@ -1000,7 +1000,7 @@ func TestStacktraceGoroutine(t *testing.T) { } p.ClearBreakpoint(bp.Addr) - proc.Continue(p) + p.Continue() }) } @@ -1032,7 +1032,7 @@ func TestKill(t *testing.T) { func testGSupportFunc(name string, t *testing.T, p *proc.Target, fixture protest.Fixture) { bp := setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, name+": Continue()") + assertNoError(p.Continue(), t, name+": Continue()") g, err := proc.GetG(p.CurrentThread()) assertNoError(err, t, name+": GetG()") @@ -1074,7 +1074,7 @@ func TestContinueMulti(t *testing.T) { mainCount := 0 sayhiCount := 0 for { - err := proc.Continue(p) + err := p.Continue() if valid, _ := p.Valid(); !valid { break } @@ -1106,7 +1106,7 @@ func TestBreakpointOnFunctionEntry(t *testing.T) { func TestProcessReceivesSIGCHLD(t *testing.T) { protest.AllowRecording(t) withTestProcess("sigchldprog", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() _, ok := err.(proc.ErrProcessExited) if !ok { t.Fatalf("Continue() returned unexpected error type %v", err) @@ -1117,7 +1117,7 @@ func TestProcessReceivesSIGCHLD(t *testing.T) { func TestIssue239(t *testing.T) { withTestProcess("is sue239", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 17) - assertNoError(proc.Continue(p), t, fmt.Sprintf("Continue()")) + assertNoError(p.Continue(), t, fmt.Sprintf("Continue()")) }) } @@ -1211,7 +1211,7 @@ func TestVariableEvaluation(t *testing.T) { } withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") for _, tc := range testcases { v := evalVariable(p, t, tc.name) @@ -1262,7 +1262,7 @@ func TestFrameEvaluation(t *testing.T) { protest.AllowRecording(t) withTestProcess("goroutinestackprog", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.stacktraceme") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") t.Logf("stopped on thread %d, goroutine: %#v", p.CurrentThread().ThreadID(), p.SelectedGoroutine()) @@ -1311,7 +1311,7 @@ func TestFrameEvaluation(t *testing.T) { } // Testing evaluation on frames - assertNoError(proc.Continue(p), t, "Continue() 2") + assertNoError(p.Continue(), t, "Continue() 2") g, err := proc.GetG(p.CurrentThread()) assertNoError(err, t, "GetG()") @@ -1331,7 +1331,7 @@ func TestFrameEvaluation(t *testing.T) { func TestPointerSetting(t *testing.T) { withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") pval := func(n int64) { variable := evalVariable(p, t, "p1") @@ -1359,14 +1359,14 @@ func TestPointerSetting(t *testing.T) { func TestVariableFunctionScoping(t *testing.T) { withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() assertNoError(err, t, "Continue() returned an error") evalVariable(p, t, "a1") evalVariable(p, t, "a2") // Move scopes, a1 exists here by a2 does not - err = proc.Continue(p) + err = p.Continue() assertNoError(err, t, "Continue() returned an error") evalVariable(p, t, "a1") @@ -1381,7 +1381,7 @@ func TestVariableFunctionScoping(t *testing.T) { func TestRecursiveStructure(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") v := evalVariable(p, t, "aas") t.Logf("v: %v\n", v) }) @@ -1391,7 +1391,7 @@ func TestIssue316(t *testing.T) { // A pointer loop that includes one interface should not send dlv into an infinite loop protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") evalVariable(p, t, "iface5") }) } @@ -1400,7 +1400,7 @@ func TestIssue325(t *testing.T) { // nil pointer dereference when evaluating interfaces to function pointers protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") iface2fn1v := evalVariable(p, t, "iface2fn1") t.Logf("iface2fn1: %v\n", iface2fn1v) @@ -1418,7 +1418,7 @@ func TestBreakpointCounts(t *testing.T) { bp := setFileBreakpoint(p, t, fixture.Source, 12) for { - if err := proc.Continue(p); err != nil { + if err := p.Continue(); err != nil { if _, exited := err.(proc.ErrProcessExited); exited { break } @@ -1447,7 +1447,7 @@ func BenchmarkArray(b *testing.B) { // each bencharr struct is 128 bytes, bencharr is 64 elements long b.SetBytes(int64(64 * 128)) withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), b, "Continue()") + assertNoError(p.Continue(), b, "Continue()") b.ResetTimer() for i := 0; i < b.N; i++ { evalVariable(p, b, "bencharr") @@ -1467,7 +1467,7 @@ func TestBreakpointCountsWithDetection(t *testing.T) { bp := setFileBreakpoint(p, t, fixture.Source, 12) for { - if err := proc.Continue(p); err != nil { + if err := p.Continue(); err != nil { if _, exited := err.(proc.ErrProcessExited); exited { break } @@ -1520,7 +1520,7 @@ func BenchmarkArrayPointer(b *testing.B) { // each read will read 64 bencharr structs plus the 64 pointers of benchparr b.SetBytes(int64(64*128 + 64*8)) withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), b, "Continue()") + assertNoError(p.Continue(), b, "Continue()") b.ResetTimer() for i := 0; i < b.N; i++ { evalVariable(p, b, "bencharr") @@ -1534,7 +1534,7 @@ func BenchmarkMap(b *testing.B) { // reading strings and the map structure imposes a overhead that we ignore here b.SetBytes(int64(41 * (2*8 + 9))) withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), b, "Continue()") + assertNoError(p.Continue(), b, "Continue()") b.ResetTimer() for i := 0; i < b.N; i++ { evalVariable(p, b, "m1") @@ -1544,7 +1544,7 @@ func BenchmarkMap(b *testing.B) { func BenchmarkGoroutinesInfo(b *testing.B) { withTestProcess("testvariables2", b, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), b, "Continue()") + assertNoError(p.Continue(), b, "Continue()") b.ResetTimer() for i := 0; i < b.N; i++ { p.ClearAllGCache() @@ -1560,8 +1560,8 @@ func TestIssue262(t *testing.T) { withTestProcess("issue262", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 11) - assertNoError(proc.Continue(p), t, "Continue()") - err := proc.Continue(p) + assertNoError(p.Continue(), t, "Continue()") + err := p.Continue() if err == nil { t.Fatalf("No error on second continue") } @@ -1580,13 +1580,13 @@ func TestIssue305(t *testing.T) { withTestProcess("issue305", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 5) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") - assertNoError(proc.Next(p), t, "Next() 1") - assertNoError(proc.Next(p), t, "Next() 2") - assertNoError(proc.Next(p), t, "Next() 3") - assertNoError(proc.Next(p), t, "Next() 4") - assertNoError(proc.Next(p), t, "Next() 5") + assertNoError(p.Next(), t, "Next() 1") + assertNoError(p.Next(), t, "Next() 2") + assertNoError(p.Next(), t, "Next() 3") + assertNoError(p.Next(), t, "Next() 4") + assertNoError(p.Next(), t, "Next() 5") }) } @@ -1595,7 +1595,7 @@ func TestPointerLoops(t *testing.T) { // Regression test for issue #341 protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") for _, expr := range []string{"mapinf", "ptrinf", "sliceinf"} { t.Logf("requesting %s", expr) v := evalVariable(p, t, expr) @@ -1606,7 +1606,7 @@ func TestPointerLoops(t *testing.T) { func BenchmarkLocalVariables(b *testing.B) { withTestProcess("testvariables", b, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), b, "Continue() returned an error") + assertNoError(p.Continue(), b, "Continue() returned an error") scope, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, b, "Scope()") b.ResetTimer() @@ -1630,7 +1630,7 @@ func TestCondBreakpoint(t *testing.T) { Y: &ast.BasicLit{Kind: token.INT, Value: "7"}, } - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") nvar := evalVariable(p, t, "n") @@ -1654,7 +1654,7 @@ func TestCondBreakpointError(t *testing.T) { Y: &ast.BasicLit{Kind: token.INT, Value: "7"}, } - err := proc.Continue(p) + err := p.Continue() if err == nil { t.Fatalf("No error on first Continue()") } @@ -1669,7 +1669,7 @@ func TestCondBreakpointError(t *testing.T) { Y: &ast.BasicLit{Kind: token.INT, Value: "7"}, } - err = proc.Continue(p) + err = p.Continue() if err != nil { if _, exited := err.(proc.ErrProcessExited); !exited { t.Fatalf("Unexpected error on second Continue(): %v", err) @@ -1689,7 +1689,7 @@ func TestIssue356(t *testing.T) { // slice with a typedef does not get printed correctly protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") mmvar := evalVariable(p, t, "mainMenu") if mmvar.Kind != reflect.Slice { t.Fatalf("Wrong kind for mainMenu: %v\n", mmvar.Kind) @@ -1700,9 +1700,9 @@ func TestIssue356(t *testing.T) { func TestStepIntoFunction(t *testing.T) { withTestProcess("teststep", t, func(p *proc.Target, fixture protest.Fixture) { // Continue until breakpoint - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") // Step into function - assertNoError(proc.Step(p), t, "Step() returned an error") + assertNoError(p.Step(), t, "Step() returned an error") // We should now be inside the function. loc, err := p.CurrentThread().Location() if err != nil { @@ -1733,7 +1733,7 @@ func TestIssue384(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue384", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 13) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") evalVariable(p, t, "st") }) } @@ -1743,8 +1743,8 @@ func TestIssue332_Part1(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue332", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 8) - assertNoError(proc.Continue(p), t, "Continue()") - assertNoError(proc.Next(p), t, "first Next()") + assertNoError(p.Continue(), t, "Continue()") + assertNoError(p.Next(), t, "first Next()") locations, err := proc.ThreadStacktrace(p.CurrentThread(), 2) assertNoError(err, t, "Stacktrace()") if locations[0].Call.Fn == nil { @@ -1767,11 +1767,11 @@ func TestIssue332_Part2(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue332", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 8) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") // step until we enter changeMe for { - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Step(), t, "Step()") locations, err := proc.ThreadStacktrace(p.CurrentThread(), 2) assertNoError(err, t, "Stacktrace()") if locations[0].Call.Fn == nil { @@ -1793,10 +1793,10 @@ func TestIssue332_Part2(t *testing.T) { t.Fatalf("Step did not skip the prologue: current pc: %x, first instruction after prologue: %x", pc, pcAfterPrologue) } - assertNoError(proc.Next(p), t, "first Next()") - assertNoError(proc.Next(p), t, "second Next()") - assertNoError(proc.Next(p), t, "third Next()") - err = proc.Continue(p) + assertNoError(p.Next(), t, "first Next()") + assertNoError(p.Next(), t, "second Next()") + assertNoError(p.Next(), t, "third Next()") + err = p.Continue() if _, exited := err.(proc.ErrProcessExited); !exited { assertNoError(err, t, "final Continue()") } @@ -1819,9 +1819,9 @@ func TestIssue414(t *testing.T) { protest.AllowRecording(t) withTestProcess("math", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 9) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") for { - err := proc.Step(p) + err := p.Step() if err != nil { if _, exited := err.(proc.ErrProcessExited); exited { break @@ -1835,7 +1835,7 @@ func TestIssue414(t *testing.T) { func TestPackageVariables(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() assertNoError(err, t, "Continue()") scope, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, t, "Scope()") @@ -1868,7 +1868,7 @@ func TestIssue149(t *testing.T) { func TestPanicBreakpoint(t *testing.T) { protest.AllowRecording(t) withTestProcess("panic", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") bp := p.CurrentThread().Breakpoint() if bp.Breakpoint == nil || bp.Name != proc.UnrecoveredPanic { t.Fatalf("not on unrecovered-panic breakpoint: %v", bp) @@ -1878,7 +1878,7 @@ func TestPanicBreakpoint(t *testing.T) { func TestCmdLineArgs(t *testing.T) { expectSuccess := func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() bp := p.CurrentThread().Breakpoint() if bp.Breakpoint != nil && bp.Name == proc.UnrecoveredPanic { t.Fatalf("testing args failed on unrecovered-panic breakpoint: %v", bp) @@ -1894,7 +1894,7 @@ func TestCmdLineArgs(t *testing.T) { } expectPanic := func(p *proc.Target, fixture protest.Fixture) { - proc.Continue(p) + p.Continue() bp := p.CurrentThread().Breakpoint() if bp.Breakpoint == nil || bp.Name != proc.UnrecoveredPanic { t.Fatalf("not on unrecovered-panic breakpoint: %v", bp) @@ -1936,7 +1936,7 @@ func TestIssue462(t *testing.T) { p.RequestManualStop() }() - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") _, err := proc.ThreadStacktrace(p.CurrentThread(), 40) assertNoError(err, t, "Stacktrace()") }) @@ -1953,7 +1953,7 @@ func TestNextParked(t *testing.T) { // continue until a parked goroutine exists var parkedg *proc.G for parkedg == nil { - err := proc.Continue(p) + err := p.Continue() if _, exited := err.(proc.ErrProcessExited); exited { t.Log("could not find parked goroutine") return @@ -1987,7 +1987,7 @@ func TestNextParked(t *testing.T) { assertNoError(p.SwitchGoroutine(parkedg), t, "SwitchGoroutine()") p.ClearBreakpoint(bp.Addr) - assertNoError(proc.Next(p), t, "Next()") + assertNoError(p.Next(), t, "Next()") if p.SelectedGoroutine().ID != parkedg.ID { t.Fatalf("Next did not continue on the selected goroutine, expected %d got %d", parkedg.ID, p.SelectedGoroutine().ID) @@ -2007,7 +2007,7 @@ func TestStepParked(t *testing.T) { var parkedg *proc.G LookForParkedG: for { - err := proc.Continue(p) + err := p.Continue() if _, exited := err.(proc.ErrProcessExited); exited { t.Log("could not find parked goroutine") return @@ -2037,7 +2037,7 @@ func TestStepParked(t *testing.T) { assertNoError(p.SwitchGoroutine(parkedg), t, "SwitchGoroutine()") p.ClearBreakpoint(bp.Addr) - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Step(), t, "Step()") if p.SelectedGoroutine().ID != parkedg.ID { t.Fatalf("Step did not continue on the selected goroutine, expected %d got %d", parkedg.ID, p.SelectedGoroutine().ID) @@ -2125,10 +2125,10 @@ func TestIssue573(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue573", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.foo") - assertNoError(proc.Continue(p), t, "Continue()") - assertNoError(proc.Step(p), t, "Step() #1") - assertNoError(proc.Step(p), t, "Step() #2") // Bug exits here. - assertNoError(proc.Step(p), t, "Step() #3") // Third step ought to be possible; program ought not have exited. + assertNoError(p.Continue(), t, "Continue()") + assertNoError(p.Step(), t, "Step() #1") + assertNoError(p.Step(), t, "Step() #2") // Bug exits here. + assertNoError(p.Step(), t, "Step() #3") // Third step ought to be possible; program ought not have exited. }) } @@ -2307,22 +2307,22 @@ func TestIssue561(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue561", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 10) - assertNoError(proc.Continue(p), t, "Continue()") - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Continue(), t, "Continue()") + assertNoError(p.Step(), t, "Step()") assertLineNumber(p, t, 5, "wrong line number after Step,") }) } func TestGoroutineLables(t *testing.T) { withTestProcess("goroutineLabels", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") g, err := proc.GetG(p.CurrentThread()) assertNoError(err, t, "GetG()") if len(g.Labels()) != 0 { t.Fatalf("No labels expected") } - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") g, err = proc.GetG(p.CurrentThread()) assertNoError(err, t, "GetG()") labels := g.Labels() @@ -2347,7 +2347,7 @@ func TestStepConcurrentDirect(t *testing.T) { withTestProcess("teststepconcurrent", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFileBreakpoint(p, t, fixture.Source, 37) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") _, err := p.ClearBreakpoint(bp.Addr) assertNoError(err, t, "ClearBreakpoint()") @@ -2396,7 +2396,7 @@ func TestStepConcurrentDirect(t *testing.T) { if i == 0 { count++ } - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Step(), t, "Step()") } if count != 100 { @@ -2424,7 +2424,7 @@ func TestStepConcurrentPtr(t *testing.T) { kvals := map[int]int64{} count := 0 for { - err := proc.Continue(p) + err := p.Continue() _, exited := err.(proc.ErrProcessExited) if exited { break @@ -2452,12 +2452,12 @@ func TestStepConcurrentPtr(t *testing.T) { } kvals[gid] = k - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Step(), t, "Step()") for p.Breakpoints().HasInternalBreakpoints() { if p.SelectedGoroutine().ID == gid { t.Fatalf("step did not step into function call (but internal breakpoints still active?) (%d %d)", gid, p.SelectedGoroutine().ID) } - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") } if p.SelectedGoroutine().ID != gid { @@ -2484,12 +2484,12 @@ func TestStepOutDefer(t *testing.T) { protest.AllowRecording(t) withTestProcess("testnextdefer", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFileBreakpoint(p, t, fixture.Source, 9) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") p.ClearBreakpoint(bp.Addr) assertLineNumber(p, t, 9, "wrong line number") - assertNoError(proc.StepOut(p), t, "StepOut()") + assertNoError(p.StepOut(), t, "StepOut()") f, l, _ := p.BinInfo().PCToLine(currentPC(p, t)) if f == fixture.Source || l == 6 { @@ -2514,7 +2514,7 @@ func TestStepOnCallPtrInstr(t *testing.T) { withTestProcess("teststepprog", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 10) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") found := false @@ -2532,14 +2532,14 @@ func TestStepOnCallPtrInstr(t *testing.T) { found = true break } - assertNoError(proc.StepInstruction(p), t, "StepInstruction()") + assertNoError(p.StepInstruction(), t, "StepInstruction()") } if !found { t.Fatal("Could not find CALL instruction") } - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Step(), t, "Step()") if goversion.VersionAfterOrEqual(runtime.Version(), 1, 11) { assertLineNumber(p, t, 6, "Step continued to wrong line,") @@ -2564,7 +2564,7 @@ func TestIssue594(t *testing.T) { // dereference panic and recover from it. protest.AllowRecording(t) withTestProcess("issue594", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") var f string var ln int if testBackend == "rr" { @@ -2604,7 +2604,7 @@ func TestWorkDir(t *testing.T) { protest.AllowRecording(t) withTestProcessArgs("workdir", t, wd, []string{}, 0, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 14) - proc.Continue(p) + p.Continue() v := evalVariable(p, t, "pwd") str := constant.StringVal(v.Value) if wd != str { @@ -2625,7 +2625,7 @@ func TestNegativeIntEvaluation(t *testing.T) { } protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") for _, tc := range testcases { v := evalVariable(p, t, tc.name) if typ := v.RealType.String(); typ != tc.typ { @@ -2643,11 +2643,11 @@ func TestIssue683(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue683", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "First Continue()") + assertNoError(p.Continue(), t, "First Continue()") for i := 0; i < 20; i++ { // eventually an error about the source file not being found will be // returned, the important thing is that we shouldn't panic - err := proc.Step(p) + err := p.Step() if err != nil { break } @@ -2659,8 +2659,8 @@ func TestIssue664(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue664", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 4) - assertNoError(proc.Continue(p), t, "Continue()") - assertNoError(proc.Next(p), t, "Next()") + assertNoError(p.Continue(), t, "Continue()") + assertNoError(p.Next(), t, "Next()") assertLineNumber(p, t, 5, "Did not continue to correct location,") }) } @@ -2671,7 +2671,7 @@ func BenchmarkTrace(b *testing.B) { setFunctionBreakpoint(p, b, "main.PerfCheck") b.ResetTimer() for i := 0; i < b.N; i++ { - assertNoError(proc.Continue(p), b, "Continue()") + assertNoError(p.Continue(), b, "Continue()") s, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, b, "Scope()") _, err = s.FunctionArguments(proc.LoadConfig{false, 0, 64, 0, 3, 0}) @@ -2689,7 +2689,7 @@ func TestNextInDeferReturn(t *testing.T) { protest.AllowRecording(t) withTestProcess("defercall", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "runtime.deferreturn") - assertNoError(proc.Continue(p), t, "First Continue()") + assertNoError(p.Continue(), t, "First Continue()") // Set a breakpoint on the deferred function so that the following loop // can not step out of the runtime.deferreturn and all the way to the @@ -2702,7 +2702,7 @@ func TestNextInDeferReturn(t *testing.T) { if loc.Fn != nil && loc.Fn.Name == "main.sampleFunction" { break } - assertNoError(proc.Next(p), t, fmt.Sprintf("Next() %d", i)) + assertNoError(p.Next(), t, fmt.Sprintf("Next() %d", i)) } }) } @@ -2738,7 +2738,7 @@ func TestStacktraceWithBarriers(t *testing.T) { setFunctionBreakpoint(p, t, "runtime.gcInstallStackBarrier") stackBarrierGoids := []int{} for len(stackBarrierGoids) == 0 { - err := proc.Continue(p) + err := p.Continue() if _, exited := err.(proc.ErrProcessExited); exited { t.Logf("Could not run test") return @@ -2773,7 +2773,7 @@ func TestStacktraceWithBarriers(t *testing.T) { t.Logf("stack barrier goids: %v\n", stackBarrierGoids) - assertNoError(proc.StepOut(p), t, "StepOut()") + assertNoError(p.StepOut(), t, "StepOut()") gs, _, err := proc.GoroutinesInfo(p, 0, 0) assertNoError(err, t, "GoroutinesInfo()") @@ -2871,7 +2871,7 @@ func TestAttachDetach(t *testing.T) { http.Get("http://127.0.0.1:9191") }() - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") assertLineNumber(p, t, 11, "Did not continue to correct location,") assertNoError(p.Detach(false), t, "Detach") @@ -2890,7 +2890,7 @@ func TestAttachDetach(t *testing.T) { func TestVarSum(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") sumvar := evalVariable(p, t, "s1[0] + s1[1]") sumvarstr := constant.StringVal(sumvar.Value) if sumvarstr != "onetwo" { @@ -2905,7 +2905,7 @@ func TestVarSum(t *testing.T) { func TestPackageWithPathVar(t *testing.T) { protest.AllowRecording(t) withTestProcess("pkgrenames", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") evalVariable(p, t, "pkg.SomeVar") evalVariable(p, t, "pkg.SomeVar.X") }) @@ -2915,7 +2915,7 @@ func TestEnvironment(t *testing.T) { protest.AllowRecording(t) os.Setenv("SOMEVAR", "bah") withTestProcess("testenv", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") v := evalVariable(p, t, "x") vv := constant.StringVal(v.Value) t.Logf("v = %q", vv) @@ -2943,22 +2943,22 @@ func TestRecursiveNext(t *testing.T) { withTestProcess("increment", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFunctionBreakpoint(p, t, "main.Increment") - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") _, err := p.ClearBreakpoint(bp.Addr) assertNoError(err, t, "ClearBreakpoint") - assertNoError(proc.Next(p), t, "Next 1") - assertNoError(proc.Next(p), t, "Next 2") - assertNoError(proc.Next(p), t, "Next 3") + assertNoError(p.Next(), t, "Next 1") + assertNoError(p.Next(), t, "Next 2") + assertNoError(p.Next(), t, "Next 3") frameoff0 := getFrameOff(p, t) - assertNoError(proc.Step(p), t, "Step") + assertNoError(p.Step(), t, "Step") frameoff1 := getFrameOff(p, t) if frameoff0 == frameoff1 { t.Fatalf("did not step into function?") } assertLineNumber(p, t, 6, "program did not continue to expected location,") - assertNoError(proc.Next(p), t, "Next 4") + assertNoError(p.Next(), t, "Next 4") assertLineNumber(p, t, 7, "program did not continue to expected location,") - assertNoError(proc.StepOut(p), t, "StepOut") + assertNoError(p.StepOut(), t, "StepOut") assertLineNumber(p, t, 11, "program did not continue to expected location,") frameoff2 := getFrameOff(p, t) if frameoff0 != frameoff2 { @@ -2981,7 +2981,7 @@ func TestIssue877(t *testing.T) { const envval = "/usr/local/lib" os.Setenv("DYLD_LIBRARY_PATH", envval) withTestProcess("issue877", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") v := evalVariable(p, t, "dyldenv") vv := constant.StringVal(v.Value) t.Logf("v = %q", vv) @@ -2997,7 +2997,7 @@ func TestIssue893(t *testing.T) { // error, (c) program runs to completion protest.AllowRecording(t) withTestProcess("increment", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Next(p) + err := p.Next() if err == nil { return } @@ -3022,14 +3022,14 @@ func TestStepInstructionNoGoroutine(t *testing.T) { withTestProcess("increment", t, func(p *proc.Target, fixture protest.Fixture) { // Call StepInstruction immediately after launching the program, it should // work even though no goroutine is selected. - assertNoError(proc.StepInstruction(p), t, "StepInstruction") + assertNoError(p.StepInstruction(), t, "StepInstruction") }) } func TestIssue871(t *testing.T) { protest.AllowRecording(t) withTestProcess("issue871", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") var scope *proc.EvalScope var err error @@ -3077,7 +3077,7 @@ func TestShadowedFlag(t *testing.T) { return } withTestProcess("testshadow", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") scope, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, t, "GoroutineScope") locals, err := scope.LocalVariables(normalLoadConfig) @@ -3188,8 +3188,8 @@ func TestIssue844(t *testing.T) { X: &ast.Ident{Name: "n"}, Y: &ast.BasicLit{Kind: token.INT, Value: "11"}, } - assertNoError(proc.Continue(p), t, "Continue") - assertNoError(proc.Next(p), t, "Next") + assertNoError(p.Continue(), t, "Continue") + assertNoError(p.Next(), t, "Next") assertLineNumber(p, t, 10, "continued to wrong location,") }) } @@ -3323,7 +3323,7 @@ func TestCgoStacktrace(t *testing.T) { withTestProcess("cgostacktest/", t, func(p *proc.Target, fixture protest.Fixture) { for itidx, tc := range testCases { - assertNoError(proc.Continue(p), t, fmt.Sprintf("Continue at iteration step %d", itidx)) + assertNoError(p.Continue(), t, fmt.Sprintf("Continue at iteration step %d", itidx)) g, err := proc.GetG(p.CurrentThread()) assertNoError(err, t, fmt.Sprintf("GetG at iteration step %d", itidx)) @@ -3423,8 +3423,8 @@ func TestSystemstackStacktrace(t *testing.T) { // check that we can follow a stack switch initiated by runtime.systemstack() withTestProcess("panic", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "runtime.startpanic_m") - assertNoError(proc.Continue(p), t, "first continue") - assertNoError(proc.Continue(p), t, "second continue") + assertNoError(p.Continue(), t, "first continue") + assertNoError(p.Continue(), t, "second continue") g, err := proc.GetG(p.CurrentThread()) assertNoError(err, t, "GetG") frames, err := g.Stacktrace(100, 0) @@ -3445,7 +3445,7 @@ func TestSystemstackOnRuntimeNewstack(t *testing.T) { // command won't work for it. withTestProcess("binarytrees", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "first continue") + assertNoError(p.Continue(), t, "first continue") g, err := proc.GetG(p.CurrentThread()) assertNoError(err, t, "GetG") @@ -3453,7 +3453,7 @@ func TestSystemstackOnRuntimeNewstack(t *testing.T) { setFunctionBreakpoint(p, t, "runtime.newstack") for { - assertNoError(proc.Continue(p), t, "second continue") + assertNoError(p.Continue(), t, "second continue") g, err = proc.GetG(p.CurrentThread()) assertNoError(err, t, "GetG") if g.ID == mainGoroutineID { @@ -3479,7 +3479,7 @@ func TestIssue1034(t *testing.T) { // without the "has children" flag, we should support this. withTestProcess("cgostacktest/", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") frames, err := p.SelectedGoroutine().Stacktrace(10, 0) assertNoError(err, t, "Stacktrace") scope := proc.FrameToScope(p.BinInfo(), p.CurrentThread(), nil, frames[2:]...) @@ -3500,7 +3500,7 @@ func TestIssue1008(t *testing.T) { // in debug_line. which we should support correctly. withTestProcess("cgostacktest/", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") loc, err := p.CurrentThread().Location() assertNoError(err, t, "CurrentThread().Location()") t.Logf("location %v\n", loc) @@ -3520,7 +3520,7 @@ func TestDeclLine(t *testing.T) { } withTestProcess("decllinetest", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") scope, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, t, "GoroutineScope (1)") vars, err := scope.LocalVariables(normalLoadConfig) @@ -3529,7 +3529,7 @@ func TestDeclLine(t *testing.T) { t.Fatalf("wrong number of variables %d", len(vars)) } - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") scope, err = proc.GoroutineScope(p.CurrentThread()) assertNoError(err, t, "GoroutineScope (2)") scope.LocalVariables(normalLoadConfig) @@ -3543,7 +3543,7 @@ func TestDeclLine(t *testing.T) { func TestIssue1137(t *testing.T) { withTestProcess("dotpackagesiface", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") v := evalVariable(p, t, "iface") assertNoError(v.Unreadable, t, "iface unreadable") v2 := evalVariable(p, t, "iface2") @@ -3570,14 +3570,14 @@ func TestIssue1101(t *testing.T) { withTestProcess("issue1101", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.f") - assertNoError(proc.Continue(p), t, "Continue()") - assertNoError(proc.Next(p), t, "Next() 1") - assertNoError(proc.Next(p), t, "Next() 2") + assertNoError(p.Continue(), t, "Continue()") + assertNoError(p.Next(), t, "Next() 1") + assertNoError(p.Next(), t, "Next() 2") lastCmd := "Next() 3" - exitErr := proc.Next(p) + exitErr := p.Next() if exitErr == nil { lastCmd = "final Continue()" - exitErr = proc.Continue(p) + exitErr = p.Continue() } if pexit, exited := exitErr.(proc.ErrProcessExited); exited { if pexit.Status != 2 && testBackend != "lldb" { @@ -3595,7 +3595,7 @@ func TestIssue1101(t *testing.T) { func TestIssue1145(t *testing.T) { withTestProcess("sleep", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 18) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") resumeChan := make(chan struct{}, 1) p.ResumeNotify(resumeChan) go func() { @@ -3604,7 +3604,7 @@ func TestIssue1145(t *testing.T) { p.RequestManualStop() }() - assertNoError(proc.Next(p), t, "Next()") + assertNoError(p.Next(), t, "Next()") if p.Breakpoints().HasInternalBreakpoints() { t.Fatal("has internal breakpoints after manual stop request") } @@ -3742,7 +3742,7 @@ func TestInlinedStacktraceAndVariables(t *testing.T) { } // first inlined call - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") frames, err := proc.ThreadStacktrace(p.CurrentThread(), 20) assertNoError(err, t, "ThreadStacktrace") t.Logf("Stacktrace:\n") @@ -3769,7 +3769,7 @@ func TestInlinedStacktraceAndVariables(t *testing.T) { } // second inlined call - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") frames, err = proc.ThreadStacktrace(p.CurrentThread(), 20) assertNoError(err, t, "ThreadStacktrace (2)") t.Logf("Stacktrace 2:\n") @@ -3902,7 +3902,7 @@ func TestIssue951(t *testing.T) { } withTestProcess("issue951", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") scope, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, t, "GoroutineScope") args, err := scope.FunctionArguments(normalLoadConfig) @@ -3939,7 +3939,7 @@ func TestDWZCompression(t *testing.T) { withTestProcessArgs("dwzcompression", t, ".", []string{}, protest.EnableDWZCompression, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "C.fortytwo") - assertNoError(proc.Continue(p), t, "first Continue()") + assertNoError(p.Continue(), t, "first Continue()") val := evalVariable(p, t, "stdin") if val.RealType == nil { t.Errorf("Can't find type for \"stdin\" global variable") @@ -3951,7 +3951,7 @@ func TestMapLoadConfigWithReslice(t *testing.T) { // Check that load configuration is respected for resliced maps. withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { zolotovLoadCfg := proc.LoadConfig{FollowPointers: true, MaxStructFields: -1, MaxVariableRecurse: 3, MaxStringLen: 10, MaxArrayValues: 10} - assertNoError(proc.Continue(p), t, "First Continue()") + assertNoError(p.Continue(), t, "First Continue()") scope, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, t, "GoroutineScope") m1, err := scope.EvalExpression("m1", zolotovLoadCfg) @@ -3979,8 +3979,8 @@ func TestStepOutReturn(t *testing.T) { } withTestProcess("stepoutret", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.stepout") - assertNoError(proc.Continue(p), t, "Continue") - assertNoError(proc.StepOut(p), t, "StepOut") + assertNoError(p.Continue(), t, "Continue") + assertNoError(p.StepOut(), t, "StepOut") ret := p.CurrentThread().Common().ReturnValues(normalLoadConfig) if len(ret) != 2 { t.Fatalf("wrong number of return values %v", ret) @@ -4048,14 +4048,14 @@ func TestIssue1264(t *testing.T) { withTestProcess("issue1264", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFileBreakpoint(p, t, fixture.Source, 8) bp.Cond = &ast.Ident{Name: "equalsTwo"} - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") assertLineNumber(p, t, 8, "after continue") }) } func TestReadDefer(t *testing.T) { withTestProcess("deferstack", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") frames, err := p.SelectedGoroutine().Stacktrace(10, proc.StacktraceReadDefers) assertNoError(err, t, "Stacktrace") @@ -4121,8 +4121,8 @@ func TestNextUnknownInstr(t *testing.T) { } withTestProcess("nodisasm/", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.asmFunc") - assertNoError(proc.Continue(p), t, "Continue()") - assertNoError(proc.Next(p), t, "Next()") + assertNoError(p.Continue(), t, "Continue()") + assertNoError(p.Next(), t, "Next()") }) } @@ -4139,7 +4139,7 @@ func TestReadDeferArgs(t *testing.T) { } withTestProcess("deferstack", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") for _, test := range tests { scope, err := proc.ConvertEvalScope(p, -1, test.frame, test.deferCall) @@ -4177,10 +4177,10 @@ func TestIssue1374(t *testing.T) { protest.MustSupportFunctionCalls(t, testBackend) withTestProcess("issue1374", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 7) - assertNoError(proc.Continue(p), t, "First Continue") + assertNoError(p.Continue(), t, "First Continue") assertLineNumber(p, t, 7, "Did not continue to correct location (first continue),") assertNoError(proc.EvalExpressionWithCalls(p, p.SelectedGoroutine(), "getNum()", normalLoadConfig, true), t, "Call") - err := proc.Continue(p) + err := p.Continue() if _, isexited := err.(proc.ErrProcessExited); !isexited { regs, _ := p.CurrentThread().Registers(false) f, l, _ := p.BinInfo().PCToLine(regs.PC()) @@ -4195,7 +4195,7 @@ func TestIssue1432(t *testing.T) { // - perform auto-dereferencing on struct member access // - yield a Variable that's ultimately assignable (i.e. has an address) withTestProcess("issue1432", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") svar := evalVariable(p, t, "s") t.Logf("%#x", svar.Addr) @@ -4210,7 +4210,7 @@ func TestIssue1432(t *testing.T) { func TestGoroutinesInfoLimit(t *testing.T) { withTestProcess("teststepconcurrent", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 37) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") gcount := 0 nextg := 0 @@ -4239,7 +4239,7 @@ func TestGoroutinesInfoLimit(t *testing.T) { func TestIssue1469(t *testing.T) { withTestProcess("issue1469", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 13) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") gid2thread := make(map[int][]proc.Thread) for _, thread := range p.ThreadList() { @@ -4277,7 +4277,7 @@ func TestDeadlockBreakpoint(t *testing.T) { deadlockBp = proc.UnrecoveredPanic } withTestProcess("testdeadlock", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") bp := p.CurrentThread().Breakpoint() if bp.Breakpoint == nil || bp.Name != deadlockBp { @@ -4290,7 +4290,7 @@ func TestListImages(t *testing.T) { pluginFixtures := protest.WithPlugins(t, protest.AllNonOptimized, "plugin1/", "plugin2/") withTestProcessArgs("plugintest", t, ".", []string{pluginFixtures[0].Path, pluginFixtures[1].Path}, protest.AllNonOptimized, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "first continue") + assertNoError(p.Continue(), t, "first continue") f, l := currentLineNumber(p, t) plugin1Found := false t.Logf("Libraries before %s:%d:", f, l) @@ -4303,7 +4303,7 @@ func TestListImages(t *testing.T) { if !plugin1Found { t.Fatalf("Could not find plugin1") } - assertNoError(proc.Continue(p), t, "second continue") + assertNoError(p.Continue(), t, "second continue") f, l = currentLineNumber(p, t) plugin1Found, plugin2Found := false, false t.Logf("Libraries after %s:%d:", f, l) @@ -4334,7 +4334,7 @@ func TestAncestors(t *testing.T) { defer os.Setenv("GODEBUG", savedGodebug) withTestProcess("testnextprog", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "main.testgoroutine") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") as, err := proc.Ancestors(p, p.SelectedGoroutine(), 1000) assertNoError(err, t, "Ancestors") t.Logf("ancestors: %#v\n", as) @@ -4396,7 +4396,7 @@ func TestCallConcurrent(t *testing.T) { protest.MustSupportFunctionCalls(t, testBackend) withTestProcess("teststepconcurrent", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFileBreakpoint(p, t, fixture.Source, 24) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") //_, err := p.ClearBreakpoint(bp.Addr) //assertNoError(err, t, "ClearBreakpoint() returned an error") @@ -4425,10 +4425,10 @@ func TestCallConcurrent(t *testing.T) { break } t.Logf("Continuing... %d", returned) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") } - proc.Continue(p) + p.Continue() }) } @@ -4452,7 +4452,7 @@ func TestPluginStepping(t *testing.T) { func TestIssue1601(t *testing.T) { //Tests that recursive types involving C qualifiers and typedefs are parsed correctly withTestProcess("issue1601", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") evalVariable(p, t, "C.globalq") }) } @@ -4468,7 +4468,7 @@ func TestIssue1615(t *testing.T) { Y: &ast.BasicLit{Kind: token.STRING, Value: `"projects/my-gcp-project-id-string/locations/us-central1/queues/my-task-queue-name"`}, } - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") assertLineNumber(p, t, 19, "") }) } @@ -4480,7 +4480,7 @@ func TestCgoStacktrace2(t *testing.T) { // If a panic happens during cgo execution the stacktrace should show the C // function that caused the problem. withTestProcess("cgosigsegvstack", t, func(p *proc.Target, fixture protest.Fixture) { - proc.Continue(p) + p.Continue() frames, err := proc.ThreadStacktrace(p.CurrentThread(), 100) assertNoError(err, t, "Stacktrace()") logStacktrace(t, p.BinInfo(), frames) @@ -4494,12 +4494,12 @@ func TestIssue1656(t *testing.T) { } withTestProcess("issue1656/", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, filepath.ToSlash(filepath.Join(fixture.BuildDir, "main.s")), 5) - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") t.Logf("step1\n") - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Step(), t, "Step()") assertLineNumber(p, t, 8, "wrong line number after first step") t.Logf("step2\n") - assertNoError(proc.Step(p), t, "Step()") + assertNoError(p.Step(), t, "Step()") assertLineNumber(p, t, 9, "wrong line number after second step") }) } @@ -4516,11 +4516,11 @@ func TestBreakpointConfusionOnResume(t *testing.T) { maindots := filepath.ToSlash(filepath.Join(fixture.BuildDir, "main.s")) maindotgo := filepath.ToSlash(filepath.Join(fixture.BuildDir, "main.go")) setFileBreakpoint(p, t, maindots, 5) // line immediately after the NOP - assertNoError(proc.Continue(p), t, "First Continue") + assertNoError(p.Continue(), t, "First Continue") assertLineNumber(p, t, 5, "not on main.s:5") setFileBreakpoint(p, t, maindots, 4) // sets a breakpoint on the NOP line, which will be one byte before the breakpoint we currently are stopped at. setFileBreakpoint(p, t, maindotgo, 18) // set one extra breakpoint so that we can recover execution and check the global variable g - assertNoError(proc.Continue(p), t, "Second Continue") + assertNoError(p.Continue(), t, "Second Continue") gvar := evalVariable(p, t, "g") if n, _ := constant.Int64Val(gvar.Value); n != 1 { t.Fatalf("wrong value of global variable 'g': %v (expected 1)", gvar.Value) @@ -4530,7 +4530,7 @@ func TestBreakpointConfusionOnResume(t *testing.T) { func TestIssue1736(t *testing.T) { withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") ch1BufVar := evalVariable(p, t, "*(ch1.buf)") q := fmt.Sprintf("*(*%q)(%d)", ch1BufVar.DwarfType.Common().Name, ch1BufVar.Addr) t.Logf("%s", q) @@ -4583,16 +4583,16 @@ func TestIssue1795(t *testing.T) { t.Skip("Test not relevant to Go < 1.13") } withTestProcessArgs("issue1795", t, ".", []string{}, protest.EnableInlining|protest.EnableOptimization, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") assertLineNumber(p, t, 12, "wrong line number after Continue,") - assertNoError(proc.Next(p), t, "Next()") + assertNoError(p.Next(), t, "Next()") assertLineNumber(p, t, 13, "wrong line number after Next,") }) withTestProcessArgs("issue1795", t, ".", []string{}, protest.EnableInlining|protest.EnableOptimization, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "regexp.(*Regexp).doExecute") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") assertLineNumber(p, t, 12, "wrong line number after Continue (1),") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") frames, err := proc.ThreadStacktrace(p.CurrentThread(), 40) assertNoError(err, t, "ThreadStacktrace()") logStacktrace(t, p.BinInfo(), frames) @@ -4620,7 +4620,7 @@ func BenchmarkConditionalBreakpoints(b *testing.B) { X: &ast.Ident{Name: "value"}, Y: &ast.BasicLit{Kind: token.INT, Value: "-1"}, } - err := proc.Continue(p) + err := p.Continue() if _, exited := err.(proc.ErrProcessExited); !exited { b.Fatalf("Unexpected error on Continue(): %v", err) } @@ -4750,7 +4750,7 @@ func TestIssue1925(t *testing.T) { // altering the state of the target process. protest.MustSupportFunctionCalls(t, testBackend) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") assertNoError(proc.EvalExpressionWithCalls(p, p.SelectedGoroutine(), "afunc(2)", normalLoadConfig, true), t, "Call") t.Logf("%v\n", p.SelectedGoroutine().CurrentLoc) if loc := p.SelectedGoroutine().CurrentLoc; loc.File != fixture.Source { diff --git a/pkg/proc/proc_unix_test.go b/pkg/proc/proc_unix_test.go index b97f45df..f19dd3ba 100644 --- a/pkg/proc/proc_unix_test.go +++ b/pkg/proc/proc_unix_test.go @@ -32,7 +32,7 @@ func TestIssue419(t *testing.T) { withTestProcess("issue419", t, func(p *proc.Target, fixture protest.Fixture) { defer close(errChan) setFunctionBreakpoint(p, t, "main.main") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") resumeChan := make(chan struct{}, 1) go func() { time.Sleep(500 * time.Millisecond) @@ -48,7 +48,7 @@ func TestIssue419(t *testing.T) { errChan <- errIssue419{pid: p.Pid(), err: err} }() p.ResumeNotify(resumeChan) - errChan <- proc.Continue(p) + errChan <- p.Continue() }) for i := 0; i < 2; i++ { diff --git a/pkg/proc/scope_test.go b/pkg/proc/scope_test.go index b5ee6923..6435fb72 100644 --- a/pkg/proc/scope_test.go +++ b/pkg/proc/scope_test.go @@ -24,7 +24,7 @@ func TestScopeWithEscapedVariable(t *testing.T) { } withTestProcess("scopeescapevareval", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") // On the breakpoint there are two 'a' variables in scope, the one that // isn't shadowed is a variable that escapes to the heap and figures in @@ -80,7 +80,7 @@ func TestScope(t *testing.T) { t.Logf("%d breakpoints set", len(scopeChecks)) for { - if err := proc.Continue(p); err != nil { + if err := p.Continue(); err != nil { if _, exited := err.(proc.ErrProcessExited); exited { break } diff --git a/pkg/proc/variable_test.go b/pkg/proc/variable_test.go index 6b555e86..848cb51a 100644 --- a/pkg/proc/variable_test.go +++ b/pkg/proc/variable_test.go @@ -12,7 +12,7 @@ func TestGoroutineCreationLocation(t *testing.T) { protest.AllowRecording(t) withTestProcess("goroutinestackprog", t, func(p *proc.Target, fixture protest.Fixture) { bp := setFunctionBreakpoint(p, t, "main.agoroutine") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") gs, _, err := proc.GoroutinesInfo(p, 0, 0) assertNoError(err, t, "GoroutinesInfo") @@ -39,6 +39,6 @@ func TestGoroutineCreationLocation(t *testing.T) { } p.ClearBreakpoint(bp.Addr) - proc.Continue(p) + p.Continue() }) } diff --git a/service/debugger/debugger.go b/service/debugger/debugger.go index 721bd09a..9da3e223 100644 --- a/service/debugger/debugger.go +++ b/service/debugger/debugger.go @@ -805,10 +805,10 @@ func (d *Debugger) Command(command *api.DebuggerCommand) (*api.DebuggerState, er if err := d.target.ChangeDirection(proc.Forward); err != nil { return nil, err } - err = proc.Continue(d.target) + err = d.target.Continue() case api.DirectionCongruentContinue: d.log.Debug("continuing (direction congruent)") - err = proc.Continue(d.target) + err = d.target.Continue() case api.Call: d.log.Debugf("function call %s", command.Expr) if err := d.target.ChangeDirection(proc.Forward); err != nil { @@ -830,55 +830,55 @@ func (d *Debugger) Command(command *api.DebuggerCommand) (*api.DebuggerState, er if err := d.target.ChangeDirection(proc.Backward); err != nil { return nil, err } - err = proc.Continue(d.target) + err = d.target.Continue() case api.Next: d.log.Debug("nexting") if err := d.target.ChangeDirection(proc.Forward); err != nil { return nil, err } - err = proc.Next(d.target) + err = d.target.Next() case api.ReverseNext: d.log.Debug("reverse nexting") if err := d.target.ChangeDirection(proc.Backward); err != nil { return nil, err } - err = proc.Next(d.target) + err = d.target.Next() case api.Step: d.log.Debug("stepping") if err := d.target.ChangeDirection(proc.Forward); err != nil { return nil, err } - err = proc.Step(d.target) + err = d.target.Step() case api.ReverseStep: d.log.Debug("reverse stepping") if err := d.target.ChangeDirection(proc.Backward); err != nil { return nil, err } - err = proc.Step(d.target) + err = d.target.Step() case api.StepInstruction: d.log.Debug("single stepping") if err := d.target.ChangeDirection(proc.Forward); err != nil { return nil, err } - err = proc.StepInstruction(d.target) + err = d.target.StepInstruction() case api.ReverseStepInstruction: d.log.Debug("reverse single stepping") if err := d.target.ChangeDirection(proc.Backward); err != nil { return nil, err } - err = proc.StepInstruction(d.target) + err = d.target.StepInstruction() case api.StepOut: d.log.Debug("step out") if err := d.target.ChangeDirection(proc.Forward); err != nil { return nil, err } - err = proc.StepOut(d.target) + err = d.target.StepOut() case api.ReverseStepOut: d.log.Debug("reverse step out") if err := d.target.ChangeDirection(proc.Backward); err != nil { return nil, err } - err = proc.StepOut(d.target) + err = d.target.StepOut() case api.SwitchThread: d.log.Debugf("switching to thread %d", command.ThreadID) err = d.target.SwitchThread(command.ThreadID) diff --git a/service/test/variables_test.go b/service/test/variables_test.go index e69aacfb..4e1943b5 100644 --- a/service/test/variables_test.go +++ b/service/test/variables_test.go @@ -200,7 +200,7 @@ func TestVariableEvaluation(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() assertNoError(err, t, "Continue() returned an error") for _, tc := range testcases { @@ -258,7 +258,7 @@ func TestSetVariable(t *testing.T) { } withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") for _, tc := range testcases { if tc.name == "iface1" && tc.expr == "parr" { @@ -327,7 +327,7 @@ func TestVariableEvaluationShort(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() assertNoError(err, t, "Continue() returned an error") for _, tc := range testcases { @@ -383,7 +383,7 @@ func TestMultilineVariableEvaluation(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() assertNoError(err, t, "Continue() returned an error") for _, tc := range testcases { @@ -457,7 +457,7 @@ func TestLocalVariables(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() assertNoError(err, t, "Continue() returned an error") for _, tc := range testcases { @@ -503,7 +503,7 @@ func TestEmbeddedStruct(t *testing.T) { {"b.s", true, "\"hello\"", "\"hello\"", "string", nil}, {"b2", true, "main.B {A: main.A {val: 42}, C: *main.C nil, a: main.A {val: 47}, ptr: *main.A nil}", "main.B {A: (*main.A)(0x…", "main.B", nil}, } - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") ver, _ := goversion.Parse(runtime.Version()) if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) { @@ -535,7 +535,7 @@ func TestEmbeddedStruct(t *testing.T) { func TestComplexSetting(t *testing.T) { withTestProcess("testvariables", t, func(p *proc.Target, fixture protest.Fixture) { - err := proc.Continue(p) + err := p.Continue() assertNoError(err, t, "Continue() returned an error") h := func(setExpr, value string) { @@ -833,7 +833,7 @@ func TestEvalExpression(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") for _, tc := range testcases { variable, err := evalVariable(p, tc.name, pnormalLoadConfig) if err != nil && err.Error() == "evaluating methods not supported on this version of Go" { @@ -862,7 +862,7 @@ func TestEvalExpression(t *testing.T) { func TestEvalAddrAndCast(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") c1addr, err := evalVariable(p, "&c1", pnormalLoadConfig) assertNoError(err, t, "EvalExpression(&c1)") c1addrstr := api.ConvertVar(c1addr).SinglelineString() @@ -889,7 +889,7 @@ func TestEvalAddrAndCast(t *testing.T) { func TestMapEvaluation(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") m1v, err := evalVariable(p, "m1", pnormalLoadConfig) assertNoError(err, t, "EvalVariable()") m1 := api.ConvertVar(m1v) @@ -931,7 +931,7 @@ func TestMapEvaluation(t *testing.T) { func TestUnsafePointer(t *testing.T) { protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") up1v, err := evalVariable(p, "up1", pnormalLoadConfig) assertNoError(err, t, "EvalVariable(up1)") up1 := api.ConvertVar(up1v) @@ -969,7 +969,7 @@ func TestIssue426(t *testing.T) { // differs from the serialization used by the linker to produce DWARF type information protest.AllowRecording(t) withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") for _, testcase := range testcases { v, err := evalVariable(p, testcase.name, pnormalLoadConfig) assertNoError(err, t, fmt.Sprintf("EvalVariable(%s)", testcase.name)) @@ -1060,7 +1060,7 @@ func TestPackageRenames(t *testing.T) { protest.AllowRecording(t) withTestProcess("pkgrenames", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue() returned an error") + assertNoError(p.Continue(), t, "Continue() returned an error") testPackageRenamesHelper(t, p, testcases) if goversion.VersionAfterOrEqual(runtime.Version(), 1, 9) { @@ -1100,7 +1100,7 @@ func TestConstants(t *testing.T) { t.Skip("constants added in go 1.10") } withTestProcess("consts", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue") + assertNoError(p.Continue(), t, "Continue") for _, testcase := range testcases { variable, err := evalVariable(p, testcase.name, pnormalLoadConfig) assertNoError(err, t, fmt.Sprintf("EvalVariable(%s)", testcase.name)) @@ -1130,7 +1130,7 @@ func setFunctionBreakpoint(p *proc.Target, t testing.TB, fname string) *proc.Bre func TestIssue1075(t *testing.T) { withTestProcess("clientdo", t, func(p *proc.Target, fixture protest.Fixture) { setFunctionBreakpoint(p, t, "net/http.(*Client).Do") - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") for i := 0; i < 10; i++ { scope, err := proc.GoroutineScope(p.CurrentThread()) assertNoError(err, t, fmt.Sprintf("GoroutineScope (%d)", i)) @@ -1271,7 +1271,7 @@ func TestCallFunction(t *testing.T) { if err != nil { t.Skip("function calls not supported on this version of go") } - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") for _, tc := range testcases { testCallFunction(t, p, tc) } @@ -1381,7 +1381,7 @@ func testCallFunction(t *testing.T, p *proc.Target, tc testCaseCallFunction) { func TestIssue1531(t *testing.T) { // Go 1.12 introduced a change to the map representation where empty cells can be marked with 1 instead of just 0. withTestProcess("issue1531", t, func(p *proc.Target, fixture protest.Fixture) { - assertNoError(proc.Continue(p), t, "Continue()") + assertNoError(p.Continue(), t, "Continue()") hasKeys := func(mv *proc.Variable, keys ...string) { n := 0 @@ -1463,7 +1463,7 @@ func TestPluginVariables(t *testing.T) { withTestProcessArgs("plugintest2", t, ".", []string{pluginFixtures[0].Path, pluginFixtures[1].Path}, protest.AllNonOptimized, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture, 41) - assertNoError(proc.Continue(p), t, "Continue 1") + assertNoError(p.Continue(), t, "Continue 1") bp := setFunctionBreakpoint(p, t, "github.com/go-delve/delve/_fixtures/plugin2.TypesTest") t.Logf("bp.Addr = %#x", bp.Addr) @@ -1473,7 +1473,7 @@ func TestPluginVariables(t *testing.T) { t.Logf("%#x %s\n", image.StaticBase, image.Path) } - assertNoError(proc.Continue(p), t, "Continue 2") + assertNoError(p.Continue(), t, "Continue 2") // test that PackageVariables returns variables from the executable and plugins scope, err := evalScope(p) @@ -1503,15 +1503,15 @@ func TestPluginVariables(t *testing.T) { // test that the concrete type -> interface{} conversion works across plugins (mostly tests proc.dwarfToRuntimeType) assertNoError(setVariable(p, "plugin2.A", "main.ExeGlobal"), t, "setVariable(plugin2.A = main.ExeGlobal)") - assertNoError(proc.Continue(p), t, "Continue 3") + assertNoError(p.Continue(), t, "Continue 3") assertCurrentLocationFunction(p, t, "github.com/go-delve/delve/_fixtures/plugin2.aIsNotNil") vstr, err := evalVariable(p, "str", pnormalLoadConfig) assertNoError(err, t, "Eval(str)") assertVariable(t, vstr, varTest{"str", true, `"success"`, ``, `string`, nil}) - assertNoError(proc.StepOut(p), t, "StepOut") - assertNoError(proc.StepOut(p), t, "StepOut") - assertNoError(proc.Next(p), t, "Next") + assertNoError(p.StepOut(), t, "StepOut") + assertNoError(p.StepOut(), t, "StepOut") + assertNoError(p.Next(), t, "Next") // read interface variable, inside executable code, with a concrete type defined in a plugin vb, err := evalVariable(p, "b", pnormalLoadConfig)