fix(debug): hardware watchpoints, signal stops and breakpoint restore
Assisted-by: GLM 5.3
This commit is contained in:
+10
-2
@@ -6,6 +6,7 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -61,8 +62,15 @@ func (s *Session) StopInfo() (StopReason, uint64) {
|
||||
case trapBRKPT:
|
||||
return StopBreakpoint, 0
|
||||
case trapHWBRKPT:
|
||||
addr := *(*uint64)(unsafe.Add(unsafe.Pointer(&info), 16))
|
||||
return StopWatchpoint, addr
|
||||
// si_addr sits at struct offset 16 (12 bytes of signo/errno/code
|
||||
// plus 4 bytes of union alignment). The siginfo buffer is only
|
||||
// 4-byte aligned, so the address is read byte-wise to keep the
|
||||
// load aligned on riscv64 and loong64. What si_addr names is
|
||||
// architecture-specific (the data address on arm64, the
|
||||
// instruction pointer on x86), so the per-architecture
|
||||
// archWatchpointAddr resolves it to the watched address.
|
||||
addr := binary.LittleEndian.Uint64(info._pad[4:12])
|
||||
return StopWatchpoint, archWatchpointAddr(s, addr)
|
||||
default:
|
||||
return StopSingleStep, 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user