]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/dwarf: replace Sym.Length with Context.Size
authorMatthew Dempsky <mdempsky@google.com>
Fri, 1 Sep 2023 04:17:46 +0000 (21:17 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 1 Sep 2023 20:40:28 +0000 (20:40 +0000)
Preparatory refactoring before next CL.

Change-Id: I06fb4670b933fddff1a2a70f3cf1eb124cbd86ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/524899
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/internal/dwarf/dwarf.go
src/cmd/internal/obj/dwarf.go
src/cmd/link/internal/ld/dwarf.go

index c48b576fa04b7b7a59edecf9332d4a6aaad6908a..3e87e590fb02846f235e3e7b7596e54545562a1a 100644 (file)
@@ -40,7 +40,6 @@ var logDwarf bool
 
 // Sym represents a symbol.
 type Sym interface {
-       Length(dwarfContext interface{}) int64
 }
 
 // A Var represents a local variable or a function parameter.
@@ -189,6 +188,7 @@ type InlCall struct {
 // A Context specifies how to add data to a Sym.
 type Context interface {
        PtrSize() int
+       Size(s Sym) int64
        AddInt(s Sym, size int, i int64)
        AddBytes(s Sym, b []byte)
        AddAddress(s Sym, t interface{}, ofs int64)
@@ -1322,7 +1322,7 @@ func putInlinedFunc(ctxt Context, s *FnState, callIdx int) error {
        putattr(ctxt, s.Info, abbrev, DW_FORM_ref_addr, DW_CLS_REFERENCE, 0, callee)
 
        if abbrev == DW_ABRV_INLINED_SUBROUTINE_RANGES {
-               putattr(ctxt, s.Info, abbrev, DW_FORM_sec_offset, DW_CLS_PTR, s.Ranges.Length(ctxt), s.Ranges)
+               putattr(ctxt, s.Info, abbrev, DW_FORM_sec_offset, DW_CLS_PTR, ctxt.Size(s.Ranges), s.Ranges)
                s.PutRanges(ctxt, ic.Ranges)
        } else {
                st := ic.Ranges[0].Start
@@ -1535,7 +1535,7 @@ func putscope(ctxt Context, s *FnState, scopes []Scope, curscope int32, fnabbrev
                        putattr(ctxt, s.Info, DW_ABRV_LEXICAL_BLOCK_SIMPLE, DW_FORM_addr, DW_CLS_ADDRESS, scope.Ranges[0].End, s.StartPC)
                } else {
                        Uleb128put(ctxt, s.Info, DW_ABRV_LEXICAL_BLOCK_RANGES)
-                       putattr(ctxt, s.Info, DW_ABRV_LEXICAL_BLOCK_RANGES, DW_FORM_sec_offset, DW_CLS_PTR, s.Ranges.Length(ctxt), s.Ranges)
+                       putattr(ctxt, s.Info, DW_ABRV_LEXICAL_BLOCK_RANGES, DW_FORM_sec_offset, DW_CLS_PTR, ctxt.Size(s.Ranges), s.Ranges)
 
                        s.PutRanges(ctxt, scope.Ranges)
                }
@@ -1684,7 +1684,7 @@ func putvar(ctxt Context, s *FnState, v *Var, absfn Sym, fnabbrev, inlIndex int,
        }
 
        if abbrevUsesLoclist(abbrev) {
-               putattr(ctxt, s.Info, abbrev, DW_FORM_sec_offset, DW_CLS_PTR, s.Loc.Length(ctxt), s.Loc)
+               putattr(ctxt, s.Info, abbrev, DW_FORM_sec_offset, DW_CLS_PTR, ctxt.Size(s.Loc), s.Loc)
                v.PutLocationList(s.Loc, s.StartPC)
        } else {
                loc := encbuf[:0]
index f5caa08f0a2b0c9ab1b3fcdeab72a492ebbb0769..47882723ddd71d87e8260e2c1a3433db80eb23f6 100644 (file)
@@ -207,6 +207,9 @@ type dwCtxt struct{ *Link }
 func (c dwCtxt) PtrSize() int {
        return c.Arch.PtrSize
 }
+func (c dwCtxt) Size(s dwarf.Sym) int64 {
+       return s.(*LSym).Size
+}
 func (c dwCtxt) AddInt(s dwarf.Sym, size int, i int64) {
        ls := s.(*LSym)
        ls.WriteInt(c.Link, ls.Size, size, i)
@@ -315,10 +318,6 @@ func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym,
        return fn.dwarfInfoSym, fn.dwarfLocSym, fn.dwarfRangesSym, fn.dwarfAbsFnSym, fn.dwarfDebugLinesSym
 }
 
-func (s *LSym) Length(dwarfContext interface{}) int64 {
-       return s.Size
-}
-
 // textPos returns the source position of the first instruction (prog)
 // of the specified function.
 func textPos(fn *LSym) src.XPos {
index 19db1b557333618e0668535d19ae5e4a35ec15b6..e1080488274191241ef7229374b03a5cc6de1b3a 100644 (file)
@@ -73,15 +73,14 @@ type dwctxt struct {
 // DwAttr objects contain references to symbols via this type.
 type dwSym loader.Sym
 
-func (s dwSym) Length(dwarfContext interface{}) int64 {
-       l := dwarfContext.(dwctxt).ldr
-       return int64(len(l.Data(loader.Sym(s))))
-}
-
 func (c dwctxt) PtrSize() int {
        return c.arch.PtrSize
 }
 
+func (c dwctxt) Size(s dwarf.Sym) int64 {
+       return int64(len(c.ldr.Data(loader.Sym(s.(dwSym)))))
+}
+
 func (c dwctxt) AddInt(s dwarf.Sym, size int, i int64) {
        ds := loader.Sym(s.(dwSym))
        dsu := c.ldr.MakeSymbolUpdater(ds)