}
}
-func debuginfo(fnsym *obj.LSym, curfn interface{}) ([]dwarf.Scope, dwarf.InlCalls) {
+func debuginfo(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope, dwarf.InlCalls) {
fn := curfn.(*Node)
if fn.Func.Nname != nil {
if expect := fn.Func.Nname.Sym.Linksym(); fnsym != expect {
Name: name,
Gotype: gotype,
})
+ fnsym.Func.RecordAutoType(gotype)
}
decls, dwarfVars := createDwarfVars(fnsym, fn.Func, automDecls)
+ // For each type referenced by the functions auto vars, attach a
+ // dummy relocation to the function symbol to insure that the type
+ // included in DWARF processing during linking.
+ typesyms := []*obj.LSym{}
+ for t, _ := range fnsym.Func.Autot {
+ typesyms = append(typesyms, t)
+ }
+ sort.Sort(obj.BySymName(typesyms))
+ for _, sym := range typesyms {
+ r := obj.Addrel(infosym)
+ r.Sym = sym
+ r.Type = objabi.R_USETYPE
+ }
+ fnsym.Func.Autot = nil
+
var varScopes []ScopeID
for _, decl := range decls {
pos := decl.Pos
Name: obj.NAME_DELETED_AUTO,
Gotype: gotype,
})
-
+ fnsym.Func.RecordAutoType(gotype)
}
return decls, vars
Locals int32
Text *Prog
Autom []*Auto
+ Autot map[*LSym]struct{}
Pcln Pcln
InlMarks []InlMark
fi.InlMarks = append(fi.InlMarks, InlMark{p: p, id: id})
}
+// Record the type symbol for an auto variable so that the linker
+// an emit DWARF type information for the type.
+func (fi *FuncInfo) RecordAutoType(gotype *LSym) {
+ if fi.Autot == nil {
+ fi.Autot = make(map[*LSym]struct{})
+ }
+ fi.Autot[gotype] = struct{}{}
+}
+
//go:generate stringer -type ABI
// ABI is the calling convention of a text symbol.
Imports []string
DiagFunc func(string, ...interface{})
DiagFlush func()
- DebugInfo func(fn *LSym, curfn interface{}) ([]dwarf.Scope, dwarf.InlCalls) // if non-nil, curfn is a *gc.Node
+ DebugInfo func(fn *LSym, info *LSym, curfn interface{}) ([]dwarf.Scope, dwarf.InlCalls) // if non-nil, curfn is a *gc.Node
GenAbstractFunc func(fn *LSym)
Errors int
var scopes []dwarf.Scope
var inlcalls dwarf.InlCalls
if ctxt.DebugInfo != nil {
- scopes, inlcalls = ctxt.DebugInfo(s, curfn)
+ scopes, inlcalls = ctxt.DebugInfo(s, info, curfn)
}
var err error
dwctxt := dwCtxt{ctxt}
if s.Func == nil {
s.Func = new(FuncInfo)
}
- scopes, _ := ctxt.DebugInfo(s, curfn)
+ scopes, _ := ctxt.DebugInfo(s, absfn, curfn)
dwctxt := dwCtxt{ctxt}
filesym := ctxt.fileSymbol(s)
fnstate := dwarf.FnState{
fns[idx] = fn
idx++
}
- sort.Sort(bySymName(fns))
+ sort.Sort(BySymName(fns))
// Should not be called during parallel portion of compilation.
if ft.ctxt.InParallel {
}
}
-type bySymName []*LSym
+type BySymName []*LSym
-func (s bySymName) Len() int { return len(s) }
-func (s bySymName) Less(i, j int) bool { return s[i].Name < s[j].Name }
-func (s bySymName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+func (s BySymName) Len() int { return len(s) }
+func (s BySymName) Less(i, j int) bool { return s[i].Name < s[j].Name }
+func (s BySymName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }