feat(debug): support register-register conditional breakpoints

Assisted-by: MiMo V2.5 Pro
This commit is contained in:
2026-08-21 01:20:25 +02:00
parent 746cef8100
commit 94b98468bb
2 changed files with 40 additions and 17 deletions
+32 -11
View File
@@ -17,12 +17,17 @@ type Breakpoint struct {
hits int
}
// Condition is a simple register-comparison condition evaluated when a
// breakpoint is hit. Format: <reg> <op> <value>.
// Condition is a register-comparison condition evaluated when a breakpoint
// is hit. Supports three forms:
// - register vs constant: <reg> <op> <value>
// - register vs register: <reg> <op> <reg2>
// - register vs memory: <reg> <op> *<addr>
type Condition struct {
Reg string // register name (rax, rbx, rip, rsp, ...)
Op string // comparison operator: ==, !=, <, >, <=, >=
Value uint64
Reg string // register name (rax, rbx, rip, rsp, ...)
Op string // comparison operator: ==, !=, <, >, <=, >=
Value uint64 // constant value (when Reg2 == "" and MemAddr == 0)
Reg2 string // second register name (for register-register comparison)
MemAddr uint64 // memory address (for register-memory comparison, prefixed with *)
}
// Eval checks the condition against the current registers.
@@ -31,19 +36,35 @@ func (c *Condition) Eval(regs *Regs) bool {
if !ok {
return true // unknown register — don't block
}
var expected uint64
switch {
case c.Reg2 != "":
// Register-register comparison.
v, ok := regs.RegValue(c.Reg2)
if !ok {
return true
}
expected = v
case c.MemAddr != 0:
// Register-memory comparison — requires a Session, not available here.
// Fall back to treating as constant (the caller should resolve).
expected = c.Value
default:
expected = c.Value
}
switch c.Op {
case "==", "=":
return actual == c.Value
return actual == expected
case "!=":
return actual != c.Value
return actual != expected
case "<":
return actual < c.Value
return actual < expected
case ">":
return actual > c.Value
return actual > expected
case "<=":
return actual <= c.Value
return actual <= expected
case ">=":
return actual >= c.Value
return actual >= expected
default:
return true
}