entity

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	*AddrPos

	Pkg *Package // package can be nil for cgo symbols

	Function *Function // for symbol source it will be a nil
	Symbol   *Symbol   // for function source it will be a nil

	SourceType AddrSourceType
}

func (*Addr) String

func (a *Addr) String() string

type AddrCoverage

type AddrCoverage []*CoveragePart

AddrCoverage is a list of AddrPos, describe the coverage of the address space

func MergeAndCleanCoverage added in v0.2.4

func MergeAndCleanCoverage(coves []AddrCoverage) (AddrCoverage, error)

MergeAndCleanCoverage merge multiple AddrCoverage

type AddrPos

type AddrPos struct {
	Addr uint64
	Size uint64
	Type AddrType
}

func (*AddrPos) String added in v0.2.4

func (a *AddrPos) String() string

type AddrSourceType

type AddrSourceType = string
const (
	AddrSourceGoPclntab AddrSourceType = "pclntab"
	AddrSourceSymbol    AddrSourceType = "symbol"
	AddrSourceDisasm    AddrSourceType = "disasm"
	AddrSourceDwarf     AddrSourceType = "dwarf"
)

type AddrSpace

type AddrSpace map[uint64]*Addr

AddrSpace is a map of address to Addr

func MergeAddrSpace

func MergeAddrSpace(others ...AddrSpace) AddrSpace

func (AddrSpace) Get

func (a AddrSpace) Get(addr uint64) (ret *Addr, ok bool)

func (AddrSpace) Insert

func (a AddrSpace) Insert(addr *Addr)

func (AddrSpace) ToDirtyCoverage

func (a AddrSpace) ToDirtyCoverage() AddrCoverage

ToDirtyCoverage get the coverage of the current address space

type AddrType

type AddrType = string
const (
	AddrTypeUnknown AddrType = "unknown" // it exists, but should never be collected
	AddrTypeText    AddrType = "text"    // for text section
	AddrTypeData    AddrType = "data"    // data / rodata section
)

type Analyzer added in v1.3.14

type Analyzer = string
const (
	AnalyzerDwarf   Analyzer = "dwarf"
	AnalyzerDisasm  Analyzer = "disasm"
	AnalyzerSymbol  Analyzer = "symbol"
	AnalyzerPclntab Analyzer = "pclntab"
)

type CoveragePart

type CoveragePart struct {
	Pos   *AddrPos
	Addrs []*Addr
}

func (*CoveragePart) HasDisasm added in v1.3.5

func (c *CoveragePart) HasDisasm() bool

func (*CoveragePart) String added in v0.2.4

func (c *CoveragePart) String() string

type ErrAddrCoverageConflict

type ErrAddrCoverageConflict struct {
	Addr uint64
	Pos1 *CoveragePart
	Pos2 *CoveragePart
}

func (*ErrAddrCoverageConflict) Error

func (e *ErrAddrCoverageConflict) Error() string

type File

type File struct {
	FilePath  string      `json:"file_path"`
	Functions []*Function `json:"functions"`

	PkgName string `json:"-"`
}

func (*File) FullSize added in v1.0.0

func (f *File) FullSize() uint64

func (*File) PclnSize added in v1.0.0

func (f *File) PclnSize() uint64

type FuncType

type FuncType = string
const (
	FuncTypeFunction FuncType = "function"
	FuncTypeMethod   FuncType = "method"
)

type Function

type Function struct {
	Name     string   `json:"name"`
	Addr     uint64   `json:"addr"`
	CodeSize uint64   `json:"code_size"`
	Type     FuncType `json:"type"`
	Receiver string   `json:"receiver"` // only for methods

	PclnSize PclnSymbolSize `json:"pcln_size"`
	// contains filtered or unexported fields
}

func (*Function) Init added in v1.6.0

func (f *Function) Init()

func (*Function) Size

func (f *Function) Size() uint64

type KnownAddr

type KnownAddr struct {
	TextAddrSpace AddrSpace

	SymbolAddrSpace AddrSpace
	SymbolCoverage  AddrCoverage
	// contains filtered or unexported fields
}

func NewKnownAddr

func NewKnownAddr(sect *Store) *KnownAddr

func (*KnownAddr) BuildSymbolCoverage

func (f *KnownAddr) BuildSymbolCoverage()

func (*KnownAddr) InsertDisasm

func (f *KnownAddr) InsertDisasm(entry uint64, size uint64, fn *Function)

func (*KnownAddr) InsertSymbol

func (f *KnownAddr) InsertSymbol(symbol *Symbol, p *Package) *Addr

func (*KnownAddr) InsertSymbolFromDWARF added in v1.3.1

func (f *KnownAddr) InsertSymbolFromDWARF(symbol *Symbol, p *Package) *Addr

func (*KnownAddr) InsertTextFromDWARF added in v1.2.0

func (f *KnownAddr) InsertTextFromDWARF(entry uint64, size uint64, fn *Function)

func (*KnownAddr) InsertTextFromPclnTab added in v1.2.0

func (f *KnownAddr) InsertTextFromPclnTab(entry uint64, size uint64, fn *Function)

func (*KnownAddr) SymbolCovHas

func (f *KnownAddr) SymbolCovHas(entry uint64, size uint64) (AddrType, bool)

type Package

type Package struct {
	Name string      `json:"name"`
	Type PackageType `json:"type"`

	SubPackages PackageMap `json:"subPackages"`
	Files       []*File    `json:"files"`

	Size uint64 `json:"size"` // late filled

	// should not be used to calculate size,
	// since linker can create overlapped symbols.
	// relies on coverage.
	Symbols []*Symbol `json:"symbols"`
	// contains filtered or unexported fields
}

func NewPackage

func NewPackage() *Package

func NewPackageWithGorePackage

func NewPackageWithGorePackage(gp *gore.Package, name string, typ PackageType, pclntab *gosym.Table) *Package

func (*Package) AddFuncIfNotExists added in v1.2.0

func (p *Package) AddFuncIfNotExists(path string, fn *Function) bool

func (*Package) AddSymbol added in v0.2.4

func (p *Package) AddSymbol(symbol *Symbol, ap *Addr)

func (*Package) AssignPackageSize added in v0.2.4

func (p *Package) AssignPackageSize()

func (*Package) ClearCache added in v1.5.1

func (p *Package) ClearCache()

func (*Package) Functions added in v1.5.4

func (p *Package) Functions(yield func(*Function) bool)

func (*Package) GetDisasmAddrSpace added in v0.2.4

func (p *Package) GetDisasmAddrSpace() AddrSpace

func (*Package) GetFunctionSizeRecursive added in v0.2.4

func (p *Package) GetFunctionSizeRecursive() uint64

func (*Package) GetPackageCoverage added in v0.2.4

func (p *Package) GetPackageCoverage() AddrCoverage

func (*Package) Merge

func (p *Package) Merge(rp *Package)

Merge p always hold an empty subpackage

type PackageMap

type PackageMap map[string]*Package

type PackageType

type PackageType = string
const (
	PackageTypeMain      PackageType = "main"
	PackageTypeStd       PackageType = "std"
	PackageTypeVendor    PackageType = "vendor"
	PackageTypeGenerated PackageType = "generated"
	PackageTypeUnknown   PackageType = "unknown"
	PackageTypeCGO       PackageType = "cgo"
)

type PclnSymbolSize added in v0.4.0

type PclnSymbolSize struct {
	Name     uint64         `json:"name"`     // the function name size
	PCFile   uint64         `json:"pcfile"`   // the file name tab size
	PCSP     uint64         `json:"pcsp"`     // the pc to stack pointer table size
	PCLN     uint64         `json:"pcln"`     // the pc to line number table size
	Header   uint64         `json:"header"`   // the header size
	FuncData uint64         `json:"funcdata"` // the funcdata size
	PCData   map[string]int `json:"pcdata"`   // the pcdata size
}

PclnSymbolSize represents a pcln symbol sizes

func NewEmptyPclnSymbolSize added in v1.2.0

func NewEmptyPclnSymbolSize() PclnSymbolSize

func NewPclnSymbolSize added in v0.4.0

func NewPclnSymbolSize(s *gosym.Func) PclnSymbolSize

func (*PclnSymbolSize) Size added in v0.4.0

func (p *PclnSymbolSize) Size() uint64

type Section

type Section struct {
	Name string `json:"name"`

	Size     uint64 `json:"size"`
	FileSize uint64 `json:"file_size"`

	KnownSize uint64 `json:"known_size"`

	Offset uint64 `json:"offset"`
	End    uint64 `json:"end"`

	Addr    uint64 `json:"addr"`
	AddrEnd uint64 `json:"addr_end"`

	OnlyInMemory bool `json:"only_in_memory"`
	Debug        bool `json:"debug"`

	ContentType SectionContentType `json:"-"`
}

type SectionContentType added in v1.6.0

type SectionContentType int
const (
	SectionContentOther SectionContentType = iota
	SectionContentText
	SectionContentData
)

type Store added in v1.6.0

type Store struct {
	Sections          map[string]*Section
	DataSectionsCache []AddrPos
	TextSectionsCache []AddrPos
}

func NewStore added in v1.6.0

func NewStore() *Store

func (*Store) AssertSize added in v1.6.0

func (s *Store) AssertSize(size uint64) error

func (*Store) BuildCache added in v1.6.0

func (s *Store) BuildCache()

func (*Store) FindSection added in v1.6.0

func (s *Store) FindSection(addr, size uint64) *Section

func (*Store) IsData added in v1.6.0

func (s *Store) IsData(addr, size uint64) bool

func (*Store) IsText added in v1.6.0

func (s *Store) IsText(addr, size uint64) bool

func (*Store) IsType added in v1.6.0

func (s *Store) IsType(addr, size uint64, t AddrType) bool

type Symbol added in v0.2.4

type Symbol struct {
	Name string   `json:"name"`
	Addr uint64   `json:"addr"`
	Size uint64   `json:"size"`
	Type AddrType `json:"type"`
}

func NewSymbol added in v0.2.4

func NewSymbol(name string, addr, size uint64, typ AddrType) *Symbol

func (*Symbol) String added in v0.2.4

func (s *Symbol) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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