// Sym represents a symbol.
type Sym interface {
- Length(dwarfContext interface{}) int64
}
// A Var represents a local variable or a function parameter.
// 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)
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
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)
}
}
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]
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)
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 {
// 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)