File: hwbreak_amd64.go

package info (click to toggle)
delve 1.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,136 kB
  • sloc: ansic: 111,947; sh: 194; asm: 147; makefile: 43; python: 23
file content (39 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download | duplicates (3)
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/go-delve/delve/pkg/proc"
	"github.com/go-delve/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
}