]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/objfile: use aux symbol for pcdata references
authorCherry Mui <cherryyz@google.com>
Mon, 27 Sep 2021 19:55:53 +0000 (15:55 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 28 Sep 2021 15:26:21 +0000 (15:26 +0000)
Pcdata are now separate aux symbols. Read them from aux, instead
of using funcinfo.

Change-Id: Ib3e4b5cff1e3329d0600504a8829a969a9c9f517
Reviewed-on: https://go-review.googlesource.com/c/go/+/352612
Trust: Cherry Mui <cherryyz@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/internal/goobj/objfile.go
src/cmd/internal/objfile/goobj.go

index fc6dbb8af6e699b1f24c3e310f9039aa10720e96..2c44696f84c30e83954015b1df278d788cec02a8 100644 (file)
@@ -357,6 +357,8 @@ type SymRef struct {
        SymIdx uint32
 }
 
+func (s SymRef) IsZero() bool { return s == SymRef{} }
+
 // Hash64
 type Hash64Type [Hash64Size]byte
 
index dd21d223511198448d127596c53095c1ab924700..24d2d0bb5c7b76c9ab91f9123d298f04b1e1c295 100644 (file)
@@ -250,26 +250,21 @@ func (f *goobjFile) PCToLine(pc uint64) (string, int, *gosym.Func) {
                if pc < addr || pc >= addr+uint64(osym.Siz()) {
                        continue
                }
-               isym := ^uint32(0)
-               auxs := r.Auxs(i)
-               for j := range auxs {
-                       a := &auxs[j]
-                       if a.Type() != goobj.AuxFuncInfo {
-                               continue
+               var pcfileSym, pclineSym goobj.SymRef
+               for _, a := range r.Auxs(i) {
+                       switch a.Type() {
+                       case goobj.AuxPcfile:
+                               pcfileSym = a.Sym()
+                       case goobj.AuxPcline:
+                               pclineSym = a.Sym()
                        }
-                       if a.Sym().PkgIdx != goobj.PkgIdxSelf {
-                               panic("funcinfo symbol not defined in current package")
-                       }
-                       isym = a.Sym().SymIdx
                }
-               if isym == ^uint32(0) {
+               if pcfileSym.IsZero() || pclineSym.IsZero() {
                        continue
                }
-               b := r.BytesAt(r.DataOff(isym), r.DataSize(isym))
-               var info *goobj.FuncInfo
-               pcline := getSymData(info.ReadPcline(b))
+               pcline := getSymData(pclineSym)
                line := int(pcValue(pcline, pc-addr, f.arch))
-               pcfile := getSymData(info.ReadPcfile(b))
+               pcfile := getSymData(pcfileSym)
                fileID := pcValue(pcfile, pc-addr, f.arch)
                fileName := r.File(int(fileID))
                // Note: we provide only the name in the Func structure.