interpreter

package
v0.0.0-...-0958f0d Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LruFunctionCacheSize is the LRU size for caching functions for an interpreter.
	// This should reflect the number of hot functions that are seen often in a trace.
	LruFunctionCacheSize = 1024

	// UnknownSourceFile is the source file name to use when the real one is not available
	UnknownSourceFile = "<unknown>"

	// TopLevelFunctionName is the name to be used when a function does not have a name,
	// but we can deduce that it is at the highest possible scope (e.g for top-level PHP code)
	TopLevelFunctionName = "<top-level>"
)

Variables

View Source
var (
	ErrMismatchInterpreterType = errors.New("mismatched interpreter type")
)

Functions

This section is empty.

Types

type Data

type Data interface {
	// Attach checks if the given dso is supported, and loads the information
	// of it to the ebpf maps.
	Attach(ebpf EbpfHandler, pid libpf.PID, bias libpf.Address, rm remotememory.RemoteMemory) (
		Instance, error)
}

Data is the interface to operate on per-ELF DSO data.

type EbpfHandler

type EbpfHandler interface {
	// UpdateInterpreterOffsets adds the given offsetRanges to the eBPF map interpreter_offsets.
	UpdateInterpreterOffsets(ebpfProgIndex uint16, fileID host.FileID,
		offsetRanges []util.Range) error

	// UpdateProcData adds the given interpreter data to the named eBPF map.
	UpdateProcData(typ libpf.InterpreterType, pid libpf.PID, data unsafe.Pointer) error

	// DeleteProcData removes any data from the named eBPF map.
	DeleteProcData(typ libpf.InterpreterType, pid libpf.PID) error

	// UpdatePidInterpreterMapping updates the eBPF map pid_page_to_mapping_info
	// to call given interpreter unwinder.
	UpdatePidInterpreterMapping(libpf.PID, lpm.Prefix, uint8, host.FileID, uint64) error

	// DeletePidInterpreterMapping removes the element specified by pid, prefix
	// rom the eBPF map pid_page_to_mapping_info.
	DeletePidInterpreterMapping(libpf.PID, lpm.Prefix) error
}

EbpfHandler provides the functionality for interpreters to interact with eBPF maps.

type Instance

type Instance interface {
	// Detach removes any information from the ebpf maps. The pid is given as argument so
	// simple interpreters can use the global Data also as the Instance implementation.
	Detach(ebpf EbpfHandler, pid libpf.PID) error

	// SynchronizeMappings is called when the processmanager has reread process memory
	// mappings. Interpreters not needing to process these events can simply ignore them
	// by just returning a nil.
	SynchronizeMappings(ebpf EbpfHandler, symbolReporter reporter.SymbolReporter,
		pr process.Process, mappings []process.Mapping) error

	// UpdateTSDInfo is called when the process C-library Thread Specific Data related
	// introspection data has been updated.
	UpdateTSDInfo(ebpf EbpfHandler, pid libpf.PID, info tpbase.TSDInfo) error

	// Symbolize requests symbolization of the given frame, and dispatches this symbolization
	// to the collection agent. The frame's contents (frame type, file ID and line number)
	// are appended to newTrace.
	Symbolize(symbolReporter reporter.SymbolReporter, frame *host.Frame,
		trace *libpf.Trace) error

	// GetAndResetMetrics collects the metrics from the Instance and resets
	// the counters to their initial value.
	GetAndResetMetrics() ([]metrics.Metric, error)
}

Instance is the interface to operate on per-PID data.

type InstanceStubs

type InstanceStubs struct {
}

InstanceStubs provides empty implementations of Instance hooks that are not mandatory for a Instance implementation.

func (*InstanceStubs) GetAndResetMetrics

func (is *InstanceStubs) GetAndResetMetrics() ([]metrics.Metric, error)

func (*InstanceStubs) Symbolize

func (*InstanceStubs) SynchronizeMappings

func (*InstanceStubs) UpdateTSDInfo

func (is *InstanceStubs) UpdateTSDInfo(EbpfHandler, libpf.PID, tpbase.TSDInfo) error

type Loader

type Loader func(ebpf EbpfHandler, info *LoaderInfo) (Data, error)

Loader is a function to detect and load data from given interpreter ELF file. ProcessManager will call each configured Loader in order to see if additional handling and data is needed to unwind interpreter frames.

A Loader can return one of the following value combinations:

  • `nil, nil`, indicating that it didn't detect the interpreter to belong to it
  • `data, nil`, indicating that it wants to handle the executable
  • `nil, error`, indicating that a permanent failure occurred during interpreter detection

type LoaderInfo

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

LoaderInfo contains information about an ELF that is passed to the interpreter loaders.

func NewLoaderInfo

func NewLoaderInfo(fileID host.FileID, elfRef *pfelf.Reference, gaps []util.Range) *LoaderInfo

NewLoaderInfo returns a populated LoaderInfo struct.

func (*LoaderInfo) FileID

func (i *LoaderInfo) FileID() host.FileID

FileID returns the fileID element of the LoaderInfo struct.

func (*LoaderInfo) FileName

func (i *LoaderInfo) FileName() string

FileName returns the fileName element of the LoaderInfo struct.

func (*LoaderInfo) Gaps

func (i *LoaderInfo) Gaps() []util.Range

Gaps returns the gaps for the executable of this LoaderInfo.

func (*LoaderInfo) GetELF

func (i *LoaderInfo) GetELF() (*pfelf.File, error)

GetELF returns and caches a *pfelf.File for this LoaderInfo.

func (*LoaderInfo) GetSymbolAsRanges

func (i *LoaderInfo) GetSymbolAsRanges(symbol libpf.SymbolName) ([]util.Range, error)

GetSymbolAsRanges returns the normalized virtual address ranges for the named symbol

Directories

Path Synopsis
Package apmint implements a pseudo interpreter handler that detects APM agent libraries, establishes socket connections with them and notifies them about the stack traces that we collected for their process.
Package apmint implements a pseudo interpreter handler that detects APM agent libraries, establishes socket connections with them and notifies them about the stack traces that we collected for their process.

Jump to

Keyboard shortcuts

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