提交 fa62905a 编写于 作者: D Derek Parker

Remove slight duplication

上级 bcc4943a
......@@ -77,14 +77,7 @@ func (dbp *DebuggedProcess) setBreakpoint(tid int, addr uint64) (*BreakPoint, er
if err != nil {
return nil, fmt.Errorf("could not set hardware breakpoint")
}
dbp.breakpointIDCounter++
dbp.HWBreakPoints[i] = &BreakPoint{
FunctionName: fn.Name,
File: f,
Line: l,
Addr: addr,
ID: dbp.breakpointIDCounter,
}
dbp.HWBreakPoints[i] = dbp.newBreakpoint(fn.Name, f, l, addr, nil)
return dbp.HWBreakPoints[i], nil
}
}
......@@ -98,15 +91,7 @@ func (dbp *DebuggedProcess) setBreakpoint(tid int, addr uint64) (*BreakPoint, er
if err != nil {
return nil, err
}
dbp.breakpointIDCounter++
dbp.BreakPoints[addr] = &BreakPoint{
FunctionName: fn.Name,
File: f,
Line: l,
Addr: addr,
OriginalData: originalData,
ID: dbp.breakpointIDCounter,
}
dbp.BreakPoints[addr] = dbp.newBreakpoint(fn.Name, f, l, addr, originalData)
return dbp.BreakPoints[addr], nil
}
......@@ -132,6 +117,18 @@ func (dbp *DebuggedProcess) clearBreakpoint(tid int, addr uint64) (*BreakPoint,
return nil, fmt.Errorf("No breakpoint currently set for %#v", addr)
}
func (dbp *DebuggedProcess) newBreakpoint(fn, f string, l int, addr uint64, data []byte) *BreakPoint {
dbp.breakpointIDCounter++
return &BreakPoint{
FunctionName: fn,
File: f,
Line: l,
Addr: addr,
OriginalData: data,
ID: dbp.breakpointIDCounter,
}
}
// Sets a hardware breakpoint by setting the contents of the
// debug register `reg` with the address of the instruction
// that we want to break at. There are only 4 debug registers
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册