fix(debug): handle mapping edges, stray traps and dying debuggees

Assisted-by: GLM 5.3
This commit is contained in:
2026-10-02 00:40:54 +02:00
parent dd1782c538
commit f57377abb9
19 changed files with 726 additions and 97 deletions
+18 -9
View File
@@ -14,17 +14,26 @@ import (
)
// Disassemble decodes the instruction at the given address in the debuggee's
// memory and returns its text representation and length in bytes.
// memory and returns its text representation and length in bytes. An amd64
// instruction is up to 15 bytes long, but the read must not reach past the
// end of the mapping: when the full 15-byte window crosses into unmapped
// memory the window shrinks, because an instruction at the mapping's end is
// by construction no longer than the readable bytes that hold it.
func (s *Session) Disassemble(addr uint64) (string, int, error) {
mem, err := s.ReadMemory(addr, 15)
if err != nil {
return "", 0, err
var lastErr error
for _, n := range []int{15, 8, 4, 2, 1} {
mem, err := s.ReadMemory(addr, n)
if err != nil {
lastErr = err
continue
}
ins, derr := disasm.Decode(arch.AMD64, mem, addr)
if derr != nil {
return "", 0, derr
}
return ins.Text, ins.Len, nil
}
ins, err := disasm.Decode(arch.AMD64, mem, addr)
if err != nil {
return "", 0, err
}
return ins.Text, ins.Len, nil
return "", 0, lastErr
}
// DisassembleN decodes up to n instructions starting at addr and returns