mirror of
https://github.com/go-delve/delve.git
synced 2025-11-03 13:57:33 +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 {
|
if _, err := readMemory(thread, uintptr(addr), originalData); err != nil {
|
||||||
return nil, err
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
dbp.Breakpoints[addr] = &Breakpoint{
|
dbp.Breakpoints[addr] = &Breakpoint{
|
||||||
@ -139,6 +139,11 @@ func (dbp *Process) setBreakpoint(tid int, addr uint64, temp bool) (*Breakpoint,
|
|||||||
return dbp.Breakpoints[addr], nil
|
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.
|
// Error thrown when trying to clear a breakpoint that does not exist.
|
||||||
type NoBreakpointError struct {
|
type NoBreakpointError struct {
|
||||||
addr uint64
|
addr uint64
|
||||||
|
|||||||
@ -78,19 +78,18 @@ func (thread *Thread) Step() (err error) {
|
|||||||
bp, ok := thread.dbp.Breakpoints[pc]
|
bp, ok := thread.dbp.Breakpoints[pc]
|
||||||
if ok {
|
if ok {
|
||||||
// Clear the breakpoint so that we can continue execution.
|
// Clear the breakpoint so that we can continue execution.
|
||||||
_, err = thread.dbp.ClearBreakpoint(bp.Addr)
|
_, err = bp.Clear(thread)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore breakpoint now that we have passed it.
|
// Restore breakpoint now that we have passed it.
|
||||||
defer func() {
|
defer func() {
|
||||||
var nbp *Breakpoint
|
if bp.hardware {
|
||||||
nbp, err = thread.dbp.setBreakpoint(thread.Id, bp.Addr, bp.Temp)
|
err = thread.dbp.setHardwareBreakpoint(bp.reg, thread.Id, bp.Addr)
|
||||||
if err != nil {
|
} else {
|
||||||
return
|
err = thread.dbp.writeSoftwareBreakpoint(thread, bp.Addr)
|
||||||
}
|
}
|
||||||
nbp.Temp = bp.Temp
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user