Handle missing line info in printcontext

This commit is contained in:
Michael Gehring
2014-11-13 12:04:47 +01:00
committed by Derek Parker
parent 03b5e30bfb
commit 2ce51ab92f

View File

@ -239,8 +239,9 @@ func printcontext(p *proctl.DebuggedProcess) error {
return err
}
f, l, _ := p.GoSymTable.PCToLine(regs.PC())
f, l, fn := p.GoSymTable.PCToLine(regs.PC())
if fn != nil {
fmt.Printf("Stopped at: %s:%d\n", f, l)
file, err := os.Open(f)
if err != nil {
@ -274,6 +275,10 @@ func printcontext(p *proctl.DebuggedProcess) error {
context = append(context, fmt.Sprintf("\033[34m%d\033[0m: %s", i, line))
}
} else {
fmt.Printf("Stopped at: 0x%x\n", regs.PC())
context = append(context, "\033[34m=>\033[0m no source available")
}
fmt.Println(strings.Join(context, ""))