debug/dwarf: return ErrUnknownPC rather than nil on unknown PC

Currently, on e == nil or e.Tag == 0, SeekPC returns with a nil error.
Instead, indicate that the PC is unknown.

Change-Id: I9594296034e2df872e399bd800b00cb565c413c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/473695
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Joel Sing 2023-03-03 01:24:06 +11:00
parent 6827f0d772
commit 20e9b7f1b5
1 changed files with 4 additions and 1 deletions

View File

@ -975,9 +975,12 @@ func (r *Reader) SeekPC(pc uint64) (*Entry, error) {
u := &r.d.unit[unit]
r.b = makeBuf(r.d, u, "info", u.off, u.data)
e, err := r.Next()
if err != nil || e == nil || e.Tag == 0 {
if err != nil {
return nil, err
}
if e == nil || e.Tag == 0 {
return nil, ErrUnknownPC
}
ranges, err := r.d.Ranges(e)
if err != nil {
return nil, err