-
Notifications
You must be signed in to change notification settings - Fork 0
/
hwbreak_amd64.go
39 lines (35 loc) · 1.01 KB
/
hwbreak_amd64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package native
import (
"github.com/undoio/delve/pkg/proc"
"github.com/undoio/delve/pkg/proc/amd64util"
)
func (t *nativeThread) writeHardwareBreakpoint(addr uint64, wtype proc.WatchType, idx uint8) error {
return t.withDebugRegisters(func(drs *amd64util.DebugRegisters) error {
return drs.SetBreakpoint(idx, addr, wtype.Read(), wtype.Write(), wtype.Size())
})
}
func (t *nativeThread) clearHardwareBreakpoint(addr uint64, wtype proc.WatchType, idx uint8) error {
return t.withDebugRegisters(func(drs *amd64util.DebugRegisters) error {
drs.ClearBreakpoint(idx)
return nil
})
}
func (t *nativeThread) findHardwareBreakpoint() (*proc.Breakpoint, error) {
var retbp *proc.Breakpoint
err := t.withDebugRegisters(func(drs *amd64util.DebugRegisters) error {
ok, idx := drs.GetActiveBreakpoint()
if ok {
for _, bp := range t.dbp.Breakpoints().M {
if bp.WatchType != 0 && bp.HWBreakIndex == idx {
retbp = bp
break
}
}
}
return nil
})
if err != nil {
return nil, err
}
return retbp, nil
}