proc: bugfix: clearing temp breakpoints
Temp breakpoints should be cleared even if a non-temp breakpoint is triggered on the same goroutine that the temp breakpoints are set on. Fixes #305
This commit is contained in:
parent
b839eda2a9
commit
453bd0217f
7
_fixtures/issue305.go
Normal file
7
_fixtures/issue305.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
println(i)
|
||||||
|
}
|
||||||
|
}
|
@ -353,6 +353,7 @@ func (dbp *Process) Continue() error {
|
|||||||
if err := dbp.pickCurrentThread(trapthread); err != nil {
|
if err := dbp.pickCurrentThread(trapthread); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case dbp.CurrentThread.CurrentBreakpoint == nil:
|
case dbp.CurrentThread.CurrentBreakpoint == nil:
|
||||||
// runtime.Breakpoint or manual stop
|
// runtime.Breakpoint or manual stop
|
||||||
@ -367,6 +368,9 @@ func (dbp *Process) Continue() error {
|
|||||||
case dbp.CurrentThread.onTriggeredTempBreakpoint():
|
case dbp.CurrentThread.onTriggeredTempBreakpoint():
|
||||||
return dbp.clearTempBreakpoints()
|
return dbp.clearTempBreakpoints()
|
||||||
case dbp.CurrentThread.onTriggeredBreakpoint():
|
case dbp.CurrentThread.onTriggeredBreakpoint():
|
||||||
|
if dbp.CurrentThread.onNextGoroutine() {
|
||||||
|
return dbp.clearTempBreakpoints()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
// not a manual stop, not on runtime.Breakpoint, not on a breakpoint, just repeat
|
// not a manual stop, not on runtime.Breakpoint, not on a breakpoint, just repeat
|
||||||
|
@ -1315,6 +1315,25 @@ func TestIssue262(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue305(t *testing.T) {
|
||||||
|
// If 'next' hits a breakpoint on the goroutine it's stepping through the temp breakpoints aren't cleared
|
||||||
|
// preventing further use of 'next' command
|
||||||
|
withTestProcess("issue305", t, func(p *Process, fixture protest.Fixture) {
|
||||||
|
addr, _, err := p.goSymTable.LineToPC(fixture.Source, 5)
|
||||||
|
assertNoError(err, t, "LineToPC()")
|
||||||
|
_, err = p.SetBreakpoint(addr)
|
||||||
|
assertNoError(err, t, "SetBreakpoint()")
|
||||||
|
|
||||||
|
assertNoError(p.Continue(), t, "Continue()")
|
||||||
|
|
||||||
|
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")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestIssue341(t *testing.T) {
|
func TestIssue341(t *testing.T) {
|
||||||
// pointer loop through map entries
|
// pointer loop through map entries
|
||||||
withTestProcess("testvariables3", t, func(p *Process, fixture protest.Fixture) {
|
withTestProcess("testvariables3", t, func(p *Process, fixture protest.Fixture) {
|
||||||
|
@ -359,3 +359,17 @@ func (thread *Thread) onRuntimeBreakpoint() bool {
|
|||||||
}
|
}
|
||||||
return loc.Fn != nil && loc.Fn.Name == "runtime.breakpoint"
|
return loc.Fn != nil && loc.Fn.Name == "runtime.breakpoint"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if this thread is on the goroutine requested by the current 'next' command
|
||||||
|
func (th *Thread) onNextGoroutine() bool {
|
||||||
|
var bp *Breakpoint
|
||||||
|
for i := range th.dbp.Breakpoints {
|
||||||
|
if th.dbp.Breakpoints[i].Temp {
|
||||||
|
bp = th.dbp.Breakpoints[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if bp == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return bp.checkCondition(th)
|
||||||
|
}
|
||||||
|
@ -20,7 +20,7 @@ const (
|
|||||||
maxVariableRecurse = 1 // How far to recurse when evaluating nested types.
|
maxVariableRecurse = 1 // How far to recurse when evaluating nested types.
|
||||||
maxArrayValues = 64 // Max value for reading large arrays.
|
maxArrayValues = 64 // Max value for reading large arrays.
|
||||||
maxErrCount = 3 // Max number of read errors to accept while evaluating slices, arrays and structs
|
maxErrCount = 3 // Max number of read errors to accept while evaluating slices, arrays and structs
|
||||||
|
|
||||||
maxArrayStridePrefetch = 1024 // Maximum size of array stride for which we will prefetch the array contents
|
maxArrayStridePrefetch = 1024 // Maximum size of array stride for which we will prefetch the array contents
|
||||||
|
|
||||||
chanRecv = "chan receive"
|
chanRecv = "chan receive"
|
||||||
|
Loading…
Reference in New Issue
Block a user