mirror of
https://github.com/go-delve/delve.git
synced 2025-10-27 12:05:21 +08:00
tests: remove duplicate code (#1669)
This commit is contained in:
committed by
Derek Parker
parent
4779218a83
commit
327fbdbd44
@ -159,10 +159,9 @@ func TestExit(t *testing.T) {
|
|||||||
func TestExitAfterContinue(t *testing.T) {
|
func TestExitAfterContinue(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("continuetestprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("continuetestprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.sayhi")
|
setFunctionBreakpoint(p, t, "main.sayhi")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "First Continue()")
|
assertNoError(proc.Continue(p), t, "First Continue()")
|
||||||
err = proc.Continue(p)
|
err := proc.Continue(p)
|
||||||
pe, ok := err.(proc.ErrProcessExited)
|
pe, ok := err.(proc.ErrProcessExited)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Continue() returned unexpected error type %s", pe)
|
t.Fatalf("Continue() returned unexpected error type %s", pe)
|
||||||
@ -176,35 +175,60 @@ func TestExitAfterContinue(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFunctionBreakpoint(p proc.Process, fname string) (*proc.Breakpoint, error) {
|
func setFunctionBreakpoint(p proc.Process, t testing.TB, fname string) *proc.Breakpoint {
|
||||||
|
_, f, l, _ := runtime.Caller(1)
|
||||||
|
f = filepath.Base(f)
|
||||||
|
|
||||||
addr, err := proc.FindFunctionLocation(p, fname, 0)
|
addr, err := proc.FindFunctionLocation(p, fname, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
t.Fatalf("%s:%d: FindFunctionLocation(%s): %v", f, l, fname, err)
|
||||||
}
|
|
||||||
return p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setFileBreakpoint(p proc.Process, t *testing.T, fixture protest.Fixture, lineno int) *proc.Breakpoint {
|
|
||||||
return setFileLineBreakpoint(p, t, fixture.Source, lineno)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setFileLineBreakpoint(p proc.Process, t *testing.T, path string, lineno int) *proc.Breakpoint {
|
|
||||||
addr, err := proc.FindFileLocation(p, path, lineno)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("FindFileLocation: %v", err)
|
|
||||||
}
|
}
|
||||||
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("SetBreakpoint: %v", err)
|
t.Fatalf("%s:%d: FindFunctionLocation(%s): %v", f, l, fname, err)
|
||||||
}
|
}
|
||||||
return bp
|
return bp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setFileBreakpoint(p proc.Process, t *testing.T, path string, lineno int) *proc.Breakpoint {
|
||||||
|
_, f, l, _ := runtime.Caller(1)
|
||||||
|
f = filepath.Base(f)
|
||||||
|
|
||||||
|
addr, err := proc.FindFileLocation(p, path, lineno)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%s:%d: FindFileLocation(%s, %d): %v", f, l, path, lineno, err)
|
||||||
|
}
|
||||||
|
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%s:%d: SetBreakpoint: %v", f, l, err)
|
||||||
|
}
|
||||||
|
return bp
|
||||||
|
}
|
||||||
|
|
||||||
|
func findFunctionLocation(p proc.Process, t *testing.T, fnname string) uint64 {
|
||||||
|
addr, err := proc.FindFunctionLocation(p, fnname, 0)
|
||||||
|
if err != nil {
|
||||||
|
_, f, l, _ := runtime.Caller(1)
|
||||||
|
f = filepath.Base(f)
|
||||||
|
t.Fatalf("%s:%d: FindFunctionLocation(%s): %v", f, l, fnname, err)
|
||||||
|
}
|
||||||
|
return addr
|
||||||
|
}
|
||||||
|
|
||||||
|
func findFileLocation(p proc.Process, t *testing.T, file string, lineno int) uint64 {
|
||||||
|
addr, err := proc.FindFileLocation(p, file, lineno)
|
||||||
|
if err != nil {
|
||||||
|
_, f, l, _ := runtime.Caller(1)
|
||||||
|
f = filepath.Base(f)
|
||||||
|
t.Fatalf("%s:%d: FindFileLocation(%s, %d): %v", f, l, file, lineno, err)
|
||||||
|
}
|
||||||
|
return addr
|
||||||
|
}
|
||||||
|
|
||||||
func TestHalt(t *testing.T) {
|
func TestHalt(t *testing.T) {
|
||||||
stopChan := make(chan interface{}, 1)
|
stopChan := make(chan interface{}, 1)
|
||||||
withTestProcess("loopprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("loopprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.loop")
|
setFunctionBreakpoint(p, t, "main.loop")
|
||||||
assertNoError(err, t, "SetBreakpoint")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue")
|
assertNoError(proc.Continue(p), t, "Continue")
|
||||||
if p, ok := p.(*native.Process); ok {
|
if p, ok := p.(*native.Process); ok {
|
||||||
for _, th := range p.ThreadList() {
|
for _, th := range p.ThreadList() {
|
||||||
@ -246,17 +270,13 @@ func TestHalt(t *testing.T) {
|
|||||||
func TestStep(t *testing.T) {
|
func TestStep(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("testprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
helloworldaddr, err := proc.FindFunctionLocation(p, "main.helloworld", 0)
|
setFunctionBreakpoint(p, t, "main.helloworld")
|
||||||
assertNoError(err, t, "FindFunctionLocation")
|
|
||||||
|
|
||||||
_, err = p.SetBreakpoint(helloworldaddr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
regs := getRegisters(p, t)
|
regs := getRegisters(p, t)
|
||||||
rip := regs.PC()
|
rip := regs.PC()
|
||||||
|
|
||||||
err = p.CurrentThread().StepInstruction()
|
err := p.CurrentThread().StepInstruction()
|
||||||
assertNoError(err, t, "Step()")
|
assertNoError(err, t, "Step()")
|
||||||
|
|
||||||
regs = getRegisters(p, t)
|
regs = getRegisters(p, t)
|
||||||
@ -269,11 +289,7 @@ func TestStep(t *testing.T) {
|
|||||||
func TestBreakpoint(t *testing.T) {
|
func TestBreakpoint(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("testprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
helloworldaddr, err := proc.FindFunctionLocation(p, "main.helloworld", 0)
|
bp := setFunctionBreakpoint(p, t, "main.helloworld")
|
||||||
assertNoError(err, t, "FindFunctionLocation")
|
|
||||||
|
|
||||||
bp, err := p.SetBreakpoint(helloworldaddr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
regs, err := p.CurrentThread().Registers(false)
|
regs, err := p.CurrentThread().Registers(false)
|
||||||
@ -294,11 +310,7 @@ func TestBreakpoint(t *testing.T) {
|
|||||||
func TestBreakpointInSeparateGoRoutine(t *testing.T) {
|
func TestBreakpointInSeparateGoRoutine(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("testthreads", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testthreads", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
fnentry, err := proc.FindFunctionLocation(p, "main.anotherthread", 0)
|
setFunctionBreakpoint(p, t, "main.anotherthread")
|
||||||
assertNoError(err, t, "FindFunctionLocation")
|
|
||||||
|
|
||||||
_, err = p.SetBreakpoint(fnentry, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint")
|
|
||||||
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue")
|
assertNoError(proc.Continue(p), t, "Continue")
|
||||||
|
|
||||||
@ -324,12 +336,9 @@ func TestBreakpointWithNonExistantFunction(t *testing.T) {
|
|||||||
|
|
||||||
func TestClearBreakpointBreakpoint(t *testing.T) {
|
func TestClearBreakpointBreakpoint(t *testing.T) {
|
||||||
withTestProcess("testprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
fnentry, err := proc.FindFunctionLocation(p, "main.sleepytime", 0)
|
bp := setFunctionBreakpoint(p, t, "main.sleepytime")
|
||||||
assertNoError(err, t, "FindFunctionLocation")
|
|
||||||
bp, err := p.SetBreakpoint(fnentry, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
bp, err = p.ClearBreakpoint(fnentry)
|
_, err := p.ClearBreakpoint(bp.Addr)
|
||||||
assertNoError(err, t, "ClearBreakpoint()")
|
assertNoError(err, t, "ClearBreakpoint()")
|
||||||
|
|
||||||
data, err := dataAtAddr(p.CurrentThread(), bp.Addr)
|
data, err := dataAtAddr(p.CurrentThread(), bp.Addr)
|
||||||
@ -398,21 +407,16 @@ func testseq2Args(wd string, args []string, buildFlags protest.BuildFlags, t *te
|
|||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcessArgs(program, t, wd, args, buildFlags, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcessArgs(program, t, wd, args, buildFlags, func(p proc.Process, fixture protest.Fixture) {
|
||||||
var bp *proc.Breakpoint
|
var bp *proc.Breakpoint
|
||||||
var err error
|
|
||||||
if initialLocation != "" {
|
if initialLocation != "" {
|
||||||
bp, err = setFunctionBreakpoint(p, initialLocation)
|
bp = setFunctionBreakpoint(p, t, initialLocation)
|
||||||
} else if testcases[0].cf == contContinue {
|
} else if testcases[0].cf == contContinue {
|
||||||
var pc uint64
|
bp = setFileBreakpoint(p, t, fixture.Source, testcases[0].pos.(int))
|
||||||
pc, err = proc.FindFileLocation(p, fixture.Source, testcases[0].pos.(int))
|
|
||||||
assertNoError(err, t, "FindFileLocation()")
|
|
||||||
bp, err = p.SetBreakpoint(pc, proc.UserBreakpoint, nil)
|
|
||||||
} else {
|
} else {
|
||||||
panic("testseq2 can not set initial breakpoint")
|
panic("testseq2 can not set initial breakpoint")
|
||||||
}
|
}
|
||||||
if traceTestseq2 {
|
if traceTestseq2 {
|
||||||
t.Logf("initial breakpoint %v", bp)
|
t.Logf("initial breakpoint %v", bp)
|
||||||
}
|
}
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
regs, err := p.CurrentThread().Registers(false)
|
regs, err := p.CurrentThread().Registers(false)
|
||||||
assertNoError(err, t, "Registers")
|
assertNoError(err, t, "Registers")
|
||||||
|
|
||||||
@ -534,13 +538,12 @@ func TestNextConcurrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.sayhi")
|
bp := setFunctionBreakpoint(p, t, "main.sayhi")
|
||||||
assertNoError(err, t, "SetBreakpoint")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue")
|
assertNoError(proc.Continue(p), t, "Continue")
|
||||||
f, ln := currentLineNumber(p, t)
|
f, ln := currentLineNumber(p, t)
|
||||||
initV := evalVariable(p, t, "n")
|
initV := evalVariable(p, t, "n")
|
||||||
initVval, _ := constant.Int64Val(initV.Value)
|
initVval, _ := constant.Int64Val(initV.Value)
|
||||||
_, err = p.ClearBreakpoint(bp.Addr)
|
_, err := p.ClearBreakpoint(bp.Addr)
|
||||||
assertNoError(err, t, "ClearBreakpoint()")
|
assertNoError(err, t, "ClearBreakpoint()")
|
||||||
for _, tc := range testcases {
|
for _, tc := range testcases {
|
||||||
g, err := proc.GetG(p.CurrentThread())
|
g, err := proc.GetG(p.CurrentThread())
|
||||||
@ -574,8 +577,7 @@ func TestNextConcurrentVariant2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.sayhi")
|
setFunctionBreakpoint(p, t, "main.sayhi")
|
||||||
assertNoError(err, t, "SetBreakpoint")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue")
|
assertNoError(proc.Continue(p), t, "Continue")
|
||||||
f, ln := currentLineNumber(p, t)
|
f, ln := currentLineNumber(p, t)
|
||||||
initV := evalVariable(p, t, "n")
|
initV := evalVariable(p, t, "n")
|
||||||
@ -711,15 +713,8 @@ func returnAddress(thread proc.Thread) (uint64, error) {
|
|||||||
func TestFindReturnAddress(t *testing.T) {
|
func TestFindReturnAddress(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("testnextprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testnextprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
start, _, err := p.BinInfo().LineToPC(fixture.Source, 24)
|
setFileBreakpoint(p, t, fixture.Source, 24)
|
||||||
if err != nil {
|
err := proc.Continue(p)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
_, err = p.SetBreakpoint(start, proc.UserBreakpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = proc.Continue(p)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -738,11 +733,7 @@ func TestFindReturnAddressTopOfStackFn(t *testing.T) {
|
|||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("testreturnaddress", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testreturnaddress", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
fnName := "runtime.rt0_go"
|
fnName := "runtime.rt0_go"
|
||||||
fnentry, err := proc.FindFunctionLocation(p, fnName, 0)
|
setFunctionBreakpoint(p, t, fnName)
|
||||||
assertNoError(err, t, "FindFunctionLocation")
|
|
||||||
if _, err := p.SetBreakpoint(fnentry, proc.UserBreakpoint, nil); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := proc.Continue(p); err != nil {
|
if err := proc.Continue(p); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -760,14 +751,7 @@ func TestSwitchThread(t *testing.T) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("Expected error for invalid thread id")
|
t.Fatal("Expected error for invalid thread id")
|
||||||
}
|
}
|
||||||
pc, err := proc.FindFunctionLocation(p, "main.main", 0)
|
setFunctionBreakpoint(p, t, "main.main")
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
_, err = p.SetBreakpoint(pc, proc.UserBreakpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = proc.Continue(p)
|
err = proc.Continue(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -806,22 +790,9 @@ func TestCGONext(t *testing.T) {
|
|||||||
|
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("cgotest", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("cgotest", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
pc, err := proc.FindFunctionLocation(p, "main.main", 0)
|
setFunctionBreakpoint(p, t, "main.main")
|
||||||
if err != nil {
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
t.Fatal(err)
|
assertNoError(proc.Next(p), t, "Next()")
|
||||||
}
|
|
||||||
_, err = p.SetBreakpoint(pc, proc.UserBreakpoint, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = proc.Continue(p)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = proc.Next(p)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,8 +817,7 @@ func TestStacktrace(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("stacktraceprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("stacktraceprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.stacktraceme")
|
bp := setFunctionBreakpoint(p, t, "main.stacktraceme")
|
||||||
assertNoError(err, t, "BreakByLocation()")
|
|
||||||
|
|
||||||
for i := range stacks {
|
for i := range stacks {
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
@ -936,8 +906,7 @@ func TestStacktraceGoroutine(t *testing.T) {
|
|||||||
|
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("goroutinestackprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("goroutinestackprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.stacktraceme")
|
bp := setFunctionBreakpoint(p, t, "main.stacktraceme")
|
||||||
assertNoError(err, t, "BreakByLocation()")
|
|
||||||
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
@ -1015,8 +984,7 @@ func TestKill(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testGSupportFunc(name string, t *testing.T, p proc.Process, fixture protest.Fixture) {
|
func testGSupportFunc(name string, t *testing.T, p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.main")
|
bp := setFunctionBreakpoint(p, t, "main.main")
|
||||||
assertNoError(err, t, name+": BreakByLocation()")
|
|
||||||
|
|
||||||
assertNoError(proc.Continue(p), t, name+": Continue()")
|
assertNoError(proc.Continue(p), t, name+": Continue()")
|
||||||
|
|
||||||
@ -1054,11 +1022,8 @@ func TestGetG(t *testing.T) {
|
|||||||
func TestContinueMulti(t *testing.T) {
|
func TestContinueMulti(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("integrationprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("integrationprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp1, err := setFunctionBreakpoint(p, "main.main")
|
bp1 := setFunctionBreakpoint(p, t, "main.main")
|
||||||
assertNoError(err, t, "BreakByLocation()")
|
bp2 := setFunctionBreakpoint(p, t, "main.sayhi")
|
||||||
|
|
||||||
bp2, err := setFunctionBreakpoint(p, "main.sayhi")
|
|
||||||
assertNoError(err, t, "BreakByLocation()")
|
|
||||||
|
|
||||||
mainCount := 0
|
mainCount := 0
|
||||||
sayhiCount := 0
|
sayhiCount := 0
|
||||||
@ -1105,10 +1070,7 @@ func TestProcessReceivesSIGCHLD(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue239(t *testing.T) {
|
func TestIssue239(t *testing.T) {
|
||||||
withTestProcess("is sue239", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("is sue239", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
pos, _, err := p.BinInfo().LineToPC(fixture.Source, 17)
|
setFileBreakpoint(p, t, fixture.Source, 17)
|
||||||
assertNoError(err, t, "LineToPC()")
|
|
||||||
_, err = p.SetBreakpoint(pos, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, fmt.Sprintf("SetBreakpoint(%d)", pos))
|
|
||||||
assertNoError(proc.Continue(p), t, fmt.Sprintf("Continue()"))
|
assertNoError(proc.Continue(p), t, fmt.Sprintf("Continue()"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1253,8 +1215,7 @@ func TestVariableEvaluation(t *testing.T) {
|
|||||||
func TestFrameEvaluation(t *testing.T) {
|
func TestFrameEvaluation(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("goroutinestackprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("goroutinestackprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.stacktraceme")
|
setFunctionBreakpoint(p, t, "main.stacktraceme")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
t.Logf("stopped on thread %d, goroutine: %#v", p.CurrentThread().ThreadID(), p.SelectedGoroutine())
|
t.Logf("stopped on thread %d, goroutine: %#v", p.CurrentThread().ThreadID(), p.SelectedGoroutine())
|
||||||
@ -1408,10 +1369,7 @@ func TestBreakpointCounts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("bpcountstest", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("bpcountstest", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addr, _, err := p.BinInfo().LineToPC(fixture.Source, 12)
|
bp := setFileBreakpoint(p, t, fixture.Source, 12)
|
||||||
assertNoError(err, t, "LineToPC")
|
|
||||||
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if err := proc.Continue(p); err != nil {
|
if err := proc.Continue(p); err != nil {
|
||||||
@ -1460,10 +1418,7 @@ func TestBreakpointCountsWithDetection(t *testing.T) {
|
|||||||
m := map[int64]int64{}
|
m := map[int64]int64{}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("bpcountstest", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("bpcountstest", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addr, _, err := p.BinInfo().LineToPC(fixture.Source, 12)
|
bp := setFileBreakpoint(p, t, fixture.Source, 12)
|
||||||
assertNoError(err, t, "LineToPC")
|
|
||||||
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if err := proc.Continue(p); err != nil {
|
if err := proc.Continue(p); err != nil {
|
||||||
@ -1557,13 +1512,10 @@ func TestIssue262(t *testing.T) {
|
|||||||
// Continue does not work when the current breakpoint is set on a NOP instruction
|
// Continue does not work when the current breakpoint is set on a NOP instruction
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue262", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue262", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addr, _, err := p.BinInfo().LineToPC(fixture.Source, 11)
|
setFileBreakpoint(p, t, fixture.Source, 11)
|
||||||
assertNoError(err, t, "LineToPC")
|
|
||||||
_, err = p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
err = proc.Continue(p)
|
err := proc.Continue(p)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("No error on second continue")
|
t.Fatalf("No error on second continue")
|
||||||
}
|
}
|
||||||
@ -1580,10 +1532,7 @@ func TestIssue305(t *testing.T) {
|
|||||||
// 'next' command
|
// 'next' command
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue305", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue305", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addr, _, err := p.BinInfo().LineToPC(fixture.Source, 5)
|
setFileBreakpoint(p, t, fixture.Source, 5)
|
||||||
assertNoError(err, t, "LineToPC()")
|
|
||||||
_, err = p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
@ -1628,10 +1577,7 @@ func TestCondBreakpoint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addr, _, err := p.BinInfo().LineToPC(fixture.Source, 9)
|
bp := setFileBreakpoint(p, t, fixture.Source, 9)
|
||||||
assertNoError(err, t, "LineToPC")
|
|
||||||
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
bp.Cond = &ast.BinaryExpr{
|
bp.Cond = &ast.BinaryExpr{
|
||||||
Op: token.EQL,
|
Op: token.EQL,
|
||||||
X: &ast.Ident{Name: "n"},
|
X: &ast.Ident{Name: "n"},
|
||||||
@ -1655,17 +1601,14 @@ func TestCondBreakpointError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addr, _, err := p.BinInfo().LineToPC(fixture.Source, 9)
|
bp := setFileBreakpoint(p, t, fixture.Source, 9)
|
||||||
assertNoError(err, t, "LineToPC")
|
|
||||||
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
bp.Cond = &ast.BinaryExpr{
|
bp.Cond = &ast.BinaryExpr{
|
||||||
Op: token.EQL,
|
Op: token.EQL,
|
||||||
X: &ast.Ident{Name: "nonexistentvariable"},
|
X: &ast.Ident{Name: "nonexistentvariable"},
|
||||||
Y: &ast.BasicLit{Kind: token.INT, Value: "7"},
|
Y: &ast.BasicLit{Kind: token.INT, Value: "7"},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = proc.Continue(p)
|
err := proc.Continue(p)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("No error on first Continue()")
|
t.Fatalf("No error on first Continue()")
|
||||||
}
|
}
|
||||||
@ -1743,10 +1686,7 @@ func TestIssue384(t *testing.T) {
|
|||||||
|
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue384", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue384", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
start, _, err := p.BinInfo().LineToPC(fixture.Source, 13)
|
setFileBreakpoint(p, t, fixture.Source, 13)
|
||||||
assertNoError(err, t, "LineToPC()")
|
|
||||||
_, err = p.SetBreakpoint(start, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
evalVariable(p, t, "st")
|
evalVariable(p, t, "st")
|
||||||
})
|
})
|
||||||
@ -1756,10 +1696,7 @@ func TestIssue332_Part1(t *testing.T) {
|
|||||||
// Next shouldn't step inside a function call
|
// Next shouldn't step inside a function call
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue332", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue332", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
start, _, err := p.BinInfo().LineToPC(fixture.Source, 8)
|
setFileBreakpoint(p, t, fixture.Source, 8)
|
||||||
assertNoError(err, t, "LineToPC()")
|
|
||||||
_, err = p.SetBreakpoint(start, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
assertNoError(proc.Next(p), t, "first Next()")
|
assertNoError(proc.Next(p), t, "first Next()")
|
||||||
locations, err := proc.ThreadStacktrace(p.CurrentThread(), 2)
|
locations, err := proc.ThreadStacktrace(p.CurrentThread(), 2)
|
||||||
@ -1783,10 +1720,7 @@ func TestIssue332_Part2(t *testing.T) {
|
|||||||
// because the incorrect FDE data leads to reading the wrong stack address as the return address
|
// because the incorrect FDE data leads to reading the wrong stack address as the return address
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue332", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue332", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
start, _, err := p.BinInfo().LineToPC(fixture.Source, 8)
|
setFileBreakpoint(p, t, fixture.Source, 8)
|
||||||
assertNoError(err, t, "LineToPC()")
|
|
||||||
_, err = p.SetBreakpoint(start, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
// step until we enter changeMe
|
// step until we enter changeMe
|
||||||
@ -1805,8 +1739,7 @@ func TestIssue332_Part2(t *testing.T) {
|
|||||||
regs, err := p.CurrentThread().Registers(false)
|
regs, err := p.CurrentThread().Registers(false)
|
||||||
assertNoError(err, t, "Registers()")
|
assertNoError(err, t, "Registers()")
|
||||||
pc := regs.PC()
|
pc := regs.PC()
|
||||||
pcAfterPrologue, err := proc.FindFunctionLocation(p, "main.changeMe", 0)
|
pcAfterPrologue := findFunctionLocation(p, t, "main.changeMe")
|
||||||
assertNoError(err, t, "FindFunctionLocation()")
|
|
||||||
if pcAfterPrologue == p.BinInfo().LookupFunc["main.changeMe"].Entry {
|
if pcAfterPrologue == p.BinInfo().LookupFunc["main.changeMe"].Entry {
|
||||||
t.Fatalf("main.changeMe and main.changeMe:0 are the same (%x)", pcAfterPrologue)
|
t.Fatalf("main.changeMe and main.changeMe:0 are the same (%x)", pcAfterPrologue)
|
||||||
}
|
}
|
||||||
@ -1831,8 +1764,7 @@ func TestIssue396(t *testing.T) {
|
|||||||
t.Skip("no autogenerated init function in Go 1.13 or later")
|
t.Skip("no autogenerated init function in Go 1.13 or later")
|
||||||
}
|
}
|
||||||
withTestProcess("callme", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("callme", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := proc.FindFunctionLocation(p, "main.init", 0)
|
findFunctionLocation(p, t, "main.init")
|
||||||
assertNoError(err, t, "FindFunctionLocation()")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1840,10 +1772,7 @@ func TestIssue414(t *testing.T) {
|
|||||||
// Stepping until the program exits
|
// Stepping until the program exits
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("math", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("math", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
start, _, err := p.BinInfo().LineToPC(fixture.Source, 9)
|
setFileBreakpoint(p, t, fixture.Source, 9)
|
||||||
assertNoError(err, t, "LineToPC()")
|
|
||||||
_, err = p.SetBreakpoint(start, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
for {
|
for {
|
||||||
err := proc.Step(p)
|
err := proc.Step(p)
|
||||||
@ -1886,8 +1815,7 @@ func TestIssue149(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// setting breakpoint on break statement
|
// setting breakpoint on break statement
|
||||||
withTestProcess("break", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("break", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := proc.FindFileLocation(p, fixture.Source, 8)
|
findFileLocation(p, t, fixture.Source, 8)
|
||||||
assertNoError(err, t, "FindFileLocation()")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1974,8 +1902,7 @@ func TestNextParked(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.sayhi")
|
bp := setFunctionBreakpoint(p, t, "main.sayhi")
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
// continue until a parked goroutine exists
|
// continue until a parked goroutine exists
|
||||||
var parkedg *proc.G
|
var parkedg *proc.G
|
||||||
@ -2028,8 +1955,7 @@ func TestStepParked(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("parallel_next", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.sayhi")
|
bp := setFunctionBreakpoint(p, t, "main.sayhi")
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
// continue until a parked goroutine exists
|
// continue until a parked goroutine exists
|
||||||
var parkedg *proc.G
|
var parkedg *proc.G
|
||||||
@ -2150,9 +2076,7 @@ func TestIssue573(t *testing.T) {
|
|||||||
// of the function and the internal breakpoint set by StepInto may be missed.
|
// of the function and the internal breakpoint set by StepInto may be missed.
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue573", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue573", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
fentry, _ := proc.FindFunctionLocation(p, "main.foo", 0)
|
setFunctionBreakpoint(p, t, "main.foo")
|
||||||
_, err := p.SetBreakpoint(fentry, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
assertNoError(proc.Step(p), t, "Step() #1")
|
assertNoError(proc.Step(p), t, "Step() #1")
|
||||||
assertNoError(proc.Step(p), t, "Step() #2") // Bug exits here.
|
assertNoError(proc.Step(p), t, "Step() #2") // Bug exits here.
|
||||||
@ -2163,8 +2087,7 @@ func TestIssue573(t *testing.T) {
|
|||||||
func TestTestvariables2Prologue(t *testing.T) {
|
func TestTestvariables2Prologue(t *testing.T) {
|
||||||
withTestProcess("testvariables2", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testvariables2", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addrEntry := p.BinInfo().LookupFunc["main.main"].Entry
|
addrEntry := p.BinInfo().LookupFunc["main.main"].Entry
|
||||||
addrPrologue, err := proc.FindFunctionLocation(p, "main.main", 0)
|
addrPrologue := findFunctionLocation(p, t, "main.main")
|
||||||
assertNoError(err, t, "FindFunctionLocation - postprologue")
|
|
||||||
if addrEntry == addrPrologue {
|
if addrEntry == addrPrologue {
|
||||||
t.Fatalf("Prologue detection failed on testvariables2.go/main.main")
|
t.Fatalf("Prologue detection failed on testvariables2.go/main.main")
|
||||||
}
|
}
|
||||||
@ -2335,7 +2258,7 @@ func TestIssue561(t *testing.T) {
|
|||||||
// where a breakpoint is also set.
|
// where a breakpoint is also set.
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue561", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue561", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileBreakpoint(p, t, fixture, 10)
|
setFileBreakpoint(p, t, fixture.Source, 10)
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
assertNoError(proc.Step(p), t, "Step()")
|
assertNoError(proc.Step(p), t, "Step()")
|
||||||
assertLineNumber(p, t, 5, "wrong line number after Step,")
|
assertLineNumber(p, t, 5, "wrong line number after Step,")
|
||||||
@ -2352,13 +2275,10 @@ func TestStepConcurrentDirect(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
pc, err := proc.FindFileLocation(p, fixture.Source, 37)
|
bp := setFileBreakpoint(p, t, fixture.Source, 37)
|
||||||
assertNoError(err, t, "FindFileLocation()")
|
|
||||||
bp, err := p.SetBreakpoint(pc, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
_, err = p.ClearBreakpoint(bp.Addr)
|
_, err := p.ClearBreakpoint(bp.Addr)
|
||||||
assertNoError(err, t, "ClearBreakpoint()")
|
assertNoError(err, t, "ClearBreakpoint()")
|
||||||
|
|
||||||
for _, b := range p.Breakpoints().M {
|
for _, b := range p.Breakpoints().M {
|
||||||
@ -2421,10 +2341,7 @@ func TestStepConcurrentPtr(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
pc, err := proc.FindFileLocation(p, fixture.Source, 24)
|
setFileBreakpoint(p, t, fixture.Source, 24)
|
||||||
assertNoError(err, t, "FindFileLocation()")
|
|
||||||
_, err = p.SetBreakpoint(pc, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
for _, b := range p.Breakpoints().M {
|
for _, b := range p.Breakpoints().M {
|
||||||
if b.Name == proc.UnrecoveredPanic {
|
if b.Name == proc.UnrecoveredPanic {
|
||||||
@ -2496,10 +2413,7 @@ func TestStepConcurrentPtr(t *testing.T) {
|
|||||||
func TestStepOutDefer(t *testing.T) {
|
func TestStepOutDefer(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("testnextdefer", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testnextdefer", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
pc, err := proc.FindFileLocation(p, fixture.Source, 9)
|
bp := setFileBreakpoint(p, t, fixture.Source, 9)
|
||||||
assertNoError(err, t, "FindFileLocation()")
|
|
||||||
bp, err := p.SetBreakpoint(pc, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
p.ClearBreakpoint(bp.Addr)
|
p.ClearBreakpoint(bp.Addr)
|
||||||
|
|
||||||
@ -2528,10 +2442,7 @@ const maxInstructionLength uint64 = 15
|
|||||||
func TestStepOnCallPtrInstr(t *testing.T) {
|
func TestStepOnCallPtrInstr(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("teststepprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("teststepprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
pc, err := proc.FindFileLocation(p, fixture.Source, 10)
|
setFileBreakpoint(p, t, fixture.Source, 10)
|
||||||
assertNoError(err, t, "FindFileLocation()")
|
|
||||||
_, err = p.SetBreakpoint(pc, proc.UserBreakpoint, nil)
|
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
@ -2622,9 +2533,7 @@ func TestWorkDir(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcessArgs("workdir", t, wd, []string{}, 0, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcessArgs("workdir", t, wd, []string{}, 0, func(p proc.Process, fixture protest.Fixture) {
|
||||||
addr, _, err := p.BinInfo().LineToPC(fixture.Source, 14)
|
setFileBreakpoint(p, t, fixture.Source, 14)
|
||||||
assertNoError(err, t, "LineToPC")
|
|
||||||
p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
|
||||||
proc.Continue(p)
|
proc.Continue(p)
|
||||||
v := evalVariable(p, t, "pwd")
|
v := evalVariable(p, t, "pwd")
|
||||||
str := constant.StringVal(v.Value)
|
str := constant.StringVal(v.Value)
|
||||||
@ -2663,8 +2572,7 @@ func TestIssue683(t *testing.T) {
|
|||||||
// Step panics when source file can not be found
|
// Step panics when source file can not be found
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue683", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue683", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.main")
|
setFunctionBreakpoint(p, t, "main.main")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "First Continue()")
|
assertNoError(proc.Continue(p), t, "First Continue()")
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
// eventually an error about the source file not being found will be
|
// eventually an error about the source file not being found will be
|
||||||
@ -2680,7 +2588,7 @@ func TestIssue683(t *testing.T) {
|
|||||||
func TestIssue664(t *testing.T) {
|
func TestIssue664(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("issue664", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue664", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileBreakpoint(p, t, fixture, 4)
|
setFileBreakpoint(p, t, fixture.Source, 4)
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
assertNoError(proc.Next(p), t, "Next()")
|
assertNoError(proc.Next(p), t, "Next()")
|
||||||
assertLineNumber(p, t, 5, "Did not continue to correct location,")
|
assertLineNumber(p, t, 5, "Did not continue to correct location,")
|
||||||
@ -2691,8 +2599,7 @@ func TestIssue664(t *testing.T) {
|
|||||||
func BenchmarkTrace(b *testing.B) {
|
func BenchmarkTrace(b *testing.B) {
|
||||||
protest.AllowRecording(b)
|
protest.AllowRecording(b)
|
||||||
withTestProcess("traceperf", b, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("traceperf", b, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.PerfCheck")
|
setFunctionBreakpoint(p, b, "main.PerfCheck")
|
||||||
assertNoError(err, b, "setFunctionBreakpoint()")
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
assertNoError(proc.Continue(p), b, "Continue()")
|
assertNoError(proc.Continue(p), b, "Continue()")
|
||||||
@ -2712,15 +2619,13 @@ func TestNextInDeferReturn(t *testing.T) {
|
|||||||
// We need to deal with this without panicing.
|
// We need to deal with this without panicing.
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("defercall", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("defercall", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "runtime.deferreturn")
|
setFunctionBreakpoint(p, t, "runtime.deferreturn")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint(runtime.deferreturn)")
|
|
||||||
assertNoError(proc.Continue(p), t, "First Continue()")
|
assertNoError(proc.Continue(p), t, "First Continue()")
|
||||||
|
|
||||||
// Set a breakpoint on the deferred function so that the following loop
|
// 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
|
// can not step out of the runtime.deferreturn and all the way to the
|
||||||
// point where the target program panics.
|
// point where the target program panics.
|
||||||
_, err = setFunctionBreakpoint(p, "main.sampleFunction")
|
setFunctionBreakpoint(p, t, "main.sampleFunction")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint(main.sampleFunction)")
|
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
loc, err := p.CurrentThread().Location()
|
loc, err := p.CurrentThread().Location()
|
||||||
assertNoError(err, t, "CurrentThread().Location()")
|
assertNoError(err, t, "CurrentThread().Location()")
|
||||||
@ -2761,8 +2666,7 @@ func TestStacktraceWithBarriers(t *testing.T) {
|
|||||||
|
|
||||||
withTestProcess("binarytrees", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("binarytrees", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
// We want to get a user goroutine with a stack barrier, to get that we execute the program until runtime.gcInstallStackBarrier is executed AND the goroutine it was executed onto contains a call to main.bottomUpTree
|
// We want to get a user goroutine with a stack barrier, to get that we execute the program until runtime.gcInstallStackBarrier is executed AND the goroutine it was executed onto contains a call to main.bottomUpTree
|
||||||
_, err := setFunctionBreakpoint(p, "runtime.gcInstallStackBarrier")
|
setFunctionBreakpoint(p, t, "runtime.gcInstallStackBarrier")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
stackBarrierGoids := []int{}
|
stackBarrierGoids := []int{}
|
||||||
for len(stackBarrierGoids) == 0 {
|
for len(stackBarrierGoids) == 0 {
|
||||||
err := proc.Continue(p)
|
err := proc.Continue(p)
|
||||||
@ -2969,10 +2873,9 @@ func TestRecursiveNext(t *testing.T) {
|
|||||||
testseq("increment", contNext, testcases, "main.Increment", t)
|
testseq("increment", contNext, testcases, "main.Increment", t)
|
||||||
|
|
||||||
withTestProcess("increment", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("increment", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.Increment")
|
bp := setFunctionBreakpoint(p, t, "main.Increment")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue")
|
assertNoError(proc.Continue(p), t, "Continue")
|
||||||
_, err = p.ClearBreakpoint(bp.Addr)
|
_, err := p.ClearBreakpoint(bp.Addr)
|
||||||
assertNoError(err, t, "ClearBreakpoint")
|
assertNoError(err, t, "ClearBreakpoint")
|
||||||
assertNoError(proc.Next(p), t, "Next 1")
|
assertNoError(proc.Next(p), t, "Next 1")
|
||||||
assertNoError(proc.Next(p), t, "Next 2")
|
assertNoError(proc.Next(p), t, "Next 2")
|
||||||
@ -3209,8 +3112,8 @@ func TestIssue844(t *testing.T) {
|
|||||||
// Conditional breakpoints should not prevent next from working if their
|
// Conditional breakpoints should not prevent next from working if their
|
||||||
// condition isn't met.
|
// condition isn't met.
|
||||||
withTestProcess("nextcond", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("nextcond", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileBreakpoint(p, t, fixture, 9)
|
setFileBreakpoint(p, t, fixture.Source, 9)
|
||||||
condbp := setFileBreakpoint(p, t, fixture, 10)
|
condbp := setFileBreakpoint(p, t, fixture.Source, 10)
|
||||||
condbp.Cond = &ast.BinaryExpr{
|
condbp.Cond = &ast.BinaryExpr{
|
||||||
Op: token.EQL,
|
Op: token.EQL,
|
||||||
X: &ast.Ident{Name: "n"},
|
X: &ast.Ident{Name: "n"},
|
||||||
@ -3439,8 +3342,7 @@ func TestCgoSources(t *testing.T) {
|
|||||||
func TestSystemstackStacktrace(t *testing.T) {
|
func TestSystemstackStacktrace(t *testing.T) {
|
||||||
// check that we can follow a stack switch initiated by runtime.systemstack()
|
// check that we can follow a stack switch initiated by runtime.systemstack()
|
||||||
withTestProcess("panic", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("panic", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "runtime.startpanic_m")
|
setFunctionBreakpoint(p, t, "runtime.startpanic_m")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "first continue")
|
assertNoError(proc.Continue(p), t, "first continue")
|
||||||
assertNoError(proc.Continue(p), t, "second continue")
|
assertNoError(proc.Continue(p), t, "second continue")
|
||||||
g, err := proc.GetG(p.CurrentThread())
|
g, err := proc.GetG(p.CurrentThread())
|
||||||
@ -3462,16 +3364,14 @@ func TestSystemstackOnRuntimeNewstack(t *testing.T) {
|
|||||||
// If one of the other goroutines is resizing its own stack the stack
|
// If one of the other goroutines is resizing its own stack the stack
|
||||||
// command won't work for it.
|
// command won't work for it.
|
||||||
withTestProcess("binarytrees", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("binarytrees", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.main")
|
setFunctionBreakpoint(p, t, "main.main")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint(main.main)")
|
|
||||||
assertNoError(proc.Continue(p), t, "first continue")
|
assertNoError(proc.Continue(p), t, "first continue")
|
||||||
|
|
||||||
g, err := proc.GetG(p.CurrentThread())
|
g, err := proc.GetG(p.CurrentThread())
|
||||||
assertNoError(err, t, "GetG")
|
assertNoError(err, t, "GetG")
|
||||||
mainGoroutineID := g.ID
|
mainGoroutineID := g.ID
|
||||||
|
|
||||||
_, err = setFunctionBreakpoint(p, "runtime.newstack")
|
setFunctionBreakpoint(p, t, "runtime.newstack")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint(runtime.newstack)")
|
|
||||||
for {
|
for {
|
||||||
assertNoError(proc.Continue(p), t, "second continue")
|
assertNoError(proc.Continue(p), t, "second continue")
|
||||||
g, err = proc.GetG(p.CurrentThread())
|
g, err = proc.GetG(p.CurrentThread())
|
||||||
@ -3494,8 +3394,7 @@ func TestIssue1034(t *testing.T) {
|
|||||||
// The external linker on macOS produces an abbrev for DW_TAG_subprogram
|
// The external linker on macOS produces an abbrev for DW_TAG_subprogram
|
||||||
// without the "has children" flag, we should support this.
|
// without the "has children" flag, we should support this.
|
||||||
withTestProcess("cgostacktest/", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("cgostacktest/", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.main")
|
setFunctionBreakpoint(p, t, "main.main")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
frames, err := p.SelectedGoroutine().Stacktrace(10, false)
|
frames, err := p.SelectedGoroutine().Stacktrace(10, false)
|
||||||
assertNoError(err, t, "Stacktrace")
|
assertNoError(err, t, "Stacktrace")
|
||||||
@ -3512,8 +3411,7 @@ func TestIssue1008(t *testing.T) {
|
|||||||
// The external linker on macOS inserts "end of sequence" extended opcodes
|
// The external linker on macOS inserts "end of sequence" extended opcodes
|
||||||
// in debug_line. which we should support correctly.
|
// in debug_line. which we should support correctly.
|
||||||
withTestProcess("cgostacktest/", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("cgostacktest/", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.main")
|
setFunctionBreakpoint(p, t, "main.main")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
loc, err := p.CurrentThread().Location()
|
loc, err := p.CurrentThread().Location()
|
||||||
assertNoError(err, t, "CurrentThread().Location()")
|
assertNoError(err, t, "CurrentThread().Location()")
|
||||||
@ -3583,8 +3481,7 @@ func TestIssue1101(t *testing.T) {
|
|||||||
// the thread group leader.
|
// the thread group leader.
|
||||||
|
|
||||||
withTestProcess("issue1101", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue1101", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.f")
|
setFunctionBreakpoint(p, t, "main.f")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
assertNoError(proc.Next(p), t, "Next() 1")
|
assertNoError(proc.Next(p), t, "Next() 1")
|
||||||
assertNoError(proc.Next(p), t, "Next() 2")
|
assertNoError(proc.Next(p), t, "Next() 2")
|
||||||
@ -3609,7 +3506,7 @@ func TestIssue1101(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue1145(t *testing.T) {
|
func TestIssue1145(t *testing.T) {
|
||||||
withTestProcess("sleep", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("sleep", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileBreakpoint(p, t, fixture, 18)
|
setFileBreakpoint(p, t, fixture.Source, 18)
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
resumeChan := make(chan struct{}, 1)
|
resumeChan := make(chan struct{}, 1)
|
||||||
p.ResumeNotify(resumeChan)
|
p.ResumeNotify(resumeChan)
|
||||||
@ -3934,8 +3831,7 @@ func TestDWZCompression(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
withTestProcessArgs("dwzcompression", t, ".", []string{}, protest.EnableDWZCompression, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcessArgs("dwzcompression", t, ".", []string{}, protest.EnableDWZCompression, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "C.fortytwo")
|
setFunctionBreakpoint(p, t, "C.fortytwo")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "first Continue()")
|
assertNoError(proc.Continue(p), t, "first Continue()")
|
||||||
val := evalVariable(p, t, "stdin")
|
val := evalVariable(p, t, "stdin")
|
||||||
if val.RealType == nil {
|
if val.RealType == nil {
|
||||||
@ -3975,8 +3871,7 @@ func TestStepOutReturn(t *testing.T) {
|
|||||||
t.Skip("return variables aren't marked on 1.9 or earlier")
|
t.Skip("return variables aren't marked on 1.9 or earlier")
|
||||||
}
|
}
|
||||||
withTestProcess("stepoutret", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("stepoutret", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.stepout")
|
setFunctionBreakpoint(p, t, "main.stepout")
|
||||||
assertNoError(err, t, "SetBreakpoint")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue")
|
assertNoError(proc.Continue(p), t, "Continue")
|
||||||
assertNoError(proc.StepOut(p), t, "StepOut")
|
assertNoError(proc.StepOut(p), t, "StepOut")
|
||||||
ret := p.CurrentThread().Common().ReturnValues(normalLoadConfig)
|
ret := p.CurrentThread().Common().ReturnValues(normalLoadConfig)
|
||||||
@ -4044,7 +3939,7 @@ func TestIssue1264(t *testing.T) {
|
|||||||
// It should be possible to set a breakpoint condition that consists only
|
// It should be possible to set a breakpoint condition that consists only
|
||||||
// of evaluating a single boolean variable.
|
// of evaluating a single boolean variable.
|
||||||
withTestProcess("issue1264", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue1264", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp := setFileBreakpoint(p, t, fixture, 8)
|
bp := setFileBreakpoint(p, t, fixture.Source, 8)
|
||||||
bp.Cond = &ast.Ident{Name: "equalsTwo"}
|
bp.Cond = &ast.Ident{Name: "equalsTwo"}
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
assertLineNumber(p, t, 8, "after continue")
|
assertLineNumber(p, t, 8, "after continue")
|
||||||
@ -4115,8 +4010,7 @@ func TestNextUnknownInstr(t *testing.T) {
|
|||||||
t.Skip("versions of Go before 1.10 can't assemble the instruction VPUNPCKLWD")
|
t.Skip("versions of Go before 1.10 can't assemble the instruction VPUNPCKLWD")
|
||||||
}
|
}
|
||||||
withTestProcess("nodisasm/", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("nodisasm/", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.asmFunc")
|
setFunctionBreakpoint(p, t, "main.asmFunc")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
assertNoError(proc.Next(p), t, "Next()")
|
assertNoError(proc.Next(p), t, "Next()")
|
||||||
})
|
})
|
||||||
@ -4169,7 +4063,7 @@ func TestIssue1374(t *testing.T) {
|
|||||||
// Continue did not work when stopped at a breakpoint immediately after calling CallFunction.
|
// Continue did not work when stopped at a breakpoint immediately after calling CallFunction.
|
||||||
protest.MustSupportFunctionCalls(t, testBackend)
|
protest.MustSupportFunctionCalls(t, testBackend)
|
||||||
withTestProcess("issue1374", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue1374", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileBreakpoint(p, t, fixture, 7)
|
setFileBreakpoint(p, t, fixture.Source, 7)
|
||||||
assertNoError(proc.Continue(p), t, "First Continue")
|
assertNoError(proc.Continue(p), t, "First Continue")
|
||||||
assertLineNumber(p, t, 7, "Did not continue to correct location (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")
|
assertNoError(proc.EvalExpressionWithCalls(p, p.SelectedGoroutine(), "getNum()", normalLoadConfig, true), t, "Call")
|
||||||
@ -4202,7 +4096,7 @@ func TestIssue1432(t *testing.T) {
|
|||||||
|
|
||||||
func TestGoroutinesInfoLimit(t *testing.T) {
|
func TestGoroutinesInfoLimit(t *testing.T) {
|
||||||
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileBreakpoint(p, t, fixture, 37)
|
setFileBreakpoint(p, t, fixture.Source, 37)
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
gcount := 0
|
gcount := 0
|
||||||
@ -4231,7 +4125,7 @@ func TestGoroutinesInfoLimit(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue1469(t *testing.T) {
|
func TestIssue1469(t *testing.T) {
|
||||||
withTestProcess("issue1469", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue1469", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileBreakpoint(p, t, fixture, 13)
|
setFileBreakpoint(p, t, fixture.Source, 13)
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
gid2thread := make(map[int][]proc.Thread)
|
gid2thread := make(map[int][]proc.Thread)
|
||||||
@ -4326,8 +4220,7 @@ func TestAncestors(t *testing.T) {
|
|||||||
os.Setenv("GODEBUG", "tracebackancestors=100")
|
os.Setenv("GODEBUG", "tracebackancestors=100")
|
||||||
defer os.Setenv("GODEBUG", savedGodebug)
|
defer os.Setenv("GODEBUG", savedGodebug)
|
||||||
withTestProcess("testnextprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("testnextprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "main.testgoroutine")
|
setFunctionBreakpoint(p, t, "main.testgoroutine")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
as, err := proc.Ancestors(p, p.SelectedGoroutine(), 1000)
|
as, err := proc.Ancestors(p, p.SelectedGoroutine(), 1000)
|
||||||
assertNoError(err, t, "Ancestors")
|
assertNoError(err, t, "Ancestors")
|
||||||
@ -4388,7 +4281,7 @@ func TestCallConcurrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
protest.MustSupportFunctionCalls(t, testBackend)
|
protest.MustSupportFunctionCalls(t, testBackend)
|
||||||
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("teststepconcurrent", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp := setFileBreakpoint(p, t, fixture, 24)
|
bp := setFileBreakpoint(p, t, fixture.Source, 24)
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
//_, err := p.ClearBreakpoint(bp.Addr)
|
//_, err := p.ClearBreakpoint(bp.Addr)
|
||||||
//assertNoError(err, t, "ClearBreakpoint() returned an error")
|
//assertNoError(err, t, "ClearBreakpoint() returned an error")
|
||||||
@ -4454,7 +4347,7 @@ func TestIssue1615(t *testing.T) {
|
|||||||
// A breakpoint condition that tests for string equality with a constant string shouldn't fail with 'string too long for comparison' error
|
// A breakpoint condition that tests for string equality with a constant string shouldn't fail with 'string too long for comparison' error
|
||||||
|
|
||||||
withTestProcess("issue1615", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue1615", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp := setFileBreakpoint(p, t, fixture, 19)
|
bp := setFileBreakpoint(p, t, fixture.Source, 19)
|
||||||
bp.Cond = &ast.BinaryExpr{
|
bp.Cond = &ast.BinaryExpr{
|
||||||
Op: token.EQL,
|
Op: token.EQL,
|
||||||
X: &ast.Ident{Name: "s"},
|
X: &ast.Ident{Name: "s"},
|
||||||
@ -4483,7 +4376,7 @@ func TestCgoStacktrace2(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue1656(t *testing.T) {
|
func TestIssue1656(t *testing.T) {
|
||||||
withTestProcess("issue1656/", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue1656/", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileLineBreakpoint(p, t, filepath.ToSlash(filepath.Join(fixture.BuildDir, "main.s")), 5)
|
setFileBreakpoint(p, t, filepath.ToSlash(filepath.Join(fixture.BuildDir, "main.s")), 5)
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
t.Logf("step1\n")
|
t.Logf("step1\n")
|
||||||
assertNoError(proc.Step(p), t, "Step()")
|
assertNoError(proc.Step(p), t, "Step()")
|
||||||
|
|||||||
@ -36,8 +36,7 @@ func TestIssue419(t *testing.T) {
|
|||||||
// SIGINT directed at the inferior should be passed along not swallowed by delve
|
// SIGINT directed at the inferior should be passed along not swallowed by delve
|
||||||
withTestProcess("issue419", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("issue419", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
defer close(errChan)
|
defer close(errChan)
|
||||||
_, err := setFunctionBreakpoint(p, "main.main")
|
setFunctionBreakpoint(p, t, "main.main")
|
||||||
assertNoError(err, t, "SetBreakpoint()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
resumeChan := make(chan struct{}, 1)
|
resumeChan := make(chan struct{}, 1)
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
@ -73,7 +73,7 @@ func TestScope(t *testing.T) {
|
|||||||
|
|
||||||
withTestProcess("scopetest", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("scopetest", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
for i := range scopeChecks {
|
for i := range scopeChecks {
|
||||||
setFileBreakpoint(p, t, fixture, scopeChecks[i].line)
|
setFileBreakpoint(p, t, fixture.Source, scopeChecks[i].line)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("%d breakpoints set", len(scopeChecks))
|
t.Logf("%d breakpoints set", len(scopeChecks))
|
||||||
|
|||||||
@ -11,8 +11,7 @@ import (
|
|||||||
func TestGoroutineCreationLocation(t *testing.T) {
|
func TestGoroutineCreationLocation(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestProcess("goroutinestackprog", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("goroutinestackprog", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.agoroutine")
|
bp := setFunctionBreakpoint(p, t, "main.agoroutine")
|
||||||
assertNoError(err, t, "BreakByLocation()")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
gs, _, err := proc.GoroutinesInfo(p, 0, 0)
|
gs, _, err := proc.GoroutinesInfo(p, 0, 0)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/constant"
|
"go/constant"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -1061,18 +1062,24 @@ func TestConstants(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFunctionBreakpoint(p proc.Process, fname string) (*proc.Breakpoint, error) {
|
func setFunctionBreakpoint(p proc.Process, t testing.TB, fname string) *proc.Breakpoint {
|
||||||
|
_, f, l, _ := runtime.Caller(1)
|
||||||
|
f = filepath.Base(f)
|
||||||
|
|
||||||
addr, err := proc.FindFunctionLocation(p, fname, 0)
|
addr, err := proc.FindFunctionLocation(p, fname, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
t.Fatalf("%s:%d: FindFunctionLocation(%s): %v", f, l, fname, err)
|
||||||
}
|
}
|
||||||
return p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%s:%d: FindFunctionLocation(%s): %v", f, l, fname, err)
|
||||||
|
}
|
||||||
|
return bp
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIssue1075(t *testing.T) {
|
func TestIssue1075(t *testing.T) {
|
||||||
withTestProcess("clientdo", t, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcess("clientdo", t, func(p proc.Process, fixture protest.Fixture) {
|
||||||
_, err := setFunctionBreakpoint(p, "net/http.(*Client).Do")
|
setFunctionBreakpoint(p, t, "net/http.(*Client).Do")
|
||||||
assertNoError(err, t, "setFunctionBreakpoint")
|
|
||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
scope, err := proc.GoroutineScope(p.CurrentThread())
|
scope, err := proc.GoroutineScope(p.CurrentThread())
|
||||||
@ -1326,14 +1333,17 @@ func TestIssue1531(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFileLineBreakpoint(p proc.Process, t *testing.T, path string, lineno int) *proc.Breakpoint {
|
func setFileBreakpoint(p proc.Process, t *testing.T, fixture protest.Fixture, lineno int) *proc.Breakpoint {
|
||||||
addr, err := proc.FindFileLocation(p, path, lineno)
|
_, f, l, _ := runtime.Caller(1)
|
||||||
|
f = filepath.Base(f)
|
||||||
|
|
||||||
|
addr, err := proc.FindFileLocation(p, fixture.Source, lineno)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("FindFileLocation: %v", err)
|
t.Fatalf("%s:%d: FindFileLocation(%s, %d): %v", f, l, fixture.Source, lineno, err)
|
||||||
}
|
}
|
||||||
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
bp, err := p.SetBreakpoint(addr, proc.UserBreakpoint, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("SetBreakpoint: %v", err)
|
t.Fatalf("%s:%d: SetBreakpoint: %v", f, l, err)
|
||||||
}
|
}
|
||||||
return bp
|
return bp
|
||||||
}
|
}
|
||||||
@ -1362,14 +1372,12 @@ func TestPluginVariables(t *testing.T) {
|
|||||||
pluginFixtures := protest.WithPlugins(t, protest.AllNonOptimized, "plugin1/", "plugin2/")
|
pluginFixtures := protest.WithPlugins(t, protest.AllNonOptimized, "plugin1/", "plugin2/")
|
||||||
|
|
||||||
withTestProcessArgs("plugintest2", t, ".", []string{pluginFixtures[0].Path, pluginFixtures[1].Path}, protest.AllNonOptimized, func(p proc.Process, fixture protest.Fixture) {
|
withTestProcessArgs("plugintest2", t, ".", []string{pluginFixtures[0].Path, pluginFixtures[1].Path}, protest.AllNonOptimized, func(p proc.Process, fixture protest.Fixture) {
|
||||||
setFileLineBreakpoint(p, t, fixture.Source, 41)
|
setFileBreakpoint(p, t, fixture, 41)
|
||||||
assertNoError(proc.Continue(p), t, "Continue 1")
|
assertNoError(proc.Continue(p), t, "Continue 1")
|
||||||
|
|
||||||
bp, err := setFunctionBreakpoint(p, "github.com/go-delve/delve/_fixtures/plugin2.TypesTest")
|
bp := setFunctionBreakpoint(p, t, "github.com/go-delve/delve/_fixtures/plugin2.TypesTest")
|
||||||
assertNoError(err, t, "SetBreakpoint(TypesTest)")
|
|
||||||
t.Logf("bp.Addr = %#x", bp.Addr)
|
t.Logf("bp.Addr = %#x", bp.Addr)
|
||||||
_, err = setFunctionBreakpoint(p, "github.com/go-delve/delve/_fixtures/plugin2.aIsNotNil")
|
setFunctionBreakpoint(p, t, "github.com/go-delve/delve/_fixtures/plugin2.aIsNotNil")
|
||||||
assertNoError(err, t, "SetBreakpoint(aIsNotNil)")
|
|
||||||
|
|
||||||
for _, image := range p.BinInfo().Images {
|
for _, image := range p.BinInfo().Images {
|
||||||
t.Logf("%#x %s\n", image.StaticBase, image.Path)
|
t.Logf("%#x %s\n", image.StaticBase, image.Path)
|
||||||
|
|||||||
Reference in New Issue
Block a user