dwarfbuilder

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dwarfbuilder provides a way to build DWARF sections with arbitrary contents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocationBlock

func LocationBlock(args ...interface{}) []byte

LocationBlock returns a DWARF expression corresponding to the list of arguments.

Types

type Address

type Address uint64

Address represents a machine address.

type Builder

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

Builder dwarf builder

func New

func New() *Builder

New creates a new DWARF builder.

func (*Builder) AddBaseType

func (b *Builder) AddBaseType(typename string, encoding Encoding, byteSz uint16) dwarf.Offset

AddBaseType adds a new base type entry to debug_info. Will write a DW_TAG_base_type, followed by a DW_AT_encoding and a DW_AT_byte_size.

func (*Builder) AddCompileUnit added in v1.3.0

func (b *Builder) AddCompileUnit(name string, lowPC uint64) dwarf.Offset

func (*Builder) AddMember

func (b *Builder) AddMember(fieldname string, typ dwarf.Offset, memberLoc []byte) dwarf.Offset

AddMember adds a new member entry to debug_info. Writes a DW_TAG_member followed by DW_AT_type and DW_AT_data_member_loc.

func (*Builder) AddPointerType added in v1.2.0

func (b *Builder) AddPointerType(typename string, typ dwarf.Offset) dwarf.Offset

AddPointerType adds a new pointer type to debug_info.

func (*Builder) AddStructType

func (b *Builder) AddStructType(typename string, byteSz uint16) dwarf.Offset

AddStructType adds a new structure type to debug_info. Call TagClose to finish adding fields. Will write a DW_TAG_struct_type, followed by a DW_AT_byte_size.

func (*Builder) AddSubprogram

func (b *Builder) AddSubprogram(fnname string, lowpc, highpc uint64) dwarf.Offset

AddSubprogram adds a subprogram declaration to debug_info, must call TagClose after adding all local variables and parameters. Will write an abbrev corresponding to a DW_TAG_subprogram, followed by a DW_AT_lowpc and a DW_AT_highpc.

func (*Builder) AddVariable

func (b *Builder) AddVariable(varname string, typ dwarf.Offset, loc interface{}) dwarf.Offset

AddVariable adds a new variable entry to debug_info. Will write a DW_TAG_variable, followed by a DW_AT_type and a DW_AT_location.

func (*Builder) Attr

func (b *Builder) Attr(attr dwarf.Attr, val interface{}) dwarf.Offset

Attr adds an attribute to the current DIE.

func (*Builder) Build

func (b *Builder) Build() (abbrev, aranges, frame, info, line, pubnames, ranges, str, loc []byte, err error)

Build closes b and returns all the dwarf sections.

func (*Builder) PatchOffset added in v1.6.0

func (b *Builder) PatchOffset(patchedOffset, patch dwarf.Offset)

PatchOffset writes the offset 'patch' at offset patchedOffset.

func (*Builder) SetHasChildren

func (b *Builder) SetHasChildren()

SetHasChildren sets the current DIE as having children (even if none are added).

func (*Builder) TagClose

func (b *Builder) TagClose()

TagClose closes the current DIE.

func (*Builder) TagOpen

func (b *Builder) TagOpen(tag dwarf.Tag, name string) dwarf.Offset

TagOpen starts a new DIE, call TagClose after adding all attributes and children elements.

type Encoding

type Encoding uint16

Encoding represents a DWARF base type encoding (see section 7.8, page 168 and following, DWARF v4).

const (
	DW_ATE_address         Encoding = 0x01
	DW_ATE_boolean         Encoding = 0x02
	DW_ATE_complex_float   Encoding = 0x03
	DW_ATE_float           Encoding = 0x04
	DW_ATE_signed          Encoding = 0x05
	DW_ATE_signed_char     Encoding = 0x06
	DW_ATE_unsigned        Encoding = 0x07
	DW_ATE_unsigned_char   Encoding = 0x08
	DW_ATE_imaginary_float Encoding = 0x09
	DW_ATE_packed_decimal  Encoding = 0x0a
	DW_ATE_numeric_string  Encoding = 0x0b
	DW_ATE_edited          Encoding = 0x0c
	DW_ATE_signed_fixed    Encoding = 0x0d
	DW_ATE_unsigned_fixed  Encoding = 0x0e
	DW_ATE_decimal_float   Encoding = 0x0f
	DW_ATE_UTF             Encoding = 0x10
	DW_ATE_lo_user         Encoding = 0x80
	DW_ATE_hi_user         Encoding = 0xff
)

type Form

type Form uint16

Form represents a DWARF form kind (see Figure 20, page 160 and following, DWARF v4)

const (
	DW_FORM_addr         Form = 0x01 // address
	DW_FORM_block2       Form = 0x03 // block
	DW_FORM_block4       Form = 0x04 // block
	DW_FORM_data2        Form = 0x05 // constant
	DW_FORM_data4        Form = 0x06 // constant
	DW_FORM_data8        Form = 0x07 // constant
	DW_FORM_string       Form = 0x08 // string
	DW_FORM_block        Form = 0x09 // block
	DW_FORM_block1       Form = 0x0a // block
	DW_FORM_data1        Form = 0x0b // constant
	DW_FORM_flag         Form = 0x0c // flag
	DW_FORM_sdata        Form = 0x0d // constant
	DW_FORM_strp         Form = 0x0e // string
	DW_FORM_udata        Form = 0x0f // constant
	DW_FORM_ref_addr     Form = 0x10 // reference
	DW_FORM_ref1         Form = 0x11 // reference
	DW_FORM_ref2         Form = 0x12 // reference
	DW_FORM_ref4         Form = 0x13 // reference
	DW_FORM_ref8         Form = 0x14 // reference
	DW_FORM_ref_udata    Form = 0x15 // reference
	DW_FORM_indirect     Form = 0x16 // (see Section 7.5.3)
	DW_FORM_sec_offset   Form = 0x17 // lineptr, loclistptr, macptr, rangelistptr
	DW_FORM_exprloc      Form = 0x18 // exprloc
	DW_FORM_flag_present Form = 0x19 // flag
	DW_FORM_ref_sig8     Form = 0x20 // reference
)

type LocEntry

type LocEntry struct {
	Lowpc  uint64
	Highpc uint64
	Loc    []byte
}

LocEntry represents one entry of debug_loc.

Jump to

Keyboard shortcuts

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