Fix: Use return address directly when at end of func

This commit is contained in:
Derek Parker 2015-05-11 08:17:19 -05:00
parent 72eebe5c4b
commit fb55ee9728
2 changed files with 15 additions and 3 deletions

@ -5,6 +5,7 @@ import (
"path/filepath"
"github.com/derekparker/delve/dwarf/frame"
"github.com/derekparker/delve/source"
sys "golang.org/x/sys/unix"
)
@ -181,7 +182,9 @@ func (ge GoroutineExitingError) Error() string {
func (thread *ThreadContext) next(curpc uint64, fde *frame.FrameDescriptionEntry, file string, line int) error {
lines, err := thread.Process.ast.NextLines(file, line)
if err != nil {
return err
if _, ok := err.(source.NoNodeError); !ok {
return err
}
}
ret, err := thread.ReturnAddress()

@ -16,6 +16,15 @@ func New() *Searcher {
return &Searcher{fileset: token.NewFileSet(), visited: make(map[string]*ast.File)}
}
type NoNodeError struct {
f string
l int
}
func (n NoNodeError) Error() string {
return fmt.Sprintf("could not find node at %s:%d", n.f, n.l)
}
// Returns the first node at the given file:line.
func (s *Searcher) FirstNodeAt(fname string, line int) (ast.Node, error) {
var node ast.Node
@ -35,7 +44,7 @@ func (s *Searcher) FirstNodeAt(fname string, line int) (ast.Node, error) {
return true
})
if node == nil {
return nil, fmt.Errorf("could not find node at %s:%d", fname, line)
return nil, NoNodeError{f: fname, l: line}
}
return node, nil
}
@ -52,7 +61,7 @@ func (s *Searcher) NextLines(fname string, line int) (lines []int, err error) {
var found bool
n, err := s.FirstNodeAt(fname, line)
if err != nil {
return nil, err
return lines, nil
}
defer func() {
if e := recover(); e != nil {