From f405cea5bc29fa6628d0783a8ca58bfb901b0f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Balv=C3=ADn?= Date: Fri, 2 Oct 2026 00:40:54 +0200 Subject: [PATCH] fix(cmd): stop the coverage run on a stray in-place trap Assisted-by: GLM 5.3 --- cmd/gasm/debug_ptrace.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/gasm/debug_ptrace.go b/cmd/gasm/debug_ptrace.go index 4316d56..28f3c68 100644 --- a/cmd/gasm/debug_ptrace.go +++ b/cmd/gasm/debug_ptrace.go @@ -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{}