dbg

package
v0.0.0-...-f342860 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Overview

Package dbg contains tools for interpreting DWARF debug info.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CU

type CU struct {
	*dwarf.Entry
}

CU is a DWARF compilation unit entry.

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data wraps dwarf.Data to provide utilities for interpreting DWARF debug info. This uses various caches internally to speed up lookups.

func New

func New(dw *dwarf.Data) (*Data, error)

New returns a new Data wrapping dw.

func (*Data) AddrToCU

func (d *Data) AddrToCU(addr uint64) (CU, bool)

AddrToCU returns the DWARF compilation unit containing address addr, or CU{}, false if no CU contains addr.

func (*Data) AddrToSubprogram

func (d *Data) AddrToSubprogram(addr uint64, cu CU) (Subprogram, bool)

AddrToSubprogram returns the dwarf.TagSubprogram entry containing address addr. cu may be CU{} or the CU containing addr.

func (*Data) LineReader

func (d *Data) LineReader() *LineReader

LineReader returns a new unpositioned line table reader. The caller must call one of the Seek methods to position the line table reader before using it.

type InlineSite

type InlineSite struct {
	// Entry is the TagSubprogram or TagInlinedSubroutine DWARF entry of
	// the function that was inlined at this site.
	Entry *dwarf.Entry

	// Caller is the frame at which this inlined function was called, or
	// nil if this is the top of the inlining stack.
	Caller *InlineSite

	// CallLine, CallColumn, and CallFile give the location at which
	// Entry was inlined into Outer. These are the zero value if Outer
	// == nil or if the call site is unknown.
	CallLine, CallColumn int
	CallFile             *dwarf.LineFile
}

InlineSite describes a call site at which a function is inlined.

Inline sites form a tree within a given top-level function. InlineSite objects are immutable once created.

type LineReader

type LineReader struct {

	// Line is the line metadata for the current position of the
	// LineReader. If the current PC is inside an inlined function, this
	// will be the line metadata for the innermost frame.
	Line dwarf.LineEntry

	// Stack is the inline call stack at Line.Address, starting with the
	// innermost frame.
	//
	// This may be nil if the current inlining stack cannot be
	// determined.
	Stack *InlineSite
	// contains filtered or unexported fields
}

LineReader maps from PCs to source line information, including stacks of inlined functions.

It is efficient both for single-PC lookups (using SeekPC or SeekSubprogram) and for iterating over ranges of addresses (using Seek* followed by Next).

Iteration is always in order of increasing PC. The reader can be scoped to the entire binary, in which case it will iterate forward over all PCs, jumping between compilation units as necessary; or it can be scoped to a single subprogram DIE, in which case it will iterate only over PCs within that function (which may be discontiguous).

func (*LineReader) Next

func (lr *LineReader) Next() error

Next advances to the next entry in the line table for the reader's scope and updates lr.Line and lr.Stack. If there are no more entries, it returns io.EOF.

Rows are always in increasing order of Line.Address, but Line.Line may go forward or backward. Line.Address may be the same for entries.

In contrast with the underlying DWARF line tables, this will iterate across compilation units as necessary, and ensures increasing order of address.

func (*LineReader) SeekPC

func (lr *LineReader) SeekPC(pc uint64) error

SeekPC positions the line table reader at the line entry containing pc, or the first entry after pc, and scopes the line table reader to iterate over all code in all compilation units. If there are no valid addresses after pc, it returns dwarf.ErrUnknownPC.

Each line entry covers the address range from Line.Address up to but not including the address of the next line entry. Line entries that have EndSequence do not cover any addresses, but merely provide the end address for the previous line entry.

func (*LineReader) SeekSubprogram

func (lr *LineReader) SeekSubprogram(subprogram Subprogram, pc uint64) error

SeekSubprogram positions the line table reader at the line entry containing pc within subprogram, or the first entry in subprogram after pc, and scopes the line table reader to iterate only within subprogram. A subprogram may consist of multiple discontiguous address ranges. If there are no valid addresses after pc in subprogram, it returns dwarf.ErrUnknownPC. To seek to the beginning of subprogram, pass 0 for pc.

type Subprogram

type Subprogram struct {
	*dwarf.Entry
	CU CU // The compilation unit containing Subprogram.
}

Subprogram is a DWARF subprogram entry. That is, a top-level function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL