python

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Code generated by glibc_dwarfdump. DO NOT EDIT.

Code generated by musl_dwarfdump. DO NOT EDIT.

Code generated by python_dwarfdump. DO NOT EDIT.

Index

Constants

View Source
const MapNameSymbols = "py_symbols"

Variables

View Source
var Py310 = &Version{Major: 3, Minor: 10}
View Source
var Py311 = &Version{Major: 3, Minor: 11}
View Source
var Py312 = &Version{Major: 3, Minor: 12}
View Source
var Py313 = &Version{Major: 3, Minor: 13}
View Source
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 GlibcOffsets struct {
	PthreadSpecific1stblock int16
	PthreadSize             int16
	PthreadKeyDataData      int16
	PthreadKeyDataSize      int16
}

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 MuslOffsets struct {
	PthreadTsd  int16
	PthreadSize int16
}

type Perf

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

func NewPerf

func NewPerf(logger log.Logger, metrics *metrics.PythonMetrics, pidDataHasMap *ebpf.Map, symbolsHashMap *ebpf.Map) (*Perf, error)

func (*Perf) CollectEvents

func (s *Perf) CollectEvents(buf []*PerfPyEvent) []*PerfPyEvent

func (*Perf) FindProc

func (s *Perf) FindProc(pid uint32) *Proc

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

func (s *Perf) RemoveDeadPID(pid uint32)

type PerfGlobalConfigT

type PerfGlobalConfigT struct {
	BpfLogErr   uint8
	BpfLogDebug uint8

	NsPidIno uint64
	// contains filtered or unexported fields
}

type PerfLibc

type PerfLibc struct {
	Musl bool

	PthreadSize             int16
	PthreadSpecific1stblock int16
	// contains filtered or unexported fields
}

func GetGlibcOffsets

func GetGlibcOffsets(version Version) (PerfLibc, bool, error)

func GetLibc

func GetLibc(l log2.Logger, pid uint32, info ProcInfo) (PerfLibc, error)

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.

func (*PerfMaps) Close

func (m *PerfMaps) Close() error

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

func GetPyPerfPidData(l log.Logger, pid uint32, collectKernel bool) (*PerfPyPidData, error)

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 PerfPyStrType struct {
	Type           uint8
	SizeCodepoints uint8
}

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 PerfSampleKey struct {
	Pid       uint32
	Flags     uint32
	KernStack int64
	UserStack int64
}

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 ProcInfo struct {
	Version       Version
	PythonMaps    []*symtab.ProcMap
	LibPythonMaps []*symtab.ProcMap
	Musl          []*symtab.ProcMap
	Glibc         []*symtab.ProcMap
}

func GetProcInfo

func GetProcInfo(s *bufio.Scanner) (ProcInfo, error)

GetProcInfo parses /proc/pid/map of a python process.

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
)

func (PyError) String

func (e PyError) String() string

type PyStrType

type PyStrType uint8
var (
	PyStrType1Byte      PyStrType = 1
	PyStrType2Byte      PyStrType = 2
	PyStrType4Byte      PyStrType = 4
	PyStrTypeAscii      PyStrType = 8
	PyStrTypeUtf8       PyStrType = 16
	PyStrTypeNotCompact PyStrType = 32
)

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 GetGlibcVersionFromFile(f string) (Version, error)

func GetGlibcVersionFromReader

func GetGlibcVersionFromReader(r io.Reader) (Version, error)

func GetMuslVersionFromFile

func GetMuslVersionFromFile(f string) (Version, error)

func GetMuslVersionFromReader

func GetMuslVersionFromReader(r io.Reader) (Version, error)

GetMuslVersionFromReader return minor musl version. For example 1 for 1.1.44 and 2 for 1.2.4

func GetPythonPatchVersion

func GetPythonPatchVersion(r io.Reader, v Version) (Version, error)

GetPythonPatchVersion searches for a patch version given a major + minor version with regexp r is libpython3.11.so or python3.11 elf binary

func (*Version) Compare

func (p *Version) Compare(other *Version) int

func (*Version) String

func (p *Version) String() string

Jump to

Keyboard shortcuts

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