gitlab.com/Raven-IO/raven-delve@v1.22.4/pkg/proc/native/hwbreak_amd64.go (about)

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