Documentation ¶
Index ¶
- Constants
- Variables
- func GetTSSKey(pid uint32, version Version, offsets *UserOffsets, ...) (int32, error)
- func LoadPerf() (*ebpf.CollectionSpec, error)
- func LoadPerfObjects(obj interface{}, opts *ebpf.CollectionOptions) error
- func PythonString(tok []int8, typ *PerfPyStrType) string
- type GlibcOffsets
- type LazySymbols
- type MuslOffsets
- type Perf
- func (s *Perf) CollectEvents(buf []*PerfPyEvent) []*PerfPyEvent
- func (s *Perf) FindProc(pid uint32) *Proc
- func (s *Perf) GetLazySymbols() *LazySymbols
- func (s *Perf) GetSymbols(svcReason string) (map[uint32]*PerfPySymbol, error)
- func (s *Perf) NewProc(pid uint32, data *PerfPyPidData, options *symtab.SymbolOptions, ...) (*Proc, error)
- func (s *Perf) RemoveDeadPID(pid uint32)
- type PerfGlobalConfigT
- type PerfLibc
- type PerfMapSpecs
- type PerfMaps
- type PerfObjects
- type PerfProgramSpecs
- type PerfPrograms
- type PerfPyEvent
- type PerfPyOffsetConfig
- type PerfPyPidData
- type PerfPySampleStateT
- type PerfPyStrType
- type PerfPySymbol
- type PerfSampleKey
- type PerfSpecs
- type Proc
- type ProcInfo
- type PyError
- type PyStrType
- type StackStatus
- type UserOffsets
- type Version
Constants ¶
const MapNameSymbols = "py_symbols"
Variables ¶
var Py310 = &Version{Major: 3, Minor: 10}
var Py311 = &Version{Major: 3, Minor: 11}
var Py312 = &Version{Major: 3, Minor: 12}
var Py313 = &Version{Major: 3, Minor: 13}
var Py37 = &Version{Major: 3, Minor: 7}
Functions ¶
func GetTSSKey ¶
func GetTSSKey(pid uint32, version Version, offsets *UserOffsets, autoTLSkeyAddr, pyRuntime uint64, libc *PerfLibc) (int32, error)
todo split offsets validation and offset usage into separate routines
func LoadPerf ¶
func LoadPerf() (*ebpf.CollectionSpec, error)
LoadPerf returns the embedded CollectionSpec for Perf.
func LoadPerfObjects ¶
func LoadPerfObjects(obj interface{}, opts *ebpf.CollectionOptions) error
LoadPerfObjects loads Perf and converts it into a struct.
The following types are suitable as obj argument:
*PerfObjects *PerfPrograms *PerfMaps
See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func PythonString ¶
func PythonString(tok []int8, typ *PerfPyStrType) string
Types ¶
type GlibcOffsets ¶
type LazySymbols ¶
type LazySymbols struct {
// contains filtered or unexported fields
}
LazySymbols tries to reuse a map from previous profile collection. If found a new symbols, then full dump ( GetSymbols ) is performed.
func (*LazySymbols) GetSymbol ¶
func (s *LazySymbols) GetSymbol(symID uint32, svc string) (*PerfPySymbol, error)
type MuslOffsets ¶
type Perf ¶
type Perf struct {
// contains filtered or unexported fields
}
func (*Perf) CollectEvents ¶
func (s *Perf) CollectEvents(buf []*PerfPyEvent) []*PerfPyEvent
func (*Perf) GetLazySymbols ¶
func (s *Perf) GetLazySymbols() *LazySymbols
func (*Perf) GetSymbols ¶
func (s *Perf) GetSymbols(svcReason string) (map[uint32]*PerfPySymbol, error)
func (*Perf) NewProc ¶
func (s *Perf) NewProc(pid uint32, data *PerfPyPidData, options *symtab.SymbolOptions, serviceName string) (*Proc, error)
func (*Perf) RemoveDeadPID ¶
type PerfGlobalConfigT ¶
type PerfLibc ¶
type PerfMapSpecs ¶
type PerfMapSpecs struct { Counts *ebpf.MapSpec `ebpf:"counts"` PyPidConfig *ebpf.MapSpec `ebpf:"py_pid_config"` PyProgs *ebpf.MapSpec `ebpf:"py_progs"` PyStateHeap *ebpf.MapSpec `ebpf:"py_state_heap"` PySymbols *ebpf.MapSpec `ebpf:"py_symbols"` PythonStacks *ebpf.MapSpec `ebpf:"python_stacks"` Stacks *ebpf.MapSpec `ebpf:"stacks"` }
PerfMapSpecs contains maps before they are loaded into the kernel.
It can be passed ebpf.CollectionSpec.Assign.
type PerfMaps ¶
type PerfMaps struct { Counts *ebpf.Map `ebpf:"counts"` PyPidConfig *ebpf.Map `ebpf:"py_pid_config"` PyProgs *ebpf.Map `ebpf:"py_progs"` PyStateHeap *ebpf.Map `ebpf:"py_state_heap"` PySymbols *ebpf.Map `ebpf:"py_symbols"` PythonStacks *ebpf.Map `ebpf:"python_stacks"` Stacks *ebpf.Map `ebpf:"stacks"` }
PerfMaps contains all maps after they have been loaded into the kernel.
It can be passed to LoadPerfObjects or ebpf.CollectionSpec.LoadAndAssign.
type PerfObjects ¶
type PerfObjects struct { PerfPrograms PerfMaps }
PerfObjects contains all objects after they have been loaded into the kernel.
It can be passed to LoadPerfObjects or ebpf.CollectionSpec.LoadAndAssign.
func (*PerfObjects) Close ¶
func (o *PerfObjects) Close() error
type PerfProgramSpecs ¶
type PerfProgramSpecs struct { PyperfCollect *ebpf.ProgramSpec `ebpf:"pyperf_collect"` ReadPythonStack *ebpf.ProgramSpec `ebpf:"read_python_stack"` }
PerfSpecs contains programs before they are loaded into the kernel.
It can be passed ebpf.CollectionSpec.Assign.
type PerfPrograms ¶
type PerfPrograms struct { PyperfCollect *ebpf.Program `ebpf:"pyperf_collect"` ReadPythonStack *ebpf.Program `ebpf:"read_python_stack"` }
PerfPrograms contains all programs after they have been loaded into the kernel.
It can be passed to LoadPerfObjects or ebpf.CollectionSpec.LoadAndAssign.
func (*PerfPrograms) Close ¶
func (p *PerfPrograms) Close() error
type PerfPyEvent ¶
type PerfPyEvent struct { K PerfSampleKey StackLen uint32 Stack [96]uint32 // contains filtered or unexported fields }
type PerfPyOffsetConfig ¶
type PerfPyOffsetConfig struct { PyThreadStateFrame int16 PyThreadStateCframe int16 PyCFrameCurrentFrame int16 PyCodeObjectCoFilename int16 PyCodeObjectCoName int16 PyCodeObjectCoVarnames int16 PyCodeObjectCoLocalsplusnames int16 PyCodeObjectCoCell2arg int16 PyCodeObjectCoCellvars int16 PyCodeObjectCoNlocals int16 PyTupleObjectObItem int16 PyVarObjectObSize int16 PyObjectObType int16 PyTypeObjectTpName int16 VFrameCode int16 VFramePrevious int16 VFrameLocalsplus int16 PyInterpreterFrameOwner int16 PyASCIIObjectSize int16 PyCompactUnicodeObjectSize int16 PyCellObjectObRef int16 Base uint64 PyCellType uint64 // contains filtered or unexported fields }
type PerfPyPidData ¶
type PerfPyPidData struct { Offsets PerfPyOffsetConfig Version struct { Major uint32 Minor uint32 Patch uint32 } Libc PerfLibc TssKey int32 CollectKernel uint8 // contains filtered or unexported fields }
func GetPyPerfPidData ¶
type PerfPySampleStateT ¶
type PerfPySampleStateT struct { SymbolCounter int64 Offsets PerfPyOffsetConfig CurCpu uint32 FramePtr uint64 PythonStackProgCallCnt int64 Sym PerfPySymbol Event PerfPyEvent Padding uint64 // contains filtered or unexported fields }
type PerfPyStrType ¶
type PerfPySymbol ¶
type PerfPySymbol struct { Classname [32]int8 Name [64]int8 File [128]int8 ClassnameType PerfPyStrType NameType PerfPyStrType FileType PerfPyStrType Padding PerfPyStrType }
type PerfSampleKey ¶
type PerfSpecs ¶
type PerfSpecs struct { PerfProgramSpecs PerfMapSpecs }
PerfSpecs contains maps and programs before they are loaded into the kernel.
It can be passed ebpf.CollectionSpec.Assign.
type Proc ¶
type Proc struct { PerfPyPidData *PerfPyPidData SymbolOptions *symtab.SymbolOptions }
type ProcInfo ¶
type PyError ¶
type PyError uint8
var ( PyErrorGeneric PyError = 1 PyErrorThreadState PyError = 2 PyErrorThreadStateNull PyError = 3 PyErrorTopFrame PyError = 4 PyErrorFrameCode PyError = 5 PyErrorFramePrev PyError = 6 PyErrorSymbol PyError = 7 PyErrorTlsbase PyError = 8 PyErrorFirstArg PyError = 9 PyErrorClassName PyError = 10 PyErrorFileName PyError = 11 PyErrorName PyError = 12 )
type StackStatus ¶
type StackStatus uint8
var ( StackStatusComplete StackStatus = 0 StackStatusError StackStatus = 1 StackStatusTruncated StackStatus = 2 )
func (StackStatus) String ¶
func (s StackStatus) String() string
type UserOffsets ¶
type UserOffsets struct { PyVarObject_ob_size int16 PyObject_ob_type int16 PyTypeObject_tp_name int16 PyThreadState_frame int16 PyThreadState_cframe int16 PyThreadState_current_frame int16 PyCFrame_current_frame int16 PyFrameObject_f_back int16 PyFrameObject_f_code int16 PyFrameObject_f_localsplus int16 PyCodeObject_co_filename int16 PyCodeObject_co_name int16 PyCodeObject_co_varnames int16 PyCodeObject_co_localsplusnames int16 PyCodeObject__co_cell2arg int16 PyCodeObject__co_cellvars int16 PyCodeObject__co_nlocals int16 PyTupleObject_ob_item int16 PyInterpreterFrame_f_code int16 PyInterpreterFrame_f_executable int16 PyInterpreterFrame_previous int16 PyInterpreterFrame_localsplus int16 PyInterpreterFrame_owner int16 PyRuntimeState_gilstate int16 PyRuntimeState_autoTSSkey int16 Gilstate_runtime_state_autoTSSkey int16 PyTssT_is_initialized int16 PyTssT_key int16 PyTssTSize int16 PyASCIIObjectSize int16 PyCompactUnicodeObjectSize int16 PyCellObject__ob_ref int16 }
UserOffsets keeps Python offsets which are then partially passed to ebpf with ProfilePyOffsetConfig
func GetUserOffsets ¶
func GetUserOffsets(version Version) (*UserOffsets, bool, error)
type Version ¶
type Version struct {
Major, Minor, Patch int
}
func GetGlibcVersionFromFile ¶
func GetMuslVersionFromFile ¶
func GetMuslVersionFromReader ¶
GetMuslVersionFromReader return minor musl version. For example 1 for 1.1.44 and 2 for 1.2.4
func GetPythonPatchVersion ¶
GetPythonPatchVersion searches for a patch version given a major + minor version with regexp r is libpython3.11.so or python3.11 elf binary