symtab

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSymbolOptions = &SymbolOptions{
	GoTableFallback: false,
}

Functions

This section is empty.

Types

type CacheOptions

type CacheOptions struct {
	PidCacheOptions      GCacheOptions
	BuildIDCacheOptions  GCacheOptions
	SameFileCacheOptions GCacheOptions
}

type ElfCache

type ElfCache struct {
	BuildIDCache  *GCache[elf.BuildID, SymbolNameResolver]
	SameFileCache *GCache[Stat, SymbolNameResolver]
}

func NewElfCache

func NewElfCache(buildIDCacheOptions GCacheOptions, sameFileCacheOptions GCacheOptions) (*ElfCache, error)

func (*ElfCache) CacheByBuildID

func (e *ElfCache) CacheByBuildID(buildID elf.BuildID, v SymbolNameResolver)

func (*ElfCache) CacheByStat

func (e *ElfCache) CacheByStat(s Stat, v SymbolNameResolver)

func (*ElfCache) Cleanup

func (e *ElfCache) Cleanup()

func (*ElfCache) DebugInfo

func (e *ElfCache) DebugInfo() ElfCacheDebugInfo

func (*ElfCache) GetSymbolsByBuildID

func (e *ElfCache) GetSymbolsByBuildID(buildID elf.BuildID) SymbolNameResolver

func (*ElfCache) GetSymbolsByStat

func (e *ElfCache) GetSymbolsByStat(s Stat) SymbolNameResolver

func (*ElfCache) NextRound

func (e *ElfCache) NextRound()

func (*ElfCache) Update

func (e *ElfCache) Update(buildIDCacheOptions GCacheOptions, sameFileCacheOptions GCacheOptions)

type ElfCacheDebugInfo

type ElfCacheDebugInfo struct {
	BuildIDCache  GCacheDebugInfo[elf.SymTabDebugInfo] `alloy:"build_id_cache,attr,optional" river:"build_id_cache,attr,optional"`
	SameFileCache GCacheDebugInfo[elf.SymTabDebugInfo] `alloy:"same_file_cache,attr,optional" river:"same_file_cache,attr,optional"`
}

type ElfDebugInfo

type ElfDebugInfo struct {
	SymbolsCount int    `alloy:"symbols_count,attr,optional" river:"symbols_count,attr,optional"`
	File         string `alloy:"file,attr,optional" river:"file,attr,optional"`
}

type ElfTable

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

func NewElfTable

func NewElfTable(logger log.Logger, procMap *ProcMap, fs string, elfFilePath string, options ElfTableOptions) *ElfTable

func (*ElfTable) Cleanup

func (et *ElfTable) Cleanup()

func (*ElfTable) DebugInfo

func (et *ElfTable) DebugInfo() elf2.SymTabDebugInfo

func (*ElfTable) Resolve

func (et *ElfTable) Resolve(pc uint64) string

type ElfTableOptions

type ElfTableOptions struct {
	ElfCache      *ElfCache
	Metrics       *metrics.SymtabMetrics
	SymbolOptions *SymbolOptions
}

type GCache

type GCache[K comparable, V Resource] struct {
	// contains filtered or unexported fields
}

func NewGCache

func NewGCache[K comparable, V Resource](options GCacheOptions) (*GCache[K, V], error)

func (*GCache[K, V]) Cache

func (g *GCache[K, V]) Cache(k K, v V)

func (*GCache[K, V]) Cleanup

func (g *GCache[K, V]) Cleanup()

func (*GCache[K, V]) Each

func (g *GCache[K, V]) Each(f func(k K, v V, round int))

func (*GCache[K, V]) EachLRU

func (g *GCache[K, V]) EachLRU(f func(k K, v V, round int))

func (*GCache[K, V]) EachRound

func (g *GCache[K, V]) EachRound(f func(k K, v V, round int))

func (*GCache[K, V]) Get

func (g *GCache[K, V]) Get(k K) V

func (*GCache[K, V]) LRUSize

func (g *GCache[K, V]) LRUSize() int

func (*GCache[K, V]) NextRound

func (g *GCache[K, V]) NextRound()

func (*GCache[K, V]) Remove

func (g *GCache[K, V]) Remove(k K)

func (*GCache[K, V]) RoundSize

func (g *GCache[K, V]) RoundSize() int

func (*GCache[K, V]) Update

func (g *GCache[K, V]) Update(options GCacheOptions)

type GCacheDebugInfo

type GCacheDebugInfo[T any] struct {
	LRUSize      int `alloy:"lru_size,attr,optional" river:"lru_size,attr,optional"`
	RoundSize    int `alloy:"round_size,attr,optional" river:"round_size,attr,optional"`
	CurrentRound int `alloy:"current_round,attr,optional" river:"current_round,attr,optional"`
	LRUDump      []T `alloy:"lru_dump,block,optional" river:"lru_dump,block,optional"`
	RoundDump    []T `alloy:"round_dump,block,optional" river:"round_dump,block,optional"`
}

func DebugInfo

func DebugInfo[K comparable, V Resource, D any](g *GCache[K, V], ff func(K, V, int) D) GCacheDebugInfo[D]

type GCacheOptions

type GCacheOptions struct {
	Size       int
	KeepRounds int
}

type PidKey

type PidKey uint32

type ProcMap

type ProcMap struct {
	// The start address of current mapping.
	StartAddr uint64
	// The end address of the current mapping
	EndAddr uint64
	// The permissions for this mapping
	Perms *ProcMapPermissions
	// The current offset into the file/fd (e.g., shared libs)
	Offset int64
	// Device owner of this mapping (major:minor) in Mkdev format.
	Dev uint64
	// The inode of the device above
	Inode uint64
	// The file or psuedofile (or empty==anonymous)
	Pathname string
}

ProcMap contains the process memory-mappings of the process read from `/proc/[pid]/maps`.

func FindLastRXMap added in v0.4.2

func FindLastRXMap(maps []*ProcMap) *ProcMap

func FindReadableMap added in v0.4.2

func FindReadableMap(maps []*ProcMap) *ProcMap

FindReadableMap return a map entry that is readable and not writable or nil

func ParseProcMapLine added in v0.3.0

func ParseProcMapLine(line []byte, executableOnly bool) (*ProcMap, error)

ParseProcMapLine will attempt to parse a single line within a proc/[pid]/maps buffer. 7f5822ebe000-7f5822ec0000 r--p 00000000 09:00 533429 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 returns nil if entry is not executable

func ParseProcMapsExecutableModules added in v0.3.0

func ParseProcMapsExecutableModules(procMaps []byte, executableOnly bool) ([]*ProcMap, error)

func (*ProcMap) String added in v0.4.2

func (p *ProcMap) String() string

type ProcMapPermissions

type ProcMapPermissions struct {
	// mapping has the [R]ead flag set
	Read bool
	// mapping has the [W]rite flag set
	Write bool
	// mapping has the [X]ecutable flag set
	Execute bool
	// mapping has the [S]hared flag set
	Shared bool
	// mapping is marked as [P]rivate (copy on write)
	Private bool
}

ProcMapPermissions contains permission settings read from `/proc/[pid]/maps`.

func (*ProcMapPermissions) String added in v0.4.2

func (p *ProcMapPermissions) String() string

type ProcMaps added in v0.4.2

type ProcMaps []*ProcMap

func (ProcMaps) String added in v0.4.2

func (p ProcMaps) String() string

type ProcTable

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

func NewProcTable

func NewProcTable(logger log.Logger, options ProcTableOptions) *ProcTable

func (*ProcTable) Cleanup

func (p *ProcTable) Cleanup()

func (*ProcTable) DebugInfo

func (p *ProcTable) DebugInfo() ProcTableDebugInfo

func (*ProcTable) Error added in v0.3.0

func (p *ProcTable) Error() error

func (*ProcTable) Pid added in v0.3.0

func (p *ProcTable) Pid() int

func (*ProcTable) Refresh

func (p *ProcTable) Refresh()

func (*ProcTable) Resolve

func (p *ProcTable) Resolve(pc uint64) Symbol

type ProcTableDebugInfo

type ProcTableDebugInfo struct {
	ElfTables     map[string]elf.SymTabDebugInfo `alloy:"elfs,block,optional" river:"elfs,block,optional"`
	Size          int                            `alloy:"size,attr,optional" river:"size,attr,optional"`
	Pid           int                            `alloy:"pid,attr,optional" river:"pid,attr,optional"`
	LastUsedRound int                            `alloy:"last_used_round,attr,optional" river:"last_used_round,attr,optional"`
}

type ProcTableOptions

type ProcTableOptions struct {
	Pid int
	ElfTableOptions
}

type Resource

type Resource interface {
	Refresh()
	Cleanup()
}

type Stat

type Stat struct {
	Dev   uint64
	Inode uint64
}

type Symbol

type Symbol struct {
	Start  uint64
	Name   string
	Module string
}

type SymbolCache

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

SymbolCache is responsible for resolving PC address to Symbol maintaining a pid -> ProcTable cache resolving kernel symbols

func NewSymbolCache

func NewSymbolCache(logger log.Logger, options CacheOptions, metrics *metrics.SymtabMetrics) (*SymbolCache, error)

func (*SymbolCache) Cleanup

func (sc *SymbolCache) Cleanup()

func (*SymbolCache) ElfCacheDebugInfo

func (sc *SymbolCache) ElfCacheDebugInfo() ElfCacheDebugInfo

func (*SymbolCache) GetKallsyms added in v0.3.0

func (sc *SymbolCache) GetKallsyms() SymbolTable

func (*SymbolCache) GetProcTableCached added in v0.4.2

func (sc *SymbolCache) GetProcTableCached(pid PidKey) *ProcTable

func (*SymbolCache) NewProcTable added in v0.4.2

func (sc *SymbolCache) NewProcTable(pid PidKey, symbolOptions *SymbolOptions) *ProcTable

func (*SymbolCache) NextRound

func (sc *SymbolCache) NextRound()

func (*SymbolCache) PidCacheDebugInfo

func (sc *SymbolCache) PidCacheDebugInfo() GCacheDebugInfo[ProcTableDebugInfo]

func (*SymbolCache) RemoveDeadPID added in v0.3.0

func (sc *SymbolCache) RemoveDeadPID(pid PidKey)

func (*SymbolCache) UpdateOptions

func (sc *SymbolCache) UpdateOptions(options CacheOptions)

type SymbolNameResolver

type SymbolNameResolver interface {
	Refresh()
	Cleanup()
	DebugInfo() elf.SymTabDebugInfo
	IsDead() bool
	Resolve(addr uint64) string
}

type SymbolOptions added in v0.2.1

type SymbolOptions struct {
	GoTableFallback    bool
	PythonFullFilePath bool
	DemangleOptions    []demangle.Option
}

type SymbolTab

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

func NewKallsyms

func NewKallsyms() (*SymbolTab, error)

func NewKallsymsFromData added in v0.2.1

func NewKallsymsFromData(kallsyms []byte) (*SymbolTab, error)

func NewKallsymsFromFile added in v0.2.1

func NewKallsymsFromFile(f string) (*SymbolTab, error)

func NewSymbolTab

func NewSymbolTab(symbols []Symbol) *SymbolTab

func (*SymbolTab) Cleanup

func (t *SymbolTab) Cleanup()

func (*SymbolTab) DebugString

func (t *SymbolTab) DebugString() string

func (*SymbolTab) Rebase

func (t *SymbolTab) Rebase(base uint64)

func (*SymbolTab) Refresh

func (t *SymbolTab) Refresh()

func (*SymbolTab) Resolve

func (t *SymbolTab) Resolve(addr uint64) Symbol

type SymbolTable

type SymbolTable interface {
	Refresh()
	Cleanup()
	Resolve(addr uint64) Symbol
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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