提交 21dca7ef 编写于 作者: D Derek Parker

Use seperate ID counter for temp breakpoints

上级 19a98fb4
......@@ -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,
}
}
......
......@@ -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
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册