mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 12:59:01 +08:00
Small refactor, only arithmetic once
This commit is contained in:
@ -217,12 +217,14 @@ func (dbp *DebuggedProcess) Next() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pc-- // account for breakpoint instruction
|
||||||
|
|
||||||
fde, err := dbp.FrameEntries.FDEForPC(pc)
|
fde, err := dbp.FrameEntries.FDEForPC(pc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
loc := dbp.DebugLine.NextLocAfterPC(pc - 1)
|
loc := dbp.DebugLine.NextLocAfterPC(pc)
|
||||||
if !fde.AddressRange.Cover(loc.Address) {
|
if !fde.AddressRange.Cover(loc.Address) {
|
||||||
// Next line is outside current frame, use return addr.
|
// Next line is outside current frame, use return addr.
|
||||||
addr := dbp.ReturnAddressFromOffset(fde.ReturnAddressOffset(pc))
|
addr := dbp.ReturnAddressFromOffset(fde.ReturnAddressOffset(pc))
|
||||||
@ -233,7 +235,7 @@ func (dbp *DebuggedProcess) Next() error {
|
|||||||
if loc.Delta < 0 {
|
if loc.Delta < 0 {
|
||||||
// We are likely in a loop, set breakpoints at entry and exit.
|
// We are likely in a loop, set breakpoints at entry and exit.
|
||||||
entry := dbp.DebugLine.LoopEntryLocation(loc.Line)
|
entry := dbp.DebugLine.LoopEntryLocation(loc.Line)
|
||||||
exit := dbp.DebugLine.LoopExitLocation(pc - 1)
|
exit := dbp.DebugLine.LoopExitLocation(pc)
|
||||||
addrs = append(addrs, entry.Address, exit.Address)
|
addrs = append(addrs, entry.Address, exit.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user