dwarfutils

package
v0.0.0-...-46749fd Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dwarfutils provides utilities for working with DWARF debug information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChildLeafEntries

func GetChildLeafEntries(entryReader *dwarf.Reader, offset dwarf.Offset, tag dwarf.Tag) ([]*dwarf.Entry, error)

GetChildLeafEntries returns a list of the debugging information entries (DIEs) that are direct children of the entry at the given offset.

func IsEntryNull

func IsEntryNull(entry *dwarf.Entry) bool

IsEntryNull determines whether a *dwarf.Entry value is a "null" DIE, which are used to denote the end of sub-trees. Note that this is not the same as a nil *dwarf.Entry value; a "null" DIE has a specific meaning in DWARF. For more information, see the DWARF v4 spec, section 2.3

Types

type CompileUnit

type CompileUnit struct {
	// DWARF version of this compile unit
	Version uint8
	LowPC   uint64
	Ranges  [][2]uint64
	// debug_info entry describing this compile unit
	Entry *dwarf.Entry
}

CompileUnit contains the metadata for a single compilation unit in a binary. For more information, see the DWARF v4 spec, section 3.1

This struct is based on github.com/go-delve/delve/pkg/proc.*compileUnit: - https://github.com/go-delve/delve/blob/75bbbbb60cecda0d65c63de7ae8cb8b8412d6fc3/pkg/proc/bininfo.go#L436 which is licensed under MIT.

type CompileUnits

type CompileUnits struct {
	All []CompileUnit
}

CompileUnits is a collection of compile units from a binary, which can be queried using FindCompileUnit o find the appropriate compile unit for a PC address.

func LoadCompileUnits

func LoadCompileUnits(dwarfData *dwarf.Data, debugInfoBytes []byte) (*CompileUnits, error)

LoadCompileUnits scans the debug information entries (DIEs) in a binary for a list of compile units.

func (*CompileUnits) FindCompileUnit

func (c *CompileUnits) FindCompileUnit(pc uint64) *CompileUnit

FindCompileUnit returns the compile unit containing address pc, or nil if no such compile unit was found.

This implementation is based on github.com/go-delve/delve/pkg/proc.(*BinaryInfo).findCompileUnit: - https://github.com/go-delve/delve/blob/75bbbbb60cecda0d65c63de7ae8cb8b8412d6fc3/pkg/proc/bininfo.go#L1115 which is licensed under MIT.

type TypeFinder

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

TypeFinder can be used to find types (i.e. structs/typedefs/interfaces) in the DWARF metadata of a Go binary. It wraps github.com/go-delve/delve/pkg/dwarf/godwarf to add additional functionality and fix invalid reflect.Kind values.

func NewTypeFinder

func NewTypeFinder(dwarfData *dwarf.Data) *TypeFinder

NewTypeFinder creates a new TypeFinder, wrapping the already-parsed DWARF data.

func (*TypeFinder) FindStructFieldOffset

func (f *TypeFinder) FindStructFieldOffset(structName string, fieldName string) (uint64, error)

FindStructFieldOffset attempts to look for a struct in the DWARF debug entries, with a matching name. If such a struct is found, the struct's fields are scanned for one matching the given field name, if found, the offset of that field within values of the struct is returned. This can be used to dereference specific fields of a struct once the offset is known.

func (*TypeFinder) FindTypeByName

func (f *TypeFinder) FindTypeByName(name string) (godwarf.Type, error)

FindTypeByName attempts to find the type in the DWARF debug information entries with the given name (matching the name attribute of the entry). If no matching type is found, an error is returned.

func (*TypeFinder) FindTypeByOffset

func (f *TypeFinder) FindTypeByOffset(offset dwarf.Offset) (godwarf.Type, error)

FindTypeByOffset reads the type entry at the given offset in the DWARF data, returning its godwarf.Type wrapper type. This function fixes invalid reflect.Kind values returned from godwarf.

Directories

Path Synopsis
Package locexpr provides a function to statically execute a DWARF location expression.
Package locexpr provides a function to statically execute a DWARF location expression.

Jump to

Keyboard shortcuts

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