perf

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package perf contains logic to interact with the linux perf subsystem. The open_perf_event syscall ABI and debugfs logic is large enough to warrant its own package so as to not clutter up the gobpfld package. The functionality in this package will be used to attach kprobe, tracepoint, perf event, raw tracepoint and trancing programs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type bpfSyscall.PerfType
	// contains filtered or unexported fields
}

Event represents an linux perf event in userspace.

func OpenKProbeEvent

func OpenKProbeEvent(kprobeOpts KProbeOpts) (*Event, error)

func OpenTracepointEvent

func OpenTracepointEvent(category, name string) (*Event, error)

OpenTracepointEvent opens a perf event for an existing tracepoint. Tracepoint perf events can be used to to attach BPF_PROG_TYPE_TRACEPOINT applications to.

func OpenUProbeEvent

func OpenUProbeEvent(uprobeOpts UProbeOpts) (*Event, error)

func (*Event) AttachBPFProgram

func (e *Event) AttachBPFProgram(programFD bpfsys.BPFfd) error

AttachBPFProgram attach a loaded BPF program to the perf event.

func (*Event) DetachBPFProgram

func (e *Event) DetachBPFProgram() error

type FD

type FD uint32

func (FD) Close

func (fd FD) Close() error

Close closes a file descriptor

type KProbe

type KProbe struct {
	Name string
	ID   int
}

func (KProbe) Clear

func (kp KProbe) Clear() error

type KProbeOpts

type KProbeOpts struct {
	Type ProbeType
	// Group name. If omitted, use "kprobes" for it.
	Group string
	// Event name. If omitted, the event name is generated
	// based on SYM+offs or MEMADDR.
	Event string

	// Module name which has given Symbol.
	Module string
	// Symbol+Offset where the probe is inserted.
	Symbol string
}

type ProbeType

type ProbeType int
const (
	// TypeUnknown is the default value for the KProbeType
	TypeUnknown ProbeType = iota
	// TypeKProbe means a kprobe triggers on the beginning of a function/symbol
	TypeKProbe
	// TypeKRetprobe means a krprobe trigger on the end/return of a function/symbol
	TypeKRetprobe
	// TypeUProbe means a uprobe triggers on the beginning of a function/symbol
	TypeUProbe
	// TypeURetProbe means a uprobe trigger on the end/return of a function/symbol
	TypeURetProbe
)

type UProbe

type UProbe struct {
	Name string
	ID   int
}

func (UProbe) Clear

func (kp UProbe) Clear() error

type UProbeOpts

type UProbeOpts struct {
	Type ProbeType
	// Group name. If omitted, use "kprobes" for it.
	Group string
	// Event name. If omitted, the event name is generated
	// based on SYM+offs or MEMADDR.
	Event string

	// Path is the path to the executable to be probed.
	Path string
	// Offset of the address to be be probed.
	Offset int
}

Jump to

Keyboard shortcuts

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