mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 21:40:22 +08:00
Only clear and reset breakpoint for current thread
This commit is contained in:
@ -123,7 +123,7 @@ func (dbp *Process) setBreakpoint(tid int, addr uint64, temp bool) (*Breakpoint,
|
||||
if _, err := readMemory(thread, uintptr(addr), originalData); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := writeMemory(thread, uintptr(addr), dbp.arch.BreakpointInstruction()); err != nil {
|
||||
if err := dbp.writeSoftwareBreakpoint(thread, addr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbp.Breakpoints[addr] = &Breakpoint{
|
||||
@ -139,6 +139,11 @@ func (dbp *Process) setBreakpoint(tid int, addr uint64, temp bool) (*Breakpoint,
|
||||
return dbp.Breakpoints[addr], nil
|
||||
}
|
||||
|
||||
func (dbp *Process) writeSoftwareBreakpoint(thread *Thread, addr uint64) error {
|
||||
_, err := writeMemory(thread, uintptr(addr), dbp.arch.BreakpointInstruction())
|
||||
return err
|
||||
}
|
||||
|
||||
// Error thrown when trying to clear a breakpoint that does not exist.
|
||||
type NoBreakpointError struct {
|
||||
addr uint64
|
||||
|
||||
@ -78,19 +78,18 @@ func (thread *Thread) Step() (err error) {
|
||||
bp, ok := thread.dbp.Breakpoints[pc]
|
||||
if ok {
|
||||
// Clear the breakpoint so that we can continue execution.
|
||||
_, err = thread.dbp.ClearBreakpoint(bp.Addr)
|
||||
_, err = bp.Clear(thread)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Restore breakpoint now that we have passed it.
|
||||
defer func() {
|
||||
var nbp *Breakpoint
|
||||
nbp, err = thread.dbp.setBreakpoint(thread.Id, bp.Addr, bp.Temp)
|
||||
if err != nil {
|
||||
return
|
||||
if bp.hardware {
|
||||
err = thread.dbp.setHardwareBreakpoint(bp.reg, thread.Id, bp.Addr)
|
||||
} else {
|
||||
err = thread.dbp.writeSoftwareBreakpoint(thread, bp.Addr)
|
||||
}
|
||||
nbp.Temp = bp.Temp
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user