Linux Perf
symbol.h File Reference
#include <linux/types.h>
#include <stdbool.h>
#include <stdint.h>
#include "map.h"
#include "../perf.h"
#include <linux/list.h>
#include <linux/rbtree.h>
#include <stdio.h>
#include <byteswap.h>
#include <libgen.h>
#include "build-id.h"
#include "event.h"
#include "path.h"
#include <elf.h>
#include "dso.h"
Include dependency graph for symbol.h:

Go to the source code of this file.

Classes

struct  symbol
 
struct  symbol_conf
 
struct  symbol_name_rb_node
 
struct  ref_reloc_sym
 
struct  map_symbol
 
struct  addr_map_symbol
 
struct  branch_info
 
struct  mem_info
 
struct  addr_location
 
struct  symsrc
 
struct  kcore_extract
 
struct  sdt_note
 

Macros

#define PERF_ELF_C_READ_MMAP   ELF_C_READ
 
#define DMGL_NO_OPTS   0 /* For readability... */
 
#define DMGL_PARAMS   (1 << 0) /* Include function args */
 
#define DMGL_ANSI   (1 << 1) /* Include const, volatile, etc */
 
#define DSO__NAME_KALLSYMS   "[kernel.kallsyms]"
 
#define DSO__NAME_KCORE   "[kernel.kcore]"
 
#define symbols__for_each_entry(symbols, pos, nd)
 
#define symbol__join_symfs(bf, path)   __symbol__join_symfs(bf, sizeof(bf), path)
 
#define PERF_KCORE_EXTRACT   "/tmp/perf-kcore-XXXXXX"
 
#define SYMBOL_A   0
 
#define SYMBOL_B   1
 
#define SDT_BASE_SCN   ".stapsdt.base"
 
#define SDT_NOTE_SCN   ".note.stapsdt"
 
#define SDT_NOTE_TYPE   3
 
#define SDT_NOTE_NAME   "stapsdt"
 
#define NR_ADDR   3
 
#define mem_info__zput(mi)   __mem_info__zput(&mi)
 

Typedefs

typedef int(* mapfn_t) (u64 start, u64 len, u64 pgoff, void *data)
 

Enumerations

enum  symbol_tag_include { SYMBOL_TAG_INCLUDE__NONE = 0, SYMBOL_TAG_INCLUDE__DEFAULT_ONLY }
 

Functions

void symbol__delete (struct symbol *sym)
 
void symbols__delete (struct rb_root *symbols)
 
static size_t symbol__size (const struct symbol *sym)
 
static int __symbol__join_symfs (char *bf, size_t size, const char *path)
 
static void * symbol__priv (struct symbol *sym)
 
void symsrc__destroy (struct symsrc *ss)
 
int symsrc__init (struct symsrc *ss, struct dso *dso, const char *name, enum dso_binary_type type)
 
bool symsrc__has_symtab (struct symsrc *ss)
 
bool symsrc__possibly_runtime (struct symsrc *ss)
 
int dso__load (struct dso *dso, struct map *map)
 
int dso__load_vmlinux (struct dso *dso, struct map *map, const char *vmlinux, bool vmlinux_allocated)
 
int dso__load_vmlinux_path (struct dso *dso, struct map *map)
 
int __dso__load_kallsyms (struct dso *dso, const char *filename, struct map *map, bool no_kcore)
 
int dso__load_kallsyms (struct dso *dso, const char *filename, struct map *map)
 
void dso__insert_symbol (struct dso *dso, struct symbol *sym)
 
struct symboldso__find_symbol (struct dso *dso, u64 addr)
 
struct symboldso__find_symbol_by_name (struct dso *dso, const char *name)
 
struct symbolsymbol__next_by_name (struct symbol *sym)
 
struct symboldso__first_symbol (struct dso *dso)
 
struct symboldso__last_symbol (struct dso *dso)
 
struct symboldso__next_symbol (struct symbol *sym)
 
enum dso_type dso__type_fd (int fd)
 
int filename__read_build_id (const char *filename, void *bf, size_t size)
 
int sysfs__read_build_id (const char *filename, void *bf, size_t size)
 
int modules__parse (const char *filename, void *arg, int(*process_module)(void *arg, const char *name, u64 start, u64 size))
 
int filename__read_debuglink (const char *filename, char *debuglink, size_t size)
 
int symbol__init (struct perf_env *env)
 
void symbol__exit (void)
 
void symbol__elf_init (void)
 
int symbol__annotation_init (void)
 
struct symbolsymbol__new (u64 start, u64 len, u8 binding, u8 type, const char *name)
 
size_t __symbol__fprintf_symname_offs (const struct symbol *sym, const struct addr_location *al, bool unknown_as_addr, bool print_offsets, FILE *fp)
 
size_t symbol__fprintf_symname_offs (const struct symbol *sym, const struct addr_location *al, FILE *fp)
 
size_t __symbol__fprintf_symname (const struct symbol *sym, const struct addr_location *al, bool unknown_as_addr, FILE *fp)
 
size_t symbol__fprintf_symname (const struct symbol *sym, FILE *fp)
 
size_t symbol__fprintf (struct symbol *sym, FILE *fp)
 
bool symbol__restricted_filename (const char *filename, const char *restricted_filename)
 
int symbol__config_symfs (const struct option *opt __maybe_unused, const char *dir, int unset __maybe_unused)
 
int dso__load_sym (struct dso *dso, struct map *map, struct symsrc *syms_ss, struct symsrc *runtime_ss, int kmodule)
 
int dso__synthesize_plt_symbols (struct dso *dso, struct symsrc *ss)
 
char * dso__demangle_sym (struct dso *dso, int kmodule, const char *elf_name)
 
void __symbols__insert (struct rb_root *symbols, struct symbol *sym, bool kernel)
 
void symbols__insert (struct rb_root *symbols, struct symbol *sym)
 
void symbols__fixup_duplicate (struct rb_root *symbols)
 
void symbols__fixup_end (struct rb_root *symbols)
 
void map_groups__fixup_end (struct map_groups *mg)
 
int file__read_maps (int fd, bool exe, mapfn_t mapfn, void *data, bool *is_64_bit)
 
int kcore_extract__create (struct kcore_extract *kce)
 
void kcore_extract__delete (struct kcore_extract *kce)
 
int kcore_copy (const char *from_dir, const char *to_dir)
 
int compare_proc_modules (const char *from, const char *to)
 
int setup_list (struct strlist **list, const char *list_str, const char *list_name)
 
int setup_intlist (struct intlist **list, const char *list_str, const char *list_name)
 
const char * arch__normalize_symbol_name (const char *name)
 
int arch__compare_symbol_names (const char *namea, const char *nameb)
 
int arch__compare_symbol_names_n (const char *namea, const char *nameb, unsigned int n)
 
int arch__choose_best_symbol (struct symbol *syma, struct symbol *symb)
 
int symbol__match_symbol_name (const char *namea, const char *nameb, enum symbol_tag_include includes)
 
int get_sdt_note_list (struct list_head *head, const char *target)
 
int cleanup_sdt_note_list (struct list_head *sdt_notes)
 
int sdt_notes__get_count (struct list_head *start)
 
struct mem_infomem_info__new (void)
 
struct mem_infomem_info__get (struct mem_info *mi)
 
void mem_info__put (struct mem_info *mi)
 
static void __mem_info__zput (struct mem_info **mi)
 

Variables

struct symbol_conf symbol_conf
 
int vmlinux_path__nr_entries
 
char ** vmlinux_path
 

Macro Definition Documentation

◆ DMGL_ANSI

#define DMGL_ANSI   (1 << 1) /* Include const, volatile, etc */

Definition at line 45 of file symbol.h.

◆ DMGL_NO_OPTS

#define DMGL_NO_OPTS   0 /* For readability... */

Definition at line 43 of file symbol.h.

◆ DMGL_PARAMS

#define DMGL_PARAMS   (1 << 0) /* Include function args */

Definition at line 44 of file symbol.h.

◆ DSO__NAME_KALLSYMS

#define DSO__NAME_KALLSYMS   "[kernel.kallsyms]"

Definition at line 48 of file symbol.h.

◆ DSO__NAME_KCORE

#define DSO__NAME_KCORE   "[kernel.kcore]"

Definition at line 49 of file symbol.h.

◆ mem_info__zput

#define mem_info__zput (   mi)    __mem_info__zput(&mi)

Definition at line 398 of file symbol.h.

◆ NR_ADDR

#define NR_ADDR   3

Definition at line 386 of file symbol.h.

◆ PERF_ELF_C_READ_MMAP

#define PERF_ELF_C_READ_MMAP   ELF_C_READ

Definition at line 34 of file symbol.h.

◆ PERF_KCORE_EXTRACT

#define PERF_KCORE_EXTRACT   "/tmp/perf-kcore-XXXXXX"

Definition at line 321 of file symbol.h.

◆ SDT_BASE_SCN

#define SDT_BASE_SCN   ".stapsdt.base"

Definition at line 382 of file symbol.h.

◆ SDT_NOTE_NAME

#define SDT_NOTE_NAME   "stapsdt"

Definition at line 385 of file symbol.h.

◆ SDT_NOTE_SCN

#define SDT_NOTE_SCN   ".note.stapsdt"

Definition at line 383 of file symbol.h.

◆ SDT_NOTE_TYPE

#define SDT_NOTE_TYPE   3

Definition at line 384 of file symbol.h.

◆ symbol__join_symfs

#define symbol__join_symfs (   bf,
  path 
)    __symbol__join_symfs(bf, sizeof(bf), path)

Definition at line 163 of file symbol.h.

◆ SYMBOL_A

#define SYMBOL_A   0

Definition at line 349 of file symbol.h.

◆ SYMBOL_B

#define SYMBOL_B   1

Definition at line 350 of file symbol.h.

◆ symbols__for_each_entry

#define symbols__for_each_entry (   symbols,
  pos,
  nd 
)
Value:
for (nd = rb_first(symbols); \
nd && (pos = rb_entry(nd, struct symbol, rb_node)); \
nd = rb_next(nd))
Definition: symbol.h:55

Definition at line 78 of file symbol.h.

Typedef Documentation

◆ mapfn_t

typedef int(* mapfn_t) (u64 start, u64 len, u64 pgoff, void *data)

Definition at line 317 of file symbol.h.

Enumeration Type Documentation

◆ symbol_tag_include

Enumerator
SYMBOL_TAG_INCLUDE__NONE 
SYMBOL_TAG_INCLUDE__DEFAULT_ONLY 

Definition at line 357 of file symbol.h.

Function Documentation

◆ __dso__load_kallsyms()

int __dso__load_kallsyms ( struct dso dso,
const char *  filename,
struct map map,
bool  no_kcore 
)

Definition at line 1311 of file symbol.c.

Here is the call graph for this function:

◆ __mem_info__zput()

static void __mem_info__zput ( struct mem_info **  mi)
inlinestatic

Definition at line 392 of file symbol.h.

Here is the call graph for this function:

◆ __symbol__fprintf_symname()

size_t __symbol__fprintf_symname ( const struct symbol sym,
const struct addr_location al,
bool  unknown_as_addr,
FILE *  fp 
)

Definition at line 48 of file symbol_fprintf.c.

Here is the call graph for this function:

◆ __symbol__fprintf_symname_offs()

size_t __symbol__fprintf_symname_offs ( const struct symbol sym,
const struct addr_location al,
bool  unknown_as_addr,
bool  print_offsets,
FILE *  fp 
)

Definition at line 17 of file symbol_fprintf.c.

◆ __symbol__join_symfs()

static int __symbol__join_symfs ( char *  bf,
size_t  size,
const char *  path 
)
inlinestatic

Definition at line 158 of file symbol.h.

Here is the call graph for this function:

◆ __symbols__insert()

void __symbols__insert ( struct rb_root *  symbols,
struct symbol sym,
bool  kernel 
)

Definition at line 298 of file symbol.c.

Here is the call graph for this function:

◆ arch__choose_best_symbol()

int arch__choose_best_symbol ( struct symbol syma,
struct symbol symb 
)

◆ arch__compare_symbol_names()

int arch__compare_symbol_names ( const char *  namea,
const char *  nameb 
)

Definition at line 45 of file sym-handling.c.

◆ arch__compare_symbol_names_n()

int arch__compare_symbol_names_n ( const char *  namea,
const char *  nameb,
unsigned int  n 
)

Definition at line 56 of file sym-handling.c.

◆ arch__normalize_symbol_name()

const char* arch__normalize_symbol_name ( const char *  name)

Definition at line 68 of file sym-handling.c.

Here is the call graph for this function:

◆ cleanup_sdt_note_list()

int cleanup_sdt_note_list ( struct list_head *  sdt_notes)

◆ compare_proc_modules()

int compare_proc_modules ( const char *  from,
const char *  to 
)

Definition at line 986 of file symbol.c.

Here is the call graph for this function:

◆ dso__demangle_sym()

char* dso__demangle_sym ( struct dso dso,
int  kmodule,
const char *  elf_name 
)

Definition at line 398 of file symbol-elf.c.

Here is the call graph for this function:

◆ dso__find_symbol()

struct symbol* dso__find_symbol ( struct dso dso,
u64  addr 
)

Definition at line 496 of file symbol.c.

Here is the call graph for this function:

◆ dso__find_symbol_by_name()

struct symbol* dso__find_symbol_by_name ( struct dso dso,
const char *  name 
)

Definition at line 532 of file symbol.c.

Here is the call graph for this function:

◆ dso__first_symbol()

struct symbol* dso__first_symbol ( struct dso dso)

Definition at line 506 of file symbol.c.

Here is the call graph for this function:

◆ dso__insert_symbol()

void dso__insert_symbol ( struct dso dso,
struct symbol sym 
)

Definition at line 484 of file symbol.c.

Here is the call graph for this function:

◆ dso__last_symbol()

struct symbol* dso__last_symbol ( struct dso dso)

Definition at line 511 of file symbol.c.

Here is the call graph for this function:

◆ dso__load()

int dso__load ( struct dso dso,
struct map map 
)

Definition at line 1487 of file symbol.c.

Here is the call graph for this function:

◆ dso__load_kallsyms()

int dso__load_kallsyms ( struct dso dso,
const char *  filename,
struct map map 
)

Definition at line 1343 of file symbol.c.

Here is the call graph for this function:

◆ dso__load_sym()

int dso__load_sym ( struct dso dso,
struct map map,
struct symsrc syms_ss,
struct symsrc runtime_ss,
int  kmodule 
)

Definition at line 904 of file symbol-elf.c.

Here is the call graph for this function:

◆ dso__load_vmlinux()

int dso__load_vmlinux ( struct dso dso,
struct map map,
const char *  vmlinux,
bool  vmlinux_allocated 
)

Definition at line 1698 of file symbol.c.

Here is the call graph for this function:

◆ dso__load_vmlinux_path()

int dso__load_vmlinux_path ( struct dso dso,
struct map map 
)

Definition at line 1735 of file symbol.c.

Here is the call graph for this function:

◆ dso__next_symbol()

struct symbol* dso__next_symbol ( struct symbol sym)

Definition at line 516 of file symbol.c.

Here is the call graph for this function:

◆ dso__synthesize_plt_symbols()

int dso__synthesize_plt_symbols ( struct dso dso,
struct symsrc ss 
)

Definition at line 245 of file symbol-elf.c.

Here is the call graph for this function:

◆ dso__type_fd()

enum dso_type dso__type_fd ( int  fd)

Definition at line 1179 of file symbol-elf.c.

Here is the call graph for this function:

◆ file__read_maps()

int file__read_maps ( int  fd,
bool  exe,
mapfn_t  mapfn,
void *  data,
bool *  is_64_bit 
)

Definition at line 1160 of file symbol-elf.c.

Here is the call graph for this function:

◆ filename__read_build_id()

int filename__read_build_id ( const char *  filename,
void *  bf,
size_t  size 
)

Definition at line 487 of file symbol-elf.c.

Here is the call graph for this function:

◆ filename__read_debuglink()

int filename__read_debuglink ( const char *  filename,
char *  debuglink,
size_t  size 
)

Definition at line 565 of file symbol-elf.c.

Here is the call graph for this function:

◆ get_sdt_note_list()

int get_sdt_note_list ( struct list_head *  head,
const char *  target 
)

◆ kcore_copy()

int kcore_copy ( const char *  from_dir,
const char *  to_dir 
)

kcore_copy - copy kallsyms, modules and kcore from one directory to another. : from directory : to directory

This function copies kallsyms, modules and kcore files from one directory to another. kallsyms and modules are copied entirely. Only code segments are copied from kcore. It is assumed that two segments suffice: one for the kernel proper and one for all the modules. The code segments are determined from kallsyms and modules files. The kernel map starts at _stext or the lowest function symbol, and ends at _etext or the highest function symbol. The module map starts at the lowest module address and ends at the highest module symbol. Start addresses are rounded down to the nearest page. End addresses are rounded up to the nearest page. An extra page is added to the highest kernel symbol and highest module symbol to, hopefully, encompass that symbol too. Because it contains only code sections, the resulting kcore is unusual. One significant peculiarity is that the mapping (start -> pgoff) is not the same for the kernel map and the modules map. That happens because the data is copied adjacently whereas the original kcore has gaps. Finally, kallsyms and modules files are compared with their copies to check that modules have not been loaded or unloaded while the copies were taking place.

Return: %0 on success, %-1 on failure.

Definition at line 1818 of file symbol-elf.c.

Here is the call graph for this function:

◆ kcore_extract__create()

int kcore_extract__create ( struct kcore_extract kce)

Definition at line 1904 of file symbol-elf.c.

Here is the call graph for this function:

◆ kcore_extract__delete()

void kcore_extract__delete ( struct kcore_extract kce)

Definition at line 1944 of file symbol-elf.c.

Here is the call graph for this function:

◆ map_groups__fixup_end()

void map_groups__fixup_end ( struct map_groups mg)

Definition at line 223 of file symbol.c.

Here is the call graph for this function:

◆ mem_info__get()

struct mem_info* mem_info__get ( struct mem_info mi)

Definition at line 2228 of file symbol.c.

◆ mem_info__new()

struct mem_info* mem_info__new ( void  )

Definition at line 2241 of file symbol.c.

Here is the call graph for this function:

◆ mem_info__put()

void mem_info__put ( struct mem_info mi)

Definition at line 2235 of file symbol.c.

Here is the call graph for this function:

◆ modules__parse()

int modules__parse ( const char *  filename,
void *  arg,
int(*)(void *arg, const char *name, u64 start, u64 size process_module 
)

Definition at line 548 of file symbol.c.

Here is the call graph for this function:

◆ sdt_notes__get_count()

int sdt_notes__get_count ( struct list_head *  start)

◆ setup_intlist()

int setup_intlist ( struct intlist **  list,
const char *  list_str,
const char *  list_name 
)

Definition at line 2064 of file symbol.c.

Here is the call graph for this function:

◆ setup_list()

int setup_list ( struct strlist **  list,
const char *  list_str,
const char *  list_name 
)

Definition at line 2048 of file symbol.c.

Here is the call graph for this function:

◆ symbol__annotation_init()

int symbol__annotation_init ( void  )

Definition at line 2097 of file symbol.c.

◆ symbol__config_symfs()

int symbol__config_symfs ( const struct option *opt  __maybe_unused,
const char *  dir,
int unset  __maybe_unused 
)

Definition at line 2205 of file symbol.c.

Here is the call graph for this function:

◆ symbol__delete()

void symbol__delete ( struct symbol sym)

Definition at line 280 of file symbol.c.

Here is the call graph for this function:

◆ symbol__elf_init()

void symbol__elf_init ( void  )

Definition at line 2224 of file symbol-elf.c.

◆ symbol__exit()

void symbol__exit ( void  )

Definition at line 2189 of file symbol.c.

Here is the call graph for this function:

◆ symbol__fprintf()

size_t symbol__fprintf ( struct symbol sym,
FILE *  fp 
)

Definition at line 8 of file symbol_fprintf.c.

◆ symbol__fprintf_symname()

size_t symbol__fprintf_symname ( const struct symbol sym,
FILE *  fp 
)

Definition at line 55 of file symbol_fprintf.c.

Here is the call graph for this function:

◆ symbol__fprintf_symname_offs()

size_t symbol__fprintf_symname_offs ( const struct symbol sym,
const struct addr_location al,
FILE *  fp 
)

Definition at line 41 of file symbol_fprintf.c.

Here is the call graph for this function:

◆ symbol__init()

int symbol__init ( struct perf_env env)

Definition at line 2112 of file symbol.c.

Here is the call graph for this function:

◆ symbol__match_symbol_name()

int symbol__match_symbol_name ( const char *  namea,
const char *  nameb,
enum symbol_tag_include  includes 
)

Definition at line 417 of file symbol.c.

Here is the call graph for this function:

◆ symbol__new()

struct symbol* symbol__new ( u64  start,
u64  len,
u8  binding,
u8  type,
const char *  name 
)

Definition at line 251 of file symbol.c.

Here is the call graph for this function:

◆ symbol__next_by_name()

struct symbol* symbol__next_by_name ( struct symbol sym)

Definition at line 521 of file symbol.c.

◆ symbol__priv()

static void* symbol__priv ( struct symbol sym)
inlinestatic

Definition at line 168 of file symbol.h.

◆ symbol__restricted_filename()

bool symbol__restricted_filename ( const char *  filename,
const char *  restricted_filename 
)

Definition at line 872 of file symbol.c.

Here is the call graph for this function:

◆ symbol__size()

static size_t symbol__size ( const struct symbol sym)
inlinestatic

Definition at line 83 of file symbol.h.

◆ symbols__delete()

void symbols__delete ( struct rb_root *  symbols)

Definition at line 285 of file symbol.c.

Here is the call graph for this function:

◆ symbols__fixup_duplicate()

void symbols__fixup_duplicate ( struct rb_root *  symbols)

Definition at line 166 of file symbol.c.

Here is the call graph for this function:

◆ symbols__fixup_end()

void symbols__fixup_end ( struct rb_root *  symbols)

Definition at line 200 of file symbol.c.

◆ symbols__insert()

void symbols__insert ( struct rb_root *  symbols,
struct symbol sym 
)

Definition at line 328 of file symbol.c.

Here is the call graph for this function:

◆ symsrc__destroy()

void symsrc__destroy ( struct symsrc ss)

Definition at line 654 of file symbol-elf.c.

◆ symsrc__has_symtab()

bool symsrc__has_symtab ( struct symsrc ss)

Definition at line 649 of file symbol-elf.c.

◆ symsrc__init()

int symsrc__init ( struct symsrc ss,
struct dso dso,
const char *  name,
enum dso_binary_type  type 
)

Definition at line 666 of file symbol-elf.c.

Here is the call graph for this function:

◆ symsrc__possibly_runtime()

bool symsrc__possibly_runtime ( struct symsrc ss)

Definition at line 644 of file symbol-elf.c.

◆ sysfs__read_build_id()

int sysfs__read_build_id ( const char *  filename,
void *  bf,
size_t  size 
)

Definition at line 514 of file symbol-elf.c.

Here is the call graph for this function:

Variable Documentation

◆ symbol_conf

Definition at line 40 of file symbol.c.

◆ vmlinux_path

char** vmlinux_path

Definition at line 38 of file symbol.c.

◆ vmlinux_path__nr_entries

int vmlinux_path__nr_entries

Definition at line 37 of file symbol.c.