python

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Code generated by python_dwarfdump. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var Py311 = &Version{Major: 3, Minor: 11}
View Source
var Py312 = &Version{Major: 3, Minor: 12}
View Source
var Py37 = &Version{Major: 3, Minor: 7}

Functions

func GetMuslVersionFromFile

func GetMuslVersionFromFile(f string) (int, error)

func GetMuslVersionFromReader

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

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

func GetTSSKey

func GetTSSKey(pid uint32, version Version, offsets *UserOffsets, autoTLSkeyAddr, pyRuntime uint64) (int32, error)

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 ReadPyEvent

func ReadPyEvent(raw []byte, event *PerfPyEvent) error

Types

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 Perf

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

func NewPerf

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

func (*Perf) Close

func (s *Perf) Close()

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) RemoveDeadPID

func (s *Perf) RemoveDeadPID(pid uint32)

func (*Perf) StartPythonProfiling

func (s *Perf) StartPythonProfiling(pid uint32, data *PerfPyPidData, serviceName string) error

type PerfMapSpecs

type PerfMapSpecs struct {
	PyEvents    *ebpf.MapSpec `ebpf:"py_events"`
	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"`
	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 {
	PyEvents    *ebpf.Map `ebpf:"py_events"`
	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"`
	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 {
	StackStatus uint8
	Err         uint8
	Reserved2   uint8
	Reserved3   uint8
	Pid         uint32
	KernStack   int64
	StackLen    uint32
	Stack       [75]uint32
}

type PerfPyOffsetConfig

type PerfPyOffsetConfig struct {
	PyThreadStateFrame            int16
	PyThreadStateCframe           int16
	PyCFrameCurrentFrame          int16
	PyCodeObjectCoFilename        int16
	PyCodeObjectCoName            int16
	PyCodeObjectCoVarnames        int16
	PyCodeObjectCoLocalsplusnames int16
	PyTupleObjectObItem           int16
	PyVarObjectObSize             int16
	PyObjectObType                int16
	PyTypeObjectTpName            int16
	VFrameCode                    int16
	VFramePrevious                int16
	VFrameLocalsplus              int16
	StringSize                    int16
}

type PerfPyPidData

type PerfPyPidData struct {
	Offsets PerfPyOffsetConfig

	Version struct {
		Major uint32
		Minor uint32
		Patch uint32
	}
	Musl uint8

	TssKey int32
	// contains filtered or unexported fields
}

func GetPyPerfPidData

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

type PerfPySampleStateT

type PerfPySampleStateT struct {
	SymbolCounter int64
	Offsets       PerfPyOffsetConfig

	CurCpu uint32

	FramePtr               uint64
	PythonStackProgCallCnt int64
	Event                  PerfPyEvent
	// contains filtered or unexported fields
}

type PerfPySymbol

type PerfPySymbol struct {
	Classname [32]int8
	Name      [64]int8
	File      [128]int8
}

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 ProcInfo

type ProcInfo struct {
	Version       Version
	PythonMaps    []*symtab.ProcMap
	LibPythonMaps []*symtab.ProcMap
	Musl          []*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 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
	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
	PyTupleObject_ob_item             int16
	PyInterpreterFrame_f_code         int16
	PyInterpreterFrame_previous       int16
	PyInterpreterFrame_localsplus     int16
	PyRuntimeState_gilstate           int16
	PyRuntimeState_autoTSSkey         int16
	Gilstate_runtime_state_autoTSSkey int16
	PyTssT_is_initialized             int16
	PyTssT_key                        int16
	PyTssTSize                        int16
	StringSize                        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 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

Jump to

Keyboard shortcuts

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