diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2023-08-31 21:17:46 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-09-01 20:40:28 +0000 |
| commit | 227ec028244b8ad91c7dd5b69fca5150f99a4878 (patch) | |
| tree | 889a6988247e0ff0e2175c37f519b88b378dd378 /src/cmd/internal | |
| parent | 9b0140a6954d65e7a83a7d45a72995ca87301f69 (diff) | |
| download | go-227ec028244b8ad91c7dd5b69fca5150f99a4878.tar.xz | |
cmd/internal/dwarf: replace Sym.Length with Context.Size
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>
Diffstat (limited to 'src/cmd/internal')
| -rw-r--r-- | src/cmd/internal/dwarf/dwarf.go | 8 | ||||
| -rw-r--r-- | src/cmd/internal/obj/dwarf.go | 7 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go index c48b576fa0..3e87e590fb 100644 --- a/src/cmd/internal/dwarf/dwarf.go +++ b/src/cmd/internal/dwarf/dwarf.go @@ -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] diff --git a/src/cmd/internal/obj/dwarf.go b/src/cmd/internal/obj/dwarf.go index f5caa08f0a..47882723dd 100644 --- a/src/cmd/internal/obj/dwarf.go +++ b/src/cmd/internal/obj/dwarf.go @@ -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 { |
