From 21dca7efeb01ab44415fdc56890369f5362eb116 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Wed, 29 Apr 2015 08:17:35 -0500 Subject: [PATCH] Use seperate ID counter for temp breakpoints --- proctl/breakpoints.go | 11 +++++++++-- proctl/proctl.go | 37 +++++++++++++++++++------------------ proctl/threads.go | 7 ++++++- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/proctl/breakpoints.go b/proctl/breakpoints.go index fe8287cd..b3ede353 100644 --- a/proctl/breakpoints.go +++ b/proctl/breakpoints.go @@ -79,14 +79,21 @@ func (dbp *DebuggedProcess) BreakpointExists(addr uint64) bool { } func (dbp *DebuggedProcess) newBreakpoint(fn, f string, l int, addr uint64, data []byte, temp bool) *BreakPoint { - dbp.breakpointIDCounter++ + var id int + if temp { + dbp.tempBreakpointIDCounter++ + id = dbp.tempBreakpointIDCounter + } else { + dbp.breakpointIDCounter++ + id = dbp.breakpointIDCounter + } return &BreakPoint{ FunctionName: fn, File: f, Line: l, Addr: addr, OriginalData: data, - ID: dbp.breakpointIDCounter, + ID: id, Temp: temp, } } diff --git a/proctl/proctl.go b/proctl/proctl.go index 72c32799..656f180e 100644 --- a/proctl/proctl.go +++ b/proctl/proctl.go @@ -22,24 +22,25 @@ import ( // Struct representing a debugged process. Holds onto pid, register values, // process struct and process state. type DebuggedProcess struct { - Pid int - Process *os.Process - HWBreakPoints [4]*BreakPoint - BreakPoints map[uint64]*BreakPoint - Threads map[int]*ThreadContext - CurrentThread *ThreadContext - dwarf *dwarf.Data - goSymTable *gosym.Table - frameEntries frame.FrameDescriptionEntries - lineInfo *line.DebugLineInfo - firstStart bool - singleStepping bool - os *OSProcessDetails - ast *source.Searcher - breakpointIDCounter int - running bool - halt bool - exited bool + Pid int + Process *os.Process + HWBreakPoints [4]*BreakPoint + BreakPoints map[uint64]*BreakPoint + Threads map[int]*ThreadContext + CurrentThread *ThreadContext + dwarf *dwarf.Data + goSymTable *gosym.Table + frameEntries frame.FrameDescriptionEntries + lineInfo *line.DebugLineInfo + firstStart bool + singleStepping bool + os *OSProcessDetails + ast *source.Searcher + breakpointIDCounter int + tempBreakpointIDCounter int + running bool + halt bool + exited bool } // A ManualStopError happens when the user triggers a diff --git a/proctl/threads.go b/proctl/threads.go index 1ef2b654..69a4e269 100644 --- a/proctl/threads.go +++ b/proctl/threads.go @@ -84,7 +84,7 @@ func (thread *ThreadContext) CallFn(name string, fn func() error) error { } // Set breakpoint at the end of the function (before it returns). - bp, err := thread.Break(f.End - 2) + bp, err := thread.TempBreak(f.End - 2) if err != nil { return err } @@ -113,6 +113,11 @@ func (thread *ThreadContext) Break(addr uint64) (*BreakPoint, error) { return thread.Process.setBreakpoint(thread.Id, addr, false) } +// Set breakpoint using this thread. +func (thread *ThreadContext) TempBreak(addr uint64) (*BreakPoint, error) { + return thread.Process.setBreakpoint(thread.Id, addr, true) +} + // Clear breakpoint using this thread. func (thread *ThreadContext) Clear(addr uint64) (*BreakPoint, error) { return thread.Process.clearBreakpoint(thread.Id, addr) -- GitLab