godwarf

package
v1.22.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrGoKind          dwarf.Attr = 0x2900
	AttrGoKey           dwarf.Attr = 0x2901
	AttrGoElem          dwarf.Attr = 0x2902
	AttrGoEmbeddedField dwarf.Attr = 0x2903
	AttrGoRuntimeType   dwarf.Attr = 0x2904
	AttrGoPackageName   dwarf.Attr = 0x2905
	AttrGoDictIndex     dwarf.Attr = 0x2906
	AttrGoClosureOffset dwarf.Attr = 0x2907
)

Variables

This section is empty.

Functions

func GetDebugSectionElf added in v1.1.0

func GetDebugSectionElf(f *elf.File, name string) ([]byte, error)

GetDebugSectionElf returns the data contents of the specified debug section, decompressing it if it is compressed. For example GetDebugSectionElf("line") will return the contents of .debug_line, if .debug_line doesn't exist it will try to return the decompressed contents of .zdebug_line.

func GetDebugSectionMacho added in v1.1.0

func GetDebugSectionMacho(f *macho.File, name string) ([]byte, error)

GetDebugSectionMacho returns the data contents of the specified debug section, decompressing it if it is compressed. For example GetDebugSectionMacho("line") will return the contents of __debug_line, if __debug_line doesn't exist it will try to return the decompressed contents of __zdebug_line.

func GetDebugSectionPE added in v1.1.0

func GetDebugSectionPE(f *pe.File, name string) ([]byte, error)

GetDebugSectionPE returns the data contents of the specified debug section, decompressing it if it is compressed. For example GetDebugSectionPE("line") will return the contents of .debug_line, if .debug_line doesn't exist it will try to return the decompressed contents of .zdebug_line.

Types

type AddrType

type AddrType struct {
	BasicType
}

An AddrType represents a machine address type.

type ArrayType

type ArrayType struct {
	CommonType
	Type          Type
	StrideBitSize int64 // if > 0, number of bits to hold each element
	Count         int64 // if == -1, an incomplete array, like char x[].
}

An ArrayType represents a fixed size array type.

func (*ArrayType) Align added in v1.22.2

func (t *ArrayType) Align() int64

func (*ArrayType) Size

func (t *ArrayType) Size() int64

func (*ArrayType) String

func (t *ArrayType) String() string

type BasicType

type BasicType struct {
	CommonType
	BitSize   int64
	BitOffset int64
}

A BasicType holds fields common to all basic types.

func (*BasicType) Align added in v1.22.2

func (t *BasicType) Align() int64

func (*BasicType) Basic

func (t *BasicType) Basic() *BasicType

func (*BasicType) String

func (t *BasicType) String() string

type BoolType

type BoolType struct {
	BasicType
}

A BoolType represents a boolean type.

type ChanType

type ChanType struct {
	TypedefType
	ElemType Type
}

A ChanType represents a Go channel type.

func (*ChanType) String

func (t *ChanType) String() string

type CharType

type CharType struct {
	BasicType
}

A CharType represents a signed character type.

type CommonType

type CommonType struct {
	Index       int          // index supplied by caller of ReadType
	ByteSize    int64        // size of value of this type, in bytes
	Name        string       // name that can be used to refer to type
	ReflectKind reflect.Kind // the reflect kind of the type.
	Offset      dwarf.Offset // the offset at which this type was read
}

A CommonType holds fields common to multiple types. If a field is not known or not applicable for a given type, the zero value is used.

func (*CommonType) Align added in v1.22.2

func (c *CommonType) Align() int64

func (*CommonType) Common

func (c *CommonType) Common() *CommonType

func (*CommonType) Size

func (c *CommonType) Size() int64

type ComplexType

type ComplexType struct {
	BasicType
}

A ComplexType represents a complex floating point type.

type DebugAddr added in v1.22.2

type DebugAddr struct {
	*DebugAddrSection
	// contains filtered or unexported fields
}

DebugAddr represents a subsection of the debug_addr section with a specific base address

func (*DebugAddr) Get added in v1.22.2

func (addr *DebugAddr) Get(idx uint64) (uint64, error)

Get returns the address at index idx starting from addrBase.

type DebugAddrSection added in v1.22.2

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

DebugAddrSection represents the debug_addr section of DWARFv5. See DWARFv5 section 7.27 page 241 and following.

func ParseAddr added in v1.22.2

func ParseAddr(data []byte) *DebugAddrSection

ParseAddr parses the header of a debug_addr section.

func (*DebugAddrSection) GetSubsection added in v1.22.2

func (addr *DebugAddrSection) GetSubsection(addrBase uint64) *DebugAddr

GetSubsection returns the subsection of debug_addr starting at addrBase

type DotDotDotType

type DotDotDotType struct {
	CommonType
}

A DotDotDotType represents the variadic ... function parameter.

func (*DotDotDotType) String

func (t *DotDotDotType) String() string

type Entry added in v1.22.2

type Entry interface {
	Val(dwarf.Attr) interface{}
	AttrField(dwarf.Attr) *dwarf.Field
}

Entry represents a debug_info entry. When calling Val, if the entry does not have the specified attribute, the entry specified by DW_AT_abstract_origin will be searched recursively.

func LoadAbstractOriginAndSpecification added in v1.22.2

func LoadAbstractOriginAndSpecification(entry *dwarf.Entry, aordr *dwarf.Reader) (Entry, dwarf.Offset)

LoadAbstractOriginAndSpecification loads the entry corresponding to the DW_AT_abstract_origin and/or DW_AT_specification of entry and returns a combination of entry and its abstract origin. If a DIE has both a specification and an abstract origin the specification will be ignored, the DWARF standard is unclear on how this should be handled

type EnumType

type EnumType struct {
	CommonType
	EnumName string
	Val      []*EnumValue
}

An EnumType represents an enumerated type. The only indication of its native integer type is its ByteSize (inside CommonType).

func (*EnumType) String

func (t *EnumType) String() string

type EnumValue

type EnumValue struct {
	Name string
	Val  int64
}

An EnumValue represents a single enumeration value.

type FloatType

type FloatType struct {
	BasicType
}

A FloatType represents a floating point type.

type FuncType

type FuncType struct {
	CommonType
	ReturnType Type
	ParamType  []Type
}

A FuncType represents a function type.

func (*FuncType) String

func (t *FuncType) String() string

type IntType

type IntType struct {
	BasicType
}

An IntType represents a signed integer type.

type InterfaceType

type InterfaceType struct {
	TypedefType
}

An InterfaceType represents a Go interface.

func (*InterfaceType) String

func (t *InterfaceType) String() string

type MapType

type MapType struct {
	TypedefType
	KeyType  Type
	ElemType Type
}

A MapType represents a Go map type. It looks like a TypedefType, describing the runtime-internal structure, with extra fields.

func (*MapType) String

func (t *MapType) String() string

type ParametricType added in v1.22.2

type ParametricType struct {
	TypedefType
	DictIndex int64
}

type PtrType

type PtrType struct {
	CommonType
	Type Type
}

A PtrType represents a pointer type.

func (*PtrType) String

func (t *PtrType) String() string

type QualType

type QualType struct {
	CommonType
	Qual string
	Type Type
}

A QualType represents a type that has the C/C++ "const", "restrict", or "volatile" qualifier.

func (*QualType) Align added in v1.22.2

func (t *QualType) Align() int64

func (*QualType) Size

func (t *QualType) Size() int64

func (*QualType) String

func (t *QualType) String() string

type SliceType

type SliceType struct {
	StructType
	ElemType Type
}

A SliceType represents a Go slice type. It looks like a StructType, describing the runtime-internal structure, with extra fields.

func (*SliceType) String

func (t *SliceType) String() string

type StringType

type StringType struct {
	StructType
}

A StringType represents a Go string type. It looks like a StructType, describing the runtime-internal structure, but we wrap it for neatness.

func (*StringType) String

func (t *StringType) String() string

type StructField

type StructField struct {
	Name       string
	Type       Type
	ByteOffset int64
	ByteSize   int64
	BitOffset  int64 // within the ByteSize bytes at ByteOffset
	BitSize    int64 // zero if not a bit field
	Embedded   bool
}

A StructField represents a field in a struct, union, or C++ class type.

type StructType

type StructType struct {
	CommonType
	StructName string
	Kind       string // "struct", "union", or "class".
	Field      []*StructField
	Incomplete bool // if true, struct, union, class is declared but not defined
}

A StructType represents a struct, union, or C++ class type.

func (*StructType) Align added in v1.22.2

func (t *StructType) Align() int64

func (*StructType) Defn

func (t *StructType) Defn(recCheck recCheck) string

func (*StructType) Size added in v1.22.2

func (t *StructType) Size() int64

func (*StructType) String

func (t *StructType) String() string

type Tree added in v1.22.2

type Tree struct {
	Entry

	Tag      dwarf.Tag
	Offset   dwarf.Offset
	Ranges   [][2]uint64
	Children []*Tree
	// contains filtered or unexported fields
}

Tree represents a tree of dwarf objects.

func EntryToTree added in v1.22.2

func EntryToTree(entry *dwarf.Entry) *Tree

EntryToTree converts a single entry, without children, to a *Tree object.

func LoadTree added in v1.22.2

func LoadTree(off dwarf.Offset, dw *dwarf.Data, staticBase uint64) (*Tree, error)

LoadTree returns the tree of DIE rooted at offset 'off'. Abstract origins are automatically loaded, if present. DIE ranges are bubbled up automatically, if the child of a DIE covers a range of addresses that is not covered by its parent LoadTree will fix the parent entry.

func (*Tree) ContainsPC added in v1.22.2

func (n *Tree) ContainsPC(pc uint64) bool

ContainsPC returns true if the ranges of this DIE contains PC.

func (*Tree) Type added in v1.22.2

func (n *Tree) Type(dw *dwarf.Data, index int, typeCache map[dwarf.Offset]Type) (Type, error)

type Type

type Type interface {
	Common() *CommonType
	String() string
	Size() int64
	Align() int64
	// contains filtered or unexported methods
}

A Type conventionally represents a pointer to any of the specific Type structures (CharType, StructType, etc.).

func FakeBasicType added in v1.22.2

func FakeBasicType(name string, bitSize int) Type

FakeBasicType synthesizes a basic type numeric type (int8, uint16, float32, etc)

func FakeSliceType added in v1.22.2

func FakeSliceType(fieldType Type) Type

FakeSliceType synthesizes a slice type with the given field type.

func ReadType

func ReadType(d *dwarf.Data, index int, off dwarf.Offset, typeCache map[dwarf.Offset]Type) (Type, error)

ReadType reads the type at off in the DWARF “info” section.

type TypedefType

type TypedefType struct {
	CommonType
	Type Type
}

A TypedefType represents a named type.

func (*TypedefType) Align added in v1.22.2

func (t *TypedefType) Align() int64

func (*TypedefType) Size

func (t *TypedefType) Size() int64

func (*TypedefType) String

func (t *TypedefType) String() string

type UcharType

type UcharType struct {
	BasicType
}

A UcharType represents an unsigned character type.

type UintType

type UintType struct {
	BasicType
}

A UintType represents an unsigned integer type.

type UnspecifiedType

type UnspecifiedType struct {
	BasicType
}

An UnspecifiedType represents an implicit, unknown, ambiguous or nonexistent type.

type UnsupportedType added in v1.22.2

type UnsupportedType struct {
	CommonType
	Tag dwarf.Tag
}

An UnsupportedType is a placeholder returned in situations where we encounter a type that isn't supported.

func (*UnsupportedType) String added in v1.22.2

func (t *UnsupportedType) String() string

type VoidType

type VoidType struct {
	CommonType
}

A VoidType represents the C void type.

func (*VoidType) String

func (t *VoidType) String() string

Jump to

Keyboard shortcuts

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