diff --git a/main.go b/main.go index 47922d9c..9cc7282e 100644 --- a/main.go +++ b/main.go @@ -63,8 +63,24 @@ func printStderrAndDie(args ...interface{}) { } func registerProcessCommands(cmds *command.Commands, proc *proctl.DebuggedProcess) { - cmds.Register("step", command.CommandFunc(proc.Step)) cmds.Register("continue", command.CommandFunc(proc.Continue)) + cmds.Register("step", func(args ...string) error { + err := proc.Step() + if err != nil { + return err + } + + regs, err := proc.Registers() + if err != nil { + return err + } + + f, l, _ := proc.GoSymTable.PCToLine(regs.PC()) + fmt.Printf("Stopped at: %s:%d\n", f, l) + + return nil + }) + cmds.Register("break", func(args ...string) error { fname := args[0] bp, err := proc.Break(fname) diff --git a/proctl/proctl_linux_amd64.go b/proctl/proctl_linux_amd64.go index d1bbf871..7654731e 100644 --- a/proctl/proctl_linux_amd64.go +++ b/proctl/proctl_linux_amd64.go @@ -135,7 +135,11 @@ func (dbp *DebuggedProcess) Step() error { bp, ok := dbp.PCtoBP(regs.PC()) if ok { - dbp.restoreInstruction(regs.PC(), bp.OriginalData) + err = dbp.restoreInstruction(regs.PC(), bp.OriginalData) + if err != nil { + return err + } + } err = dbp.handleResult(syscall.PtraceSingleStep(dbp.Pid)) @@ -143,11 +147,9 @@ func (dbp *DebuggedProcess) Step() error { return fmt.Errorf("step failed: ", err.Error()) } - f, l, fn := dbp.GoSymTable.PCToLine(regs.PC()) - fmt.Printf("Stopped at: %s %s:%d\n", fn.Name, f, l) - + // Restore breakpoint if ok { - _, err = dbp.Break(bp.FunctionName) + _, err := dbp.Break(bp.FunctionName) if err != nil { return err }