parser

package
v0.0.0-...-b9e7692 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatEntryInfo

func FormatEntryInfo(entry *dwarf.Entry) string

Formats key information about this entry as a string; strives to be easily readable.

func GetArrayRanges

func GetArrayRanges(r *dwarf.Reader, entry *dwarf.Entry) ([]int, error)

Returns a slice with en entry for the range of each array dimension

Scalar types will have range []int{0}. The length of the return defines the dimension of the array.

func GetBitSize

func GetBitSize(entry *dwarf.Entry) (int, error)

Finds the size of the type defined by this entry, in bits

func GetCUs

func GetCUs(r *dwarf.Reader) ([]*dwarf.Entry, error)

func GetChildren

func GetChildren(r *dwarf.Reader, f func(*dwarf.Entry) bool) ([]*dwarf.Entry, error)

Return a slice of all child entries of the current entry filteed by a passed function

TODO: this doesn't seem to work yet

func GetEntry

func GetEntry(r *dwarf.Reader, name string) (*dwarf.Entry, *dwarf.Entry, error)

Searches for an entry matching a requested name

TODO: this many return values seems like a bad idea

func GetLocation

func GetLocation(entry *dwarf.Entry) ([]uint8, error)

Returns the location of an entry in memory

func GetReader

func GetReader[T DebugFile](fh T) (*dwarf.Reader, error)

Returns a dwarf.Reader object

func GetTypeEntry

func GetTypeEntry(reader *dwarf.Reader, entry *dwarf.Entry) (*dwarf.Entry, error)

Returns the entry defining the type for a given entry. Returns self if no such entry can be found. Leaves the reader at the new entry.

func HasAttr

func HasAttr(entry *dwarf.Entry, attr dwarf.Attr) bool

Return true if this entry contains the requested attribute

func ListAllAttributes

func ListAllAttributes(entry *dwarf.Entry)

Prints each attribute for this entry.

func ParseLocation

func ParseLocation(location []uint8) int

Translates a DW_AT_locationn attribute into an address

func ResolveTypeEntry

func ResolveTypeEntry(reader *dwarf.Reader, entry *dwarf.Entry) (*dwarf.Entry, error)

Repeatedly calls GetTypeEntry until arriving at an entry that truly describes the underlying type of this entry. Skip over array and other non-typedef entries

Types

type DebugFile

type DebugFile interface {
	DWARF() (*dwarf.Data, error)
}

type Proxy

type Proxy interface {
	Name() string
	ListChildren() []string
	GetChild(childName string) (*TypeDefProxy, error)
}

type TypeDefProxy

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

A TypedefProxy is an outward-facing representation of a typedef representing what a user may care about without any DWARF implementation information. This proxy represents the key information required to understand the layout of a particular type and then read or create variables of this type idiomatically from within a target language (most immediately relevant is Go but this should be generic enough to apply to other languages through Go bindings or a socket server using json or rpc).

All relevant DWARF parsing is handled when this proxy is created and no intermediate DWARF data is included here. The proxy should be ready to hand off as-is to a user.

func NewTypeDefProxy

func NewTypeDefProxy(reader *dwarf.Reader, e *dwarf.Entry) (*TypeDefProxy, error)

Construct a new TypeDefProxy

func (TypeDefProxy) GetChild

func (p TypeDefProxy) GetChild(childName string) (*TypeDefProxy, error)

Returns the TypeDefProxy for a member of this TypeDef by name

func (*TypeDefProxy) GoString

func (p *TypeDefProxy) GoString() string

func (TypeDefProxy) ListChildren

func (p TypeDefProxy) ListChildren() []string

Retuns a slice of strings containing the name of each member of this TypeDef

func (TypeDefProxy) Name

func (p TypeDefProxy) Name() string

type VariableProxy

type VariableProxy struct {
	Type    TypeDefProxy
	Address int
	// contains filtered or unexported fields
}

Represents a variable and facilitates interacting with that variable. For our purposes, a variable is an object of known Type located at a known address, whose value we can find by reading a known size from that address. Alternatively, we can set the value of this variables, or its members if it is a struct, and then write those values back to memory.

Data is stored internally as bytes and parse into fields on demand.

Writing data to memory is handled elsewhere; this proxy instructs a client which addresses to read and provides a writeable stream of bytes to allow the client to write the variable back to memory.

func NewVariableProxy

func NewVariableProxy(reader *dwarf.Reader, entry *dwarf.Entry) (*VariableProxy, error)

Construct a new VariableProxy for a variable known to the DWARF debug info.

To create a variable from scratch , use *some other method*

func (*VariableProxy) Get

func (p *VariableProxy) Get() ([]byte, error)

Return the value of the entire variable

In the case of a multi-field struct, this is most useful to enable the client to write the entire variable back to memory.

func (VariableProxy) GetChild

func (p VariableProxy) GetChild(childName string) (*TypeDefProxy, error)

TODO: change the child hierarchy to use ordered maps not slices for lookup speed?

func (*VariableProxy) GetField

func (p *VariableProxy) GetField(field string) (int, error)

Return the value of a single field within this variable Typically this will be used for a struct or class

NOTE: at present, fields must be byte-aligned

func (*VariableProxy) GoString

func (p *VariableProxy) GoString() string

func (*VariableProxy) Init

func (p *VariableProxy) Init(reader *dwarf.Reader, entry *dwarf.Entry) error

func (VariableProxy) ListChildren

func (p VariableProxy) ListChildren() []string

Retuns a slice of strings containing the name of each member of this TypeDef

func (VariableProxy) Name

func (p VariableProxy) Name() string

func (*VariableProxy) Read

func (p *VariableProxy) Read() error

func (*VariableProxy) Set

func (p *VariableProxy) Set(value []byte) error

Set the value of this entire variable

In the case of a multi-field struct, this is most useful for initializing our proxy of a variable by having the client read the entire variable out of memory. Once the proxy is poplulated, we can access fields as required.

func (*VariableProxy) SetClient

func (p *VariableProxy) SetClient(c client.Client)

func (*VariableProxy) SetField

func (p *VariableProxy) SetField(field string, value int) error

Set the value of a single field within this variable Typically this will be used for a struct or class

NOTE: at present, fields must be byte-aligned

func (*VariableProxy) Write

func (p *VariableProxy) Write() error

Jump to

Keyboard shortcuts

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