binary

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DW_OP_addr = 0x03

	// type in elf binary
	UTYPE_VAR    string = "Variable"
	UTYPE_STRUCT string = "StructType"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Binary

type Binary struct {
	Path string

	Entry    uint64 // elf binary entry point address
	SymTable *gosym.Table

	StrtMap map[string]*Strt // get strrt by name

	// following fields are parsed from binary dwarf during starting
	GoVerAddr           uint64 `name:"runtime.buildVersion"`    // parsed vma of runtime.buildVersion
	RuntimeInitTimeAddr uint64 `name:"runtime.runtimeInitTime"` // parsed runtime.runtimeInitTime
	GStruct             *Strt  `name:"runtime.g"`               // parsed runtime.g struct
	MStruct             *Strt  `name:"runtime.m"`               // parsed runtime.m struct
	PStruct             *Strt  `name:"runtime.p"`               // parsed runtime.p struct
	GobufStruct         *Strt  `name:"runtime.gobuf"`           // parsed runtime.gobuf struct
	SchedtStruct        *Strt  `name:"runtime.schedt"`          // parsed runtime.schedt struct
	MStatsStruct        *Strt  `name:"runtime.mstats"`          // parsed runtime.mstats struct
	MSpanStruct         *Strt  `name:"runtime.mspan"`           // parsed runtime.mspan struct
	MCentralStruct      *Strt  `name:"runtime.mcentral"`        // parsed runtime.mcentral struct
	MHeapStruct         *Strt  `name:"runtime.mheap"`           // parsed runtime.mheap struct
	MCacheStruct        *Strt  `name:"runtime.mcache"`          // parsed runtime.mcache struct
	StackStruct         *Strt  `name:"runtime.stack"`           // parsed runtime.stack struct
	SchedAddr           uint64 `name:"runtime.sched"`           // parsed vma of runtime.sched
	AllglenAddr         uint64 `name:"runtime.allglen"`         // parsed vma of runtime.allglen
	AllgsAddr           uint64 `name:"runtime.allgs"`           // parsed vma of runtime.allgs
	AllpAddr            uint64 `name:"runtime.allp"`            // parsed vma of runtime.allp
	GomaxprocsAddr      uint64 `name:"runtime.gomaxprocs"`      // parsed vma of runtime.gomaxprocs
	MStatsAddr          uint64 `name:"runtime.memstats"`        // parsed vma of runtime.memstats
	MHeapAddr           uint64 `name:"runtime.mheap_"`          // parsed vma of runtime.mheap_
	SudogStruct         *Strt  `name:"runtime.sudog"`           // parsed runtime.sudog struct
	HChanStruct         *Strt  `name:"runtime.hchan"`           // parsed runtime.hchan struct
	TypeStruct          *Strt  `name:"internal/abi.Type"`       // parsed internal/abi.Type struct, from 1.21
	// contains filtered or unexported fields
}

func Load

func Load(path string) (*Binary, error)

func (*Binary) DumpVar

func (b *Binary) DumpVar(name string) (Var, error)

func (*Binary) Initialize

func (b *Binary) Initialize() error

Initialize will pre parse some info from elf binary

func (*Binary) PCToFunc

func (b *Binary) PCToFunc(addr uint64) *Location

PCToFunc convert program counter to symbolic information

func (*Binary) Parse

func (b *Binary) Parse(units ...*unit) (map[string]interface{}, error)

type BoolVar

type BoolVar struct {
	CommonType
}

func (*BoolVar) String

func (b *BoolVar) String() string

type CommonType

type CommonType struct {
	Name  string
	Addr  uint64
	Size  int64
	Value interface{}
}

func (*CommonType) GetAddr

func (c *CommonType) GetAddr() uint64

type IntVar

type IntVar struct {
	CommonType
}

func (*IntVar) String

func (i *IntVar) String() string

type Location

type Location struct {
	PC   uint64      // program counter
	File string      // source code file name, from dwarf info
	Line int         // soure code line, from dwarf info
	Func *gosym.Func // function name
}

func (Location) String

func (l Location) String() string

type PtrVar

type PtrVar struct {
	CommonType
	Type Var
}

func (*PtrVar) String

func (b *PtrVar) String() string

type StringVar

type StringVar struct {
	CommonType
}

func (*StringVar) String

func (s *StringVar) String() string

type Strt

type Strt struct {
	Name    string
	Size    int64
	Members map[string]*StrtMember
}

Strt is a abstruct struct parsed from dwarf info

func (*Strt) GetFieldAddr

func (s *Strt) GetFieldAddr(baseAddr uint64, name string) uint64

type StrtMember

type StrtMember struct {
	Name       string
	Size       int64  // member field size
	Offset     uint32 // offset in binary
	StrtOffset int64  // offset inside struct
}

type UintVar

type UintVar struct {
	CommonType
}

func (*UintVar) String

func (u *UintVar) String() string

type Var

type Var interface {
	String() string
	GetAddr() uint64
}

Jump to

Keyboard shortcuts

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