Refactor: Rename breakpoint methods

s/Break/SetBreakpoint/
s/Clear/ClearBreakpoint/
s/BreakByLocation/SetBreakpointByLocation/
This commit is contained in:
Derek Parker 2015-06-20 18:01:06 -05:00
parent 102d4c89ae
commit 6e538119d2
5 changed files with 45 additions and 45 deletions

@ -100,7 +100,7 @@ func (dbp *Process) Detach(kill bool) (err error) {
// Clean up any breakpoints we've set.
for _, bp := range dbp.Breakpoints {
if bp != nil {
dbp.Clear(bp.Addr)
dbp.ClearBreakpoint(bp.Addr)
}
}
dbp.execPtraceFunc(func() {
@ -217,36 +217,36 @@ func (dbp *Process) RequestManualStop() error {
// hardware supports it, and there are free debug registers, Delve
// will set a hardware breakpoint. Otherwise we fall back to software
// breakpoints, which are a bit more work for us.
func (dbp *Process) Break(addr uint64) (*Breakpoint, error) {
func (dbp *Process) SetBreakpoint(addr uint64) (*Breakpoint, error) {
return dbp.setBreakpoint(dbp.CurrentThread.Id, addr, false)
}
// Sets a temp breakpoint, for the 'next' command.
func (dbp *Process) TempBreak(addr uint64) (*Breakpoint, error) {
func (dbp *Process) SetTempBreakpoint(addr uint64) (*Breakpoint, error) {
return dbp.setBreakpoint(dbp.CurrentThread.Id, addr, true)
}
// Sets a breakpoint by location string (function, file+line, address)
func (dbp *Process) BreakByLocation(loc string) (*Breakpoint, error) {
func (dbp *Process) SetBreakpointByLocation(loc string) (*Breakpoint, error) {
addr, err := dbp.FindLocation(loc)
if err != nil {
return nil, err
}
return dbp.Break(addr)
return dbp.SetBreakpoint(addr)
}
// Clears a breakpoint in the current thread.
func (dbp *Process) Clear(addr uint64) (*Breakpoint, error) {
func (dbp *Process) ClearBreakpoint(addr uint64) (*Breakpoint, error) {
return dbp.clearBreakpoint(dbp.CurrentThread.Id, addr)
}
// Clears a breakpoint by location (function, file+line, address, breakpoint id)
func (dbp *Process) ClearByLocation(loc string) (*Breakpoint, error) {
func (dbp *Process) ClearBreakpointByLocation(loc string) (*Breakpoint, error) {
addr, err := dbp.FindLocation(loc)
if err != nil {
return nil, err
}
return dbp.Clear(addr)
return dbp.ClearBreakpoint(addr)
}
// Returns the status of the current main thread context.
@ -274,7 +274,7 @@ func (dbp *Process) next() error {
}
if g.DeferPC != 0 {
_, err = dbp.TempBreak(g.DeferPC)
_, err = dbp.SetTempBreakpoint(g.DeferPC)
if err != nil {
return err
}
@ -340,7 +340,7 @@ func (dbp *Process) setChanRecvBreakpoints() (int, error) {
}
return 0, err
}
if _, err = dbp.TempBreak(ret); err != nil {
if _, err = dbp.SetTempBreakpoint(ret); err != nil {
return 0, err
}
count++
@ -590,7 +590,7 @@ func (dbp *Process) clearTempBreakpoints() error {
if !bp.Temp {
continue
}
if _, err := dbp.Clear(bp.Addr); err != nil {
if _, err := dbp.ClearBreakpoint(bp.Addr); err != nil {
return err
}
}

@ -124,8 +124,8 @@ func TestStep(t *testing.T) {
helloworldfunc := p.goSymTable.LookupFunc("main.helloworld")
helloworldaddr := helloworldfunc.Entry
_, err := p.Break(helloworldaddr)
assertNoError(err, t, "Break()")
_, err := p.SetBreakpoint(helloworldaddr)
assertNoError(err, t, "SetBreakpoint()")
assertNoError(p.Continue(), t, "Continue()")
regs := getRegisters(p, t)
@ -146,8 +146,8 @@ func TestBreakpoint(t *testing.T) {
helloworldfunc := p.goSymTable.LookupFunc("main.helloworld")
helloworldaddr := helloworldfunc.Entry
bp, err := p.Break(helloworldaddr)
assertNoError(err, t, "Break()")
bp, err := p.SetBreakpoint(helloworldaddr)
assertNoError(err, t, "SetBreakpoint()")
assertNoError(p.Continue(), t, "Continue()")
pc, err := p.PC()
@ -169,7 +169,7 @@ func TestBreakpointInSeperateGoRoutine(t *testing.T) {
t.Fatal("No fn exists")
}
_, err := p.Break(fn.Entry)
_, err := p.SetBreakpoint(fn.Entry)
if err != nil {
t.Fatal(err)
}
@ -193,21 +193,21 @@ func TestBreakpointInSeperateGoRoutine(t *testing.T) {
func TestBreakpointWithNonExistantFunction(t *testing.T) {
withTestProcess("testprog", t, func(p *Process, fixture protest.Fixture) {
_, err := p.Break(0)
_, err := p.SetBreakpoint(0)
if err == nil {
t.Fatal("Should not be able to break at non existant function")
}
})
}
func TestClearBreakpoint(t *testing.T) {
func TestClearBreakpointBreakpoint(t *testing.T) {
withTestProcess("testprog", t, func(p *Process, fixture protest.Fixture) {
fn := p.goSymTable.LookupFunc("main.sleepytime")
bp, err := p.Break(fn.Entry)
assertNoError(err, t, "Break()")
bp, err := p.SetBreakpoint(fn.Entry)
assertNoError(err, t, "SetBreakpoint()")
bp, err = p.Clear(fn.Entry)
assertNoError(err, t, "Clear()")
bp, err = p.ClearBreakpoint(fn.Entry)
assertNoError(err, t, "ClearBreakpoint()")
data, err := dataAtAddr(p.CurrentThread, bp.Addr)
if err != nil {
@ -231,10 +231,10 @@ type nextTest struct {
func testnext(program string, testcases []nextTest, initialLocation string, t *testing.T) {
withTestProcess(program, t, func(p *Process, fixture protest.Fixture) {
bp, err := p.BreakByLocation(initialLocation)
assertNoError(err, t, "Break()")
bp, err := p.SetBreakpointByLocation(initialLocation)
assertNoError(err, t, "SetBreakpoint()")
assertNoError(p.Continue(), t, "Continue()")
p.Clear(bp.Addr)
p.ClearBreakpoint(bp.Addr)
p.CurrentThread.SetPC(bp.Addr)
f, ln := currentLineNumber(p, t)
@ -331,7 +331,7 @@ func TestFindReturnAddress(t *testing.T) {
t.Fatal(err)
}
_, err = p.Break(start)
_, err = p.SetBreakpoint(start)
if err != nil {
t.Fatal(err)
}
@ -380,7 +380,7 @@ func TestSwitchThread(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = p.Break(pc)
_, err = p.SetBreakpoint(pc)
if err != nil {
t.Fatal(err)
}
@ -431,7 +431,7 @@ func TestStacktrace(t *testing.T) {
[]loc{{8, "main.func1"}, {12, "main.func2"}, {17, "main.main"}},
}
withTestProcess("stacktraceprog", t, func(p *Process, fixture protest.Fixture) {
bp, err := p.BreakByLocation("main.stacktraceme")
bp, err := p.SetBreakpointByLocation("main.stacktraceme")
assertNoError(err, t, "BreakByLocation()")
for i := range stacks {
@ -450,7 +450,7 @@ func TestStacktrace(t *testing.T) {
}
}
p.Clear(bp.Addr)
p.ClearBreakpoint(bp.Addr)
p.Continue()
})
}
@ -472,7 +472,7 @@ func TestStacktraceGoroutine(t *testing.T) {
agoroutineStack := []loc{{-1, "runtime.goparkunlock"}, {-1, "runtime.chansend"}, {-1, "runtime.chansend1"}, {8, "main.agoroutine"}}
withTestProcess("goroutinestackprog", t, func(p *Process, fixture protest.Fixture) {
bp, err := p.BreakByLocation("main.stacktraceme")
bp, err := p.SetBreakpointByLocation("main.stacktraceme")
assertNoError(err, t, "BreakByLocation()")
assertNoError(p.Continue(), t, "Continue()")
@ -515,7 +515,7 @@ func TestStacktraceGoroutine(t *testing.T) {
t.Fatalf("Goroutine stacks not found (%d)", agoroutineCount)
}
p.Clear(bp.Addr)
p.ClearBreakpoint(bp.Addr)
p.Continue()
})
}

@ -74,7 +74,7 @@ func (thread *Thread) Step() (err error) {
bp, ok := thread.dbp.Breakpoints[pc]
if ok {
// Clear the breakpoint so that we can continue execution.
_, err = thread.dbp.Clear(bp.Addr)
_, err = thread.dbp.ClearBreakpoint(bp.Addr)
if err != nil {
return err
}
@ -82,7 +82,7 @@ func (thread *Thread) Step() (err error) {
// Restore breakpoint now that we have passed it.
defer func() {
var nbp *Breakpoint
nbp, err = thread.dbp.Break(bp.Addr)
nbp, err = thread.dbp.SetBreakpoint(bp.Addr)
nbp.Temp = bp.Temp
}()
}
@ -218,7 +218,7 @@ func (thread *Thread) setNextTempBreakpoints(curpc uint64, pcs []uint64) error {
if pcs[i] == curpc || pcs[i] == curpc-1 {
continue
}
if _, err := thread.dbp.TempBreak(pcs[i]); err != nil {
if _, err := thread.dbp.SetTempBreakpoint(pcs[i]); err != nil {
if _, ok := err.(BreakpointExistsError); !ok {
return err
}

@ -70,8 +70,8 @@ func TestVariableEvaluation(t *testing.T) {
withTestProcess("testvariables", t, func(p *Process, fixture protest.Fixture) {
pc, _, _ := p.goSymTable.LineToPC(fixture.Source, 57)
_, err := p.Break(pc)
assertNoError(err, t, "Break() returned an error")
_, err := p.SetBreakpoint(pc)
assertNoError(err, t, "SetBreakpoint() returned an error")
err = p.Continue()
assertNoError(err, t, "Continue() returned an error")
@ -94,12 +94,12 @@ func TestVariableFunctionScoping(t *testing.T) {
withTestProcess("testvariables", t, func(p *Process, fixture protest.Fixture) {
pc, _, _ := p.goSymTable.LineToPC(fixture.Source, 57)
_, err := p.Break(pc)
assertNoError(err, t, "Break() returned an error")
_, err := p.SetBreakpoint(pc)
assertNoError(err, t, "SetBreakpoint() returned an error")
err = p.Continue()
assertNoError(err, t, "Continue() returned an error")
p.Clear(pc)
p.ClearBreakpoint(pc)
_, err = p.EvalVariable("a1")
assertNoError(err, t, "Unable to find variable a1")
@ -110,8 +110,8 @@ func TestVariableFunctionScoping(t *testing.T) {
// Move scopes, a1 exists here by a2 does not
pc, _, _ = p.goSymTable.LineToPC(fixture.Source, 23)
_, err = p.Break(pc)
assertNoError(err, t, "Break() returned an error")
_, err = p.SetBreakpoint(pc)
assertNoError(err, t, "SetBreakpoint() returned an error")
err = p.Continue()
assertNoError(err, t, "Continue() returned an error")
@ -186,8 +186,8 @@ func TestLocalVariables(t *testing.T) {
withTestProcess("testvariables", t, func(p *Process, fixture protest.Fixture) {
pc, _, _ := p.goSymTable.LineToPC(fixture.Source, 57)
_, err := p.Break(pc)
assertNoError(err, t, "Break() returned an error")
_, err := p.SetBreakpoint(pc)
assertNoError(err, t, "SetBreakpoint() returned an error")
err = p.Continue()
assertNoError(err, t, "Continue() returned an error")

@ -101,7 +101,7 @@ func (d *Debugger) CreateBreakpoint(requestedBp *api.Breakpoint) (*api.Breakpoin
return nil, fmt.Errorf("no file or function name specified")
}
bp, err := d.process.BreakByLocation(loc)
bp, err := d.process.SetBreakpointByLocation(loc)
if err != nil {
return nil, err
}
@ -112,7 +112,7 @@ func (d *Debugger) CreateBreakpoint(requestedBp *api.Breakpoint) (*api.Breakpoin
func (d *Debugger) ClearBreakpoint(requestedBp *api.Breakpoint) (*api.Breakpoint, error) {
var clearedBp *api.Breakpoint
bp, err := d.process.Clear(requestedBp.Addr)
bp, err := d.process.ClearBreakpoint(requestedBp.Addr)
if err != nil {
return nil, fmt.Errorf("Can't clear breakpoint @%x: %s", requestedBp.Addr, err)
}