mirror of
https://github.com/golang/go
synced 2024-11-23 16:30:06 -07:00
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>
This commit is contained in:
parent
9b0140a695
commit
227ec02824
@ -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]
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user