From df5812bf2d623647ef705cacb9ac5fc4eb37f29e Mon Sep 17 00:00:00 2001 From: Suzy Mueller Date: Tue, 3 Aug 2021 10:47:24 -0600 Subject: [PATCH] pkg/proc: add tests for next interrupted by bp (#2632) Adds tests that make sure that when a next request is interrupted by a breakpoint, the stepping breakpoints are cleared. --- pkg/proc/proc_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index b470dcee..74bf01e9 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -2545,6 +2545,40 @@ func TestStepConcurrentPtr(t *testing.T) { }) } +func TestStepOutBreakpoint(t *testing.T) { + protest.AllowRecording(t) + withTestProcess("testnextprog", t, func(p *proc.Target, fixture protest.Fixture) { + bp := setFileBreakpoint(p, t, fixture.Source, 13) + assertNoError(p.Continue(), t, "Continue()") + p.ClearBreakpoint(bp.Addr) + + // StepOut should be interrupted by a breakpoint on the same goroutine. + setFileBreakpoint(p, t, fixture.Source, 14) + assertNoError(p.StepOut(), t, "StepOut()") + assertLineNumber(p, t, 14, "wrong line number") + if p.Breakpoints().HasSteppingBreakpoints() { + t.Fatal("has internal breakpoints after hitting breakpoint on same goroutine") + } + }) +} + +func TestNextBreakpoint(t *testing.T) { + protest.AllowRecording(t) + withTestProcess("testnextprog", t, func(p *proc.Target, fixture protest.Fixture) { + bp := setFileBreakpoint(p, t, fixture.Source, 34) + assertNoError(p.Continue(), t, "Continue()") + p.ClearBreakpoint(bp.Addr) + + // Next should be interrupted by a breakpoint on the same goroutine. + setFileBreakpoint(p, t, fixture.Source, 14) + assertNoError(p.Next(), t, "Next()") + assertLineNumber(p, t, 14, "wrong line number") + if p.Breakpoints().HasSteppingBreakpoints() { + t.Fatal("has internal breakpoints after hitting breakpoint on same goroutine") + } + }) +} + func TestStepOutDefer(t *testing.T) { protest.AllowRecording(t) withTestProcess("testnextdefer", t, func(p *proc.Target, fixture protest.Fixture) {