fix(cmd): stop the coverage run on a stray in-place trap
Assisted-by: GLM 5.3
This commit is contained in:
@@ -239,10 +239,12 @@ REPL commands:
|
||||
fmt.Printf("gasm debug: cover: stopped on signal %v\n", sig)
|
||||
break
|
||||
}
|
||||
reason, _ := sess.StopInfo()
|
||||
regs, rerr := sess.GetRegs()
|
||||
if rerr != nil {
|
||||
break
|
||||
}
|
||||
trapPC := regs.GetPC()
|
||||
// HandleTrap restores the original byte, rewinds PC and counts
|
||||
// the hit on the breakpoint itself. Single-step over the
|
||||
// restored instruction so the reinsertion at the top of the
|
||||
@@ -251,6 +253,12 @@ REPL commands:
|
||||
if err := sess.Step(); err != nil {
|
||||
break
|
||||
}
|
||||
} else if debug.TrapStray(sess, reason, trapPC) {
|
||||
// A breakpoint-class trap that matches none of ours and left
|
||||
// the PC in place: resuming would re-execute the trapping
|
||||
// instruction forever, so the coverage run stops here.
|
||||
fmt.Printf("gasm debug: cover: SIGTRAP at %#x matches no breakpoint; the PC did not advance\n", trapPC)
|
||||
break
|
||||
}
|
||||
}
|
||||
hits := map[uint64]int{}
|
||||
|
||||
Reference in New Issue
Block a user