From 50951ba257023f01c452ed2aab278c4ef0f9fe09 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Fri, 5 Sep 2014 14:52:45 -0500 Subject: [PATCH] Do not export nextPotentialLocations --- proctl/proctl_linux_amd64.go | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/proctl/proctl_linux_amd64.go b/proctl/proctl_linux_amd64.go index f3ec7971..7c224908 100644 --- a/proctl/proctl_linux_amd64.go +++ b/proctl/proctl_linux_amd64.go @@ -271,33 +271,6 @@ func (dbp *DebuggedProcess) Step() (err error) { return nil } -func (dbp *DebuggedProcess) NextPotentialLocations(pc uint64) ([]uint64, error) { - var ( - addrs = make([]uint64, 0, 3) - loc = dbp.DebugLine.NextLocAfterPC(pc) - ) - addrs = append(addrs, loc.Address) - - fde, err := dbp.FrameEntries.FDEForPC(pc) - if err != nil { - return nil, err - } - - if !fde.AddressRange.Cover(loc.Address) { // Next line is outside current frame, use return addr. - addr := dbp.ReturnAddressFromOffset(fde.ReturnAddressOffset(pc)) - loc = dbp.DebugLine.LocationInfoForPC(addr) - addrs = append(addrs, loc.Address) - } - - 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(loc.Address) - addrs = append(addrs, entry.Address, exit.Address) - } - - return addrs, nil -} - // Step over function calls. func (dbp *DebuggedProcess) Next() error { pc, err := dbp.CurrentPC() @@ -307,7 +280,7 @@ func (dbp *DebuggedProcess) Next() error { pc-- // account for breakpoint instruction - addrs, err := dbp.NextPotentialLocations(pc) + addrs, err := dbp.nextPotentialLocations(pc) if err != nil { return err } @@ -361,6 +334,33 @@ func (dbp *DebuggedProcess) CurrentPC() (uint64, error) { return regs.Rip, nil } +func (dbp *DebuggedProcess) nextPotentialLocations(pc uint64) ([]uint64, error) { + var ( + addrs = make([]uint64, 0, 3) + loc = dbp.DebugLine.NextLocAfterPC(pc) + ) + addrs = append(addrs, loc.Address) + + fde, err := dbp.FrameEntries.FDEForPC(pc) + if err != nil { + return nil, err + } + + if !fde.AddressRange.Cover(loc.Address) { // Next line is outside current frame, use return addr. + addr := dbp.ReturnAddressFromOffset(fde.ReturnAddressOffset(pc)) + loc = dbp.DebugLine.LocationInfoForPC(addr) + addrs = append(addrs, loc.Address) + } + + 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(loc.Address) + addrs = append(addrs, entry.Address, exit.Address) + } + + return addrs, nil +} + // Extracts the value from the instructions given in the DW_AT_location entry. // We execute the stack program described in the DW_OP_* instruction stream, and // then grab the value from the other processes memory.