dwarfgen

Imports

Imports #

"sort"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/internal/dwarf"
"cmd/internal/obj"
"cmd/internal/src"
"bytes"
"flag"
"fmt"
"internal/buildcfg"
"slices"
"sort"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/ssa"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/dwarf"
"cmd/internal/obj"
"cmd/internal/objabi"
"cmd/internal/src"
"fmt"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/internal/dwarf"
"cmd/internal/obj"
"cmd/internal/src"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/internal/src"

Structs

ScopeMarker struct #

A ScopeMarker tracks scope nesting and boundaries for later use during DWARF generation.

type ScopeMarker struct {
parents []ir.ScopeID
marks []ir.Mark
}

varPos struct #

To identify variables by original source position.

type varPos struct {
DeclName string
DeclFile string
DeclLine uint
DeclCol uint
}

varsAndDecls struct #

type varsAndDecls struct {
decls []*ir.Name
vars []*dwarf.Var
paramOrder map[*ir.Name]int
}

varsByScope struct #

type varsByScope struct {
vars []*dwarf.Var
scopes []ir.ScopeID
}

varsByScopeAndOffset struct #

type varsByScopeAndOffset struct {
vars []*dwarf.Var
scopes []ir.ScopeID
}

Functions

AbstractFunc function #

Secondary hook for DWARF inlined subroutine generation. This is called late in the compilation when it is determined that we need an abstract function DIE for an inlined routine imported from a previously compiled package.

func AbstractFunc(fn *obj.LSym)

Info function #

func Info(ctxt *obj.Link, fnsym *obj.LSym, infosym *obj.LSym, curfn obj.Func) (scopes []dwarf.Scope, inlcalls dwarf.InlCalls)

Len method #

func (v varsByScope) Len() int

Len method #

func (v varsAndDecls) Len() int

Len method #

func (v varsByScopeAndOffset) Len() int

Less method #

func (v varsAndDecls) Less(i int, j int) bool

Less method #

func (v varsByScopeAndOffset) Less(i int, j int) bool

Less method #

func (v varsByScope) Less(i int, j int) bool

Pop method #

Pop records a transition back to the current scope's parent.

func (m *ScopeMarker) Pop(pos src.XPos)

Push method #

Push records a transition to a new child scope of the current scope.

func (m *ScopeMarker) Push(pos src.XPos)

RecordFlags function #

RecordFlags records the specified command-line flags to be placed in the DWARF info.

func RecordFlags(flags ...string)

RecordPackageName function #

RecordPackageName records the name of the package being compiled, so that the linker can save it in the compile unit's DIE.

func RecordPackageName()

Swap method #

func (v varsByScopeAndOffset) Swap(i int, j int)

Swap method #

func (v varsByScope) Swap(i int, j int)

Swap method #

func (v varsAndDecls) Swap(i int, j int)

Unpush method #

Unpush removes the current scope, which must be empty.

func (m *ScopeMarker) Unpush()

WriteTo method #

WriteTo writes the recorded scope marks to the given function, and resets the marker for reuse.

func (m *ScopeMarker) WriteTo(fn *ir.Func)

addRange function #

func addRange(calls []dwarf.InlCall, start int64, end int64, ii int, imap map[int]int)

assembleInlines function #

This is the main entry point for collection of raw material to drive generation of DWARF "inlined subroutine" DIEs. See proposal 22080 for more details and background info.

func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls

assembleScopes function #

func assembleScopes(fnsym *obj.LSym, fn *ir.Func, dwarfVars []*dwarf.Var, varScopes []ir.ScopeID) []dwarf.Scope

checkInlCall function #

checkInlCall verifies that the PC ranges for inline info 'idx' are enclosed/contained within the ranges of its parent inline (or if this is a root/toplevel inline, checks that the ranges fall within the extent of the top level function). A panic is issued if a malformed range is found.

func checkInlCall(funcName string, inlCalls dwarf.InlCalls, funcSize int64, idx int, parentIdx int)

checkPos method #

checkPos validates the given position and returns the current scope.

func (m *ScopeMarker) checkPos(pos src.XPos) ir.ScopeID

closureOffset function #

func closureOffset(n *ir.Name, closureVars map[*ir.Name]int64) int64

compactMarks method #

func (m *ScopeMarker) compactMarks()

compactScopes function #

func compactScopes(dwarfScopes []dwarf.Scope) []dwarf.Scope

createABIVars function #

createABIVars creates DWARF variables for functions in which the register ABI is enabled but optimization is turned off. It uses a hybrid approach in which register-resident input params are captured with location lists, and all other vars use the "simple" strategy.

func createABIVars(fnsym *obj.LSym, fn *ir.Func, apDecls []*ir.Name, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var, ir.NameSet)

createComplexVar function #

createComplexVar builds a single DWARF variable entry and location list.

func createComplexVar(fnsym *obj.LSym, fn *ir.Func, varID ssa.VarID, closureVars map[*ir.Name]int64) *dwarf.Var

createComplexVars function #

createComplexVars creates recomposed DWARF vars with location lists, suitable for describing optimized code.

func createComplexVars(fnsym *obj.LSym, fn *ir.Func, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var, ir.NameSet)

createDwarfVars function #

createDwarfVars process fn, returning a list of DWARF variables and the Nodes they represent.

func createDwarfVars(fnsym *obj.LSym, complexOK bool, fn *ir.Func, apDecls []*ir.Name, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var)

createSimpleVar function #

func createSimpleVar(fnsym *obj.LSym, n *ir.Name, closureVars map[*ir.Name]int64) *dwarf.Var

createSimpleVars function #

createSimpleVars creates a DWARF entry for every variable declared in the function, claiming that they are permanently on the stack.

func createSimpleVars(fnsym *obj.LSym, apDecls []*ir.Name, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var, ir.NameSet)

declPos function #

func declPos(decl *ir.Name) src.XPos

dumpInlCall function #

func dumpInlCall(inlcalls dwarf.InlCalls, idx int, ilevel int)

dumpInlCalls function #

func dumpInlCalls(inlcalls dwarf.InlCalls)

dumpInlVars function #

func dumpInlVars(dwvars []*dwarf.Var)

findScope function #

func findScope(marks []ir.Mark, pos src.XPos) ir.ScopeID

insertInlCall function #

func insertInlCall(dwcalls *dwarf.InlCalls, inlIdx int, imap map[int]int) int

makePreinlineDclMap function #

Given a function that was inlined as part of the compilation, dig up the pre-inlining DCL list for the function and create a map that supports lookup of pre-inline dcl index, based on variable position/name. NB: the recipe for computing variable pos/file/line needs to be kept in sync with the similar code in gc.createSimpleVars and related functions.

func makePreinlineDclMap(fnsym *obj.LSym) map[varPos]int

posInlIndex function #

Given a src.XPos, return its associated inlining index if it corresponds to something created as a result of an inline, or -1 if there is no inline info. Note that the index returned will refer to the deepest call in the inlined stack, e.g. if you have "A calls B calls C calls D" and all three callees are inlined (B, C, and D), the index for a node from the inlined body of D will refer to the call to D from C. Whew.

func posInlIndex(xpos src.XPos) int

preInliningDcls function #

Given a function that was inlined at some point during the compilation, return a sorted list of nodes corresponding to the autos/locals in that function prior to inlining. If this is a function that is not local to the package being compiled, then the names of the variables may have been "versioned" to avoid conflicts with local vars; disregard this versioning when sorting.

func preInliningDcls(fnsym *obj.LSym) []*ir.Name

rangesContains function #

func rangesContains(par []dwarf.Range, rng dwarf.Range) (bool, string)

rangesContainsAll function #

func rangesContainsAll(parent []dwarf.Range, child []dwarf.Range) (bool, string)

scopePCs function #

scopePCs assigns PC ranges to their scopes.

func scopePCs(fnsym *obj.LSym, marks []ir.Mark, dwarfScopes []dwarf.Scope)

scopeVariables function #

scopeVariables assigns DWARF variable records to their scopes.

func scopeVariables(dwarfVars []*dwarf.Var, varScopes []ir.ScopeID, dwarfScopes []dwarf.Scope, regabi bool)

sortDeclsAndVars function #

sortDeclsAndVars sorts the decl and dwarf var lists according to parameter declaration order, so as to insure that when a subprogram DIE is emitted, its parameter children appear in declaration order. Prior to the advent of the register ABI, sorting by frame offset would achieve this; with the register we now need to go back to the original function signature.

func sortDeclsAndVars(fn *ir.Func, decls []*ir.Name, vars []*dwarf.Var)

unifyCallRanges function #

unifyCallRanges ensures that the ranges for a given inline transitively include all of the ranges for its child inlines.

func unifyCallRanges(inlcalls dwarf.InlCalls, idx int)

xposBefore function #

See golang.org/issue/20390.

func xposBefore(p src.XPos, q src.XPos) bool

Generated with Arrow