From e8ffa31bd73a85eb8fdc01583801afbc2094412c Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Fri, 11 Jul 2014 15:32:26 -0500 Subject: [PATCH] Small refactor, only arithmetic once --- proctl/proctl_linux_amd64.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proctl/proctl_linux_amd64.go b/proctl/proctl_linux_amd64.go index 52b5773c..b2532e9c 100644 --- a/proctl/proctl_linux_amd64.go +++ b/proctl/proctl_linux_amd64.go @@ -217,12 +217,14 @@ func (dbp *DebuggedProcess) Next() error { return err } + pc-- // account for breakpoint instruction + fde, err := dbp.FrameEntries.FDEForPC(pc) if err != nil { return err } - loc := dbp.DebugLine.NextLocAfterPC(pc - 1) + loc := dbp.DebugLine.NextLocAfterPC(pc) if !fde.AddressRange.Cover(loc.Address) { // Next line is outside current frame, use return addr. addr := dbp.ReturnAddressFromOffset(fde.ReturnAddressOffset(pc)) @@ -233,7 +235,7 @@ func (dbp *DebuggedProcess) Next() error { if loc.Delta < 0 { // We are likely in a loop, set breakpoints at entry and exit. entry := dbp.DebugLine.LoopEntryLocation(loc.Line) - exit := dbp.DebugLine.LoopExitLocation(pc - 1) + exit := dbp.DebugLine.LoopExitLocation(pc) addrs = append(addrs, entry.Address, exit.Address) }