@@ -541,6 +541,8 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
541
541
} else if a .tag == TagCompileUnit {
542
542
delay = append (delay , delayed {i , off , formAddrx })
543
543
break
544
+ } else {
545
+ b .error ("Can't adjust offset: compilation unit skipped" )
544
546
}
545
547
546
548
var err error
@@ -692,6 +694,8 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
692
694
} else if a .tag == TagCompileUnit {
693
695
delay = append (delay , delayed {i , off , formStrx })
694
696
break
697
+ } else {
698
+ b .error ("Can't adjust offset: compilation unit skipped" )
695
699
}
696
700
697
701
val = resolveStrx (uint64 (strBase ), off )
@@ -752,6 +756,8 @@ func (b *buf) entry(cu *Entry, atab abbrevTable, ubase Offset, vers int) *Entry
752
756
} else if a .tag == TagCompileUnit {
753
757
delay = append (delay , delayed {i , off , formRnglistx })
754
758
break
759
+ } else {
760
+ b .error ("Can't adjust offset: compilation unit skipped" )
755
761
}
756
762
757
763
val = resolveRnglistx (uint64 (rnglistsBase ), off )
@@ -828,7 +834,7 @@ func (r *Reader) ByteOrder() binary.ByteOrder {
828
834
829
835
// Seek positions the [Reader] at offset off in the encoded entry stream.
830
836
// Offset 0 can be used to denote the first entry.
831
- func (r * Reader ) Seek (off Offset ) {
837
+ func (r * Reader ) seekImpl (off Offset ) {
832
838
d := r .d
833
839
r .err = nil
834
840
r .lastChildren = false
@@ -856,6 +862,15 @@ func (r *Reader) Seek(off Offset) {
856
862
r .b = makeBuf (r .d , u , "info" , off , u .data [off - u .off :])
857
863
}
858
864
865
+ // Seek positions the [Reader] at offset off in the encoded entry stream, and additionally sets the current
866
+ // CU for the reader.
867
+ func (r * Reader ) Seek (off Offset ) {
868
+ cuIdx := r .d .offsetToUnit (off )
869
+ r .seekImpl (r .d .unit [cuIdx ].off )
870
+ r .Next ()
871
+ r .seekImpl (off )
872
+ }
873
+
859
874
// maybeNextUnit advances to the next unit if this one is finished.
860
875
func (r * Reader ) maybeNextUnit () {
861
876
for len (r .b .data ) == 0 && r .unit + 1 < len (r .d .unit ) {
0 commit comments