bpfbacktracer

package
v0.0.0-...-835e807 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GCoreSamlesMapName = "gcored_samples"
	FramesNumber       = 4
)

Variables

This section is empty.

Functions

func LoadBacktracesMap

func LoadBacktracesMap() (*ebpf.Map, error)

func LoadBacktracesMapFromPath

func LoadBacktracesMapFromPath(path string) (*ebpf.Map, error)

Types

type Backtrace

type Backtrace struct {
	Vaddrs [FramesNumber]uint64
}

func (*Backtrace) UnmarshalBinary

func (b *Backtrace) UnmarshalBinary(buf []byte) error

type BpfBacktracer

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

func NewBPFBacktracer

func NewBPFBacktracer() (*BpfBacktracer, error)
TODO: use bpf2go to generate a program
BCC version of a program:

prog.c ``` #include <uapi/linux/ptrace.h> #include <linux/sched.h>

struct data_t {
    u64 stacks[4];
};

BPF_HASH(gcored_samples, u32, struct data_t, 128);

void trace_stack(struct pt_regs *ctx) {
    u32 pid = bpf_get_current_pid_tgid();
    struct data_t data = {};
    u64 ret = bpf_get_stack(ctx, data.stacks, sizeof(data.stacks), BPF_F_USER_STACK);
    if (ret > 0) {
        gcored_samples.update(&pid, &data);
    }
}

```

NewBPFBacktracer creates a BPF Backtracer struct that allocates map, prog and attaches kprobe.

func (*BpfBacktracer) Close

func (b *BpfBacktracer) Close() error

type Key

type Key uint32

Jump to

Keyboard shortcuts

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