Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug/dwarf: fail on reading incorrect offset due to skipped compilation unit #70400

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/debug/dwarf/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
} else if a.tag == TagCompileUnit {
delay = append(delay, delayed{i, off, formAddrx})
break
} else {
b.error("Can't adjust offset: compilation unit skipped")
}

var err error
Expand Down Expand Up @@ -692,6 +694,8 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
} else if a.tag == TagCompileUnit {
delay = append(delay, delayed{i, off, formStrx})
break
} else {
b.error("Can't adjust offset: compilation unit skipped")
}

val = resolveStrx(uint64(strBase), off)
Expand Down Expand Up @@ -752,6 +756,8 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
} else if a.tag == TagCompileUnit {
delay = append(delay, delayed{i, off, formRnglistx})
break
} else {
b.error("Can't adjust offset: compilation unit skipped")
}

val = resolveRnglistx(uint64(rnglistsBase), off)
Expand Down Expand Up @@ -856,6 +862,15 @@ func (r *Reader) Seek(off Offset) {
r.b = makeBuf(r.d, u, "info", off, u.data[off-u.off:])
}

// SeekAndSetCU positions the [Reader] at offset off in the encoded entry stream, and additionally sets the current
// CU for the reader.
func (r *Reader) SeekAndSetCU(off Offset) {
cuIdx := r.d.offsetToUnit(off)
r.Seek(r.d.unit[cuIdx].off)
r.Next()
r.Seek(off)
}

// maybeNextUnit advances to the next unit if this one is finished.
func (r *Reader) maybeNextUnit() {
for len(r.b.data) == 0 && r.unit+1 < len(r.d.unit) {
Expand Down