Linux Perf
bpf-prologue.c File Reference
#include <bpf/libbpf.h>
#include "perf.h"
#include "debug.h"
#include "bpf-loader.h"
#include "bpf-prologue.h"
#include "probe-finder.h"
#include <errno.h>
#include <dwarf-regs.h>
#include <linux/filter.h>
Include dependency graph for bpf-prologue.c:

Go to the source code of this file.

Classes

struct  bpf_insn_pos
 

Macros

#define BPF_REG_SIZE   8
 
#define JMP_TO_ERROR_CODE   -1
 
#define JMP_TO_SUCCESS_CODE   -2
 
#define JMP_TO_USER_CODE   -3
 
#define ins(i, p)   append_insn((i), (p))
 

Functions

static int pos_get_cnt (struct bpf_insn_pos *pos)
 
static int append_insn (struct bpf_insn new_insn, struct bpf_insn_pos *pos)
 
static int check_pos (struct bpf_insn_pos *pos)
 
static int argtype_to_ldx_size (const char *type)
 
static const char * insn_sz_to_str (int insn_sz)
 
static int gen_ldx_reg_from_ctx (struct bpf_insn_pos *pos, int ctx_reg, const char *reg, int target_reg)
 
static int gen_read_mem (struct bpf_insn_pos *pos, int src_base_addr_reg, int dst_addr_reg, long offset)
 
static int gen_prologue_fastpath (struct bpf_insn_pos *pos, struct probe_trace_arg *args, int nargs)
 
static int gen_prologue_slowpath (struct bpf_insn_pos *pos, struct probe_trace_arg *args, int nargs)
 
static int prologue_relocate (struct bpf_insn_pos *pos, struct bpf_insn *error_code, struct bpf_insn *success_code, struct bpf_insn *user_code)
 
int bpf__gen_prologue (struct probe_trace_arg *args, int nargs, struct bpf_insn *new_prog, size_t *new_cnt, size_t cnt_space)
 

Macro Definition Documentation

◆ BPF_REG_SIZE

#define BPF_REG_SIZE   8

Definition at line 20 of file bpf-prologue.c.

◆ ins

#define ins (   i,
 
)    append_insn((i), (p))

Definition at line 103 of file bpf-prologue.c.

◆ JMP_TO_ERROR_CODE

#define JMP_TO_ERROR_CODE   -1

Definition at line 22 of file bpf-prologue.c.

◆ JMP_TO_SUCCESS_CODE

#define JMP_TO_SUCCESS_CODE   -2

Definition at line 23 of file bpf-prologue.c.

◆ JMP_TO_USER_CODE

#define JMP_TO_USER_CODE   -3

Definition at line 24 of file bpf-prologue.c.

Function Documentation

◆ append_insn()

static int append_insn ( struct bpf_insn  new_insn,
struct bpf_insn_pos pos 
)
static

Definition at line 39 of file bpf-prologue.c.

◆ argtype_to_ldx_size()

static int argtype_to_ldx_size ( const char *  type)
static

Definition at line 68 of file bpf-prologue.c.

◆ bpf__gen_prologue()

int bpf__gen_prologue ( struct probe_trace_arg args,
int  nargs,
struct bpf_insn *  new_prog,
size_t *  new_cnt,
size_t  cnt_space 
)

Definition at line 358 of file bpf-prologue.c.

Here is the call graph for this function:

◆ check_pos()

static int check_pos ( struct bpf_insn_pos pos)
static

Definition at line 55 of file bpf-prologue.c.

◆ gen_ldx_reg_from_ctx()

static int gen_ldx_reg_from_ctx ( struct bpf_insn_pos pos,
int  ctx_reg,
const char *  reg,
int  target_reg 
)
static

Definition at line 112 of file bpf-prologue.c.

Here is the call graph for this function:

◆ gen_prologue_fastpath()

static int gen_prologue_fastpath ( struct bpf_insn_pos pos,
struct probe_trace_arg args,
int  nargs 
)
static

Definition at line 182 of file bpf-prologue.c.

Here is the call graph for this function:

◆ gen_prologue_slowpath()

static int gen_prologue_slowpath ( struct bpf_insn_pos pos,
struct probe_trace_arg args,
int  nargs 
)
static

Definition at line 241 of file bpf-prologue.c.

Here is the call graph for this function:

◆ gen_read_mem()

static int gen_read_mem ( struct bpf_insn_pos pos,
int  src_base_addr_reg,
int  dst_addr_reg,
long  offset 
)
static

Definition at line 142 of file bpf-prologue.c.

Here is the call graph for this function:

◆ insn_sz_to_str()

static const char* insn_sz_to_str ( int  insn_sz)
static

Definition at line 86 of file bpf-prologue.c.

◆ pos_get_cnt()

static int pos_get_cnt ( struct bpf_insn_pos pos)
inlinestatic

Definition at line 33 of file bpf-prologue.c.

◆ prologue_relocate()

static int prologue_relocate ( struct bpf_insn_pos pos,
struct bpf_insn *  error_code,
struct bpf_insn *  success_code,
struct bpf_insn *  user_code 
)
static

Definition at line 319 of file bpf-prologue.c.

Here is the call graph for this function: