Linux Perf
symbol.c File Reference
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <linux/kernel.h>
#include <linux/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>
#include "annotate.h"
#include "build-id.h"
#include "util.h"
#include "debug.h"
#include "machine.h"
#include "symbol.h"
#include "strlist.h"
#include "intlist.h"
#include "namespaces.h"
#include "header.h"
#include "path.h"
#include "sane_ctype.h"
#include <elf.h>
#include <limits.h>
#include <symbol/kallsyms.h>
#include <sys/utsname.h>
Include dependency graph for symbol.c:

Go to the source code of this file.

Classes

struct  module_info
 
struct  kcore_mapfn_data
 

Macros

#define DSO_BINARY_TYPE__SYMTAB_CNT   ARRAY_SIZE(binary_type_symtab)
 

Functions

static int dso__load_kernel_sym (struct dso *dso, struct map *map)
 
static int dso__load_guest_kernel_sym (struct dso *dso, struct map *map)
 
static bool symbol__is_idle (const char *name)
 
static bool symbol_type__filter (char symbol_type)
 
static int prefix_underscores_count (const char *str)
 
const char *__weak arch__normalize_symbol_name (const char *name)
 
int __weak arch__compare_symbol_names (const char *namea, const char *nameb)
 
int __weak arch__compare_symbol_names_n (const char *namea, const char *nameb, unsigned int n)
 
int __weak arch__choose_best_symbol (struct symbol *syma, struct symbol *symb __maybe_unused)
 
static int choose_best_symbol (struct symbol *syma, struct symbol *symb)
 
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)
 
struct symbolsymbol__new (u64 start, u64 len, u8 binding, u8 type, const char *name)
 
void symbol__delete (struct symbol *sym)
 
void symbols__delete (struct rb_root *symbols)
 
void __symbols__insert (struct rb_root *symbols, struct symbol *sym, bool kernel)
 
void symbols__insert (struct rb_root *symbols, struct symbol *sym)
 
static struct symbolsymbols__find (struct rb_root *symbols, u64 ip)
 
static struct symbolsymbols__first (struct rb_root *symbols)
 
static struct symbolsymbols__last (struct rb_root *symbols)
 
static struct symbolsymbols__next (struct symbol *sym)
 
static void symbols__insert_by_name (struct rb_root *symbols, struct symbol *sym)
 
static void symbols__sort_by_name (struct rb_root *symbols, struct rb_root *source)
 
int symbol__match_symbol_name (const char *name, const char *str, enum symbol_tag_include includes)
 
static struct symbolsymbols__find_by_name (struct rb_root *symbols, const char *name, enum symbol_tag_include includes)
 
void dso__reset_find_symbol_cache (struct dso *dso)
 
void dso__insert_symbol (struct dso *dso, struct symbol *sym)
 
struct symboldso__find_symbol (struct dso *dso, u64 addr)
 
struct symboldso__first_symbol (struct dso *dso)
 
struct symboldso__last_symbol (struct dso *dso)
 
struct symboldso__next_symbol (struct symbol *sym)
 
struct symbolsymbol__next_by_name (struct symbol *sym)
 
struct symboldso__find_symbol_by_name (struct dso *dso, const char *name)
 
void dso__sort_by_name (struct dso *dso)
 
int modules__parse (const char *filename, void *arg, int(*process_module)(void *arg, const char *name, u64 start, u64 size))
 
static int map__process_kallsym_symbol (void *arg, const char *name, char type, u64 start)
 
static int dso__load_all_kallsyms (struct dso *dso, const char *filename)
 
static int map_groups__split_kallsyms_for_kcore (struct map_groups *kmaps, struct dso *dso)
 
static int map_groups__split_kallsyms (struct map_groups *kmaps, struct dso *dso, u64 delta, struct map *initial_map)
 
bool symbol__restricted_filename (const char *filename, const char *restricted_filename)
 
static void add_module (struct module_info *mi, struct rb_root *modules)
 
static void delete_modules (struct rb_root *modules)
 
static struct module_infofind_module (const char *name, struct rb_root *modules)
 
static int __read_proc_modules (void *arg, const char *name, u64 start, u64 size __maybe_unused)
 
static int read_proc_modules (const char *filename, struct rb_root *modules)
 
int compare_proc_modules (const char *from, const char *to)
 
struct mapmap_groups__first (struct map_groups *mg)
 
static int do_validate_kcore_modules (const char *filename, struct map_groups *kmaps)
 
static bool filename_from_kallsyms_filename (char *filename, const char *base_name, const char *kallsyms_filename)
 
static int validate_kcore_modules (const char *kallsyms_filename, struct map *map)
 
static int validate_kcore_addresses (const char *kallsyms_filename, struct map *map)
 
static int kcore_mapfn (u64 start, u64 len, u64 pgoff, void *data)
 
static int dso__load_kcore (struct dso *dso, struct map *map, const char *kallsyms_filename)
 
static int kallsyms__delta (struct kmap *kmap, const char *filename, u64 *delta)
 
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)
 
static int dso__load_perf_map (const char *map_path, struct dso *dso)
 
static bool dso__is_compatible_symtab_type (struct dso *dso, bool kmod, enum dso_binary_type type)
 
static int dso__find_perf_map (char *filebuf, size_t bufsz, struct nsinfo **nsip)
 
int dso__load (struct dso *dso, struct map *map)
 
struct mapmap_groups__find_by_name (struct map_groups *mg, const char *name)
 
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)
 
static bool visible_dir_filter (const char *name, struct dirent *d)
 
static int find_matching_kcore (struct map *map, char *dir, size_t dir_sz)
 
static bool filename__readable (const char *file)
 
static char * dso__find_kallsyms (struct dso *dso, struct map *map)
 
static void vmlinux_path__exit (void)
 
static int vmlinux_path__add (const char *new_entry)
 
static int vmlinux_path__init (struct perf_env *env)
 
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)
 
static bool symbol__read_kptr_restrict (void)
 
int symbol__annotation_init (void)
 
int symbol__init (struct perf_env *env)
 
void symbol__exit (void)
 
int symbol__config_symfs (const struct option *opt __maybe_unused, const char *dir, int unset __maybe_unused)
 
struct mem_infomem_info__get (struct mem_info *mi)
 
void mem_info__put (struct mem_info *mi)
 
struct mem_infomem_info__new (void)
 

Variables

int vmlinux_path__nr_entries
 
char ** vmlinux_path
 
struct symbol_conf symbol_conf
 
static enum dso_binary_type binary_type_symtab []
 
static const char *const vmlinux_paths []
 
static const char *const vmlinux_paths_upd []
 

Macro Definition Documentation

◆ DSO_BINARY_TYPE__SYMTAB_CNT

#define DSO_BINARY_TYPE__SYMTAB_CNT   ARRAY_SIZE(binary_type_symtab)

Definition at line 71 of file symbol.c.

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:

◆ __read_proc_modules()

static int __read_proc_modules ( void *  arg,
const char *  name,
u64  start,
u64 size  __maybe_unused 
)
static

Definition at line 950 of file symbol.c.

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:

◆ add_module()

static void add_module ( struct module_info mi,
struct rb_root *  modules 
)
static

Definition at line 896 of file symbol.c.

◆ arch__choose_best_symbol()

int __weak arch__choose_best_symbol ( struct symbol syma,
struct symbol *symb  __maybe_unused 
)

Definition at line 105 of file symbol.c.

◆ arch__compare_symbol_names()

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

Definition at line 94 of file symbol.c.

◆ arch__compare_symbol_names_n()

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

Definition at line 99 of file symbol.c.

◆ arch__normalize_symbol_name()

const char* __weak arch__normalize_symbol_name ( const char *  name)

Definition at line 89 of file symbol.c.

Here is the call graph for this function:

◆ choose_best_symbol()

static int choose_best_symbol ( struct symbol syma,
struct symbol symb 
)
static

Definition at line 117 of file symbol.c.

Here is the call graph for this function:

◆ 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:

◆ delete_modules()

static void delete_modules ( struct rb_root *  modules)
static

Definition at line 914 of file symbol.c.

Here is the call graph for this function:

◆ do_validate_kcore_modules()

static int do_validate_kcore_modules ( const char *  filename,
struct map_groups kmaps 
)
static

Definition at line 1032 of file symbol.c.

Here is the call graph for this function:

◆ dso__find_kallsyms()

static char* dso__find_kallsyms ( struct dso dso,
struct map map 
)
static

Definition at line 1808 of file symbol.c.

Here is the call graph for this function:

◆ dso__find_perf_map()

static int dso__find_perf_map ( char *  filebuf,
size_t  bufsz,
struct nsinfo **  nsip 
)
static

Definition at line 1455 of file symbol.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__is_compatible_symtab_type()

static bool dso__is_compatible_symtab_type ( struct dso dso,
bool  kmod,
enum dso_binary_type  type 
)
static

Definition at line 1406 of file symbol.c.

◆ 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_all_kallsyms()

static int dso__load_all_kallsyms ( struct dso dso,
const char *  filename 
)
static

Definition at line 673 of file symbol.c.

Here is the call graph for this function:

◆ dso__load_guest_kernel_sym()

static int dso__load_guest_kernel_sym ( struct dso dso,
struct map map 
)
static

Definition at line 1927 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_kcore()

static int dso__load_kcore ( struct dso dso,
struct map map,
const char *  kallsyms_filename 
)
static

Definition at line 1154 of file symbol.c.

Here is the call graph for this function:

◆ dso__load_kernel_sym()

static int dso__load_kernel_sym ( struct dso dso,
struct map map 
)
static

Definition at line 1866 of file symbol.c.

Here is the call graph for this function:

◆ dso__load_perf_map()

static int dso__load_perf_map ( const char *  map_path,
struct dso dso 
)
static

Definition at line 1349 of file symbol.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__reset_find_symbol_cache()

void dso__reset_find_symbol_cache ( struct dso dso)

Definition at line 478 of file symbol.c.

◆ dso__sort_by_name()

void dso__sort_by_name ( struct dso dso)

Definition at line 542 of file symbol.c.

Here is the call graph for this function:

◆ filename__readable()

static bool filename__readable ( const char *  file)
static

Definition at line 1799 of file symbol.c.

◆ filename_from_kallsyms_filename()

static bool filename_from_kallsyms_filename ( char *  filename,
const char *  base_name,
const char *  kallsyms_filename 
)
static

Definition at line 1071 of file symbol.c.

◆ find_matching_kcore()

static int find_matching_kcore ( struct map map,
char *  dir,
size_t  dir_sz 
)
static

Definition at line 1768 of file symbol.c.

Here is the call graph for this function:

◆ find_module()

static struct module_info* find_module ( const char *  name,
struct rb_root *  modules 
)
static

Definition at line 928 of file symbol.c.

◆ kallsyms__delta()

static int kallsyms__delta ( struct kmap kmap,
const char *  filename,
u64 *  delta 
)
static

Definition at line 1297 of file symbol.c.

Here is the call graph for this function:

◆ kcore_mapfn()

static int kcore_mapfn ( u64  start,
u64  len,
u64  pgoff,
void *  data 
)
static

Definition at line 1137 of file symbol.c.

Here is the call graph for this function:

◆ map__process_kallsym_symbol()

static int map__process_kallsym_symbol ( void *  arg,
const char *  name,
char  type,
u64  start 
)
static

Definition at line 641 of file symbol.c.

Here is the call graph for this function:

◆ map_groups__find_by_name()

struct map* map_groups__find_by_name ( struct map_groups mg,
const char *  name 
)

Definition at line 1679 of file symbol.c.

Here is the call graph for this function:

◆ map_groups__first()

struct map* map_groups__first ( struct map_groups mg)

Definition at line 1027 of file symbol.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:

◆ map_groups__split_kallsyms()

static int map_groups__split_kallsyms ( struct map_groups kmaps,
struct dso dso,
u64  delta,
struct map initial_map 
)
static

Definition at line 729 of file symbol.c.

Here is the call graph for this function:

◆ map_groups__split_kallsyms_for_kcore()

static int map_groups__split_kallsyms_for_kcore ( struct map_groups kmaps,
struct dso dso 
)
static

Definition at line 678 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:

◆ prefix_underscores_count()

static int prefix_underscores_count ( const char *  str)
static

Definition at line 79 of file symbol.c.

Here is the call graph for this function:

◆ read_proc_modules()

static int read_proc_modules ( const char *  filename,
struct rb_root *  modules 
)
static

Definition at line 973 of file symbol.c.

Here is the call graph for this function:

◆ 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__exit()

void symbol__exit ( void  )

Definition at line 2189 of file symbol.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__is_idle()

static bool symbol__is_idle ( const char *  name)
static

Definition at line 614 of file symbol.c.

◆ symbol__match_symbol_name()

int symbol__match_symbol_name ( const char *  name,
const char *  str,
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__read_kptr_restrict()

static bool symbol__read_kptr_restrict ( void  )
static

Definition at line 2078 of file symbol.c.

◆ 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_type__filter()

static bool symbol_type__filter ( char  symbol_type)
static

Definition at line 73 of file symbol.c.

◆ 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__find()

static struct symbol* symbols__find ( struct rb_root *  symbols,
u64  ip 
)
static

Definition at line 333 of file symbol.c.

◆ symbols__find_by_name()

static struct symbol* symbols__find_by_name ( struct rb_root *  symbols,
const char *  name,
enum symbol_tag_include  includes 
)
static

Definition at line 434 of file symbol.c.

Here is the call graph for this function:

◆ symbols__first()

static struct symbol* symbols__first ( struct rb_root *  symbols)
static

Definition at line 356 of file symbol.c.

◆ 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:

◆ symbols__insert_by_name()

static void symbols__insert_by_name ( struct rb_root *  symbols,
struct symbol sym 
)
static

Definition at line 386 of file symbol.c.

◆ symbols__last()

static struct symbol* symbols__last ( struct rb_root *  symbols)
static

Definition at line 366 of file symbol.c.

◆ symbols__next()

static struct symbol* symbols__next ( struct symbol sym)
static

Definition at line 376 of file symbol.c.

◆ symbols__sort_by_name()

static void symbols__sort_by_name ( struct rb_root *  symbols,
struct rb_root *  source 
)
static

Definition at line 406 of file symbol.c.

Here is the call graph for this function:

◆ validate_kcore_addresses()

static int validate_kcore_addresses ( const char *  kallsyms_filename,
struct map map 
)
static

Definition at line 1111 of file symbol.c.

Here is the call graph for this function:

◆ validate_kcore_modules()

static int validate_kcore_modules ( const char *  kallsyms_filename,
struct map map 
)
static

Definition at line 1092 of file symbol.c.

Here is the call graph for this function:

◆ visible_dir_filter()

static bool visible_dir_filter ( const char *  name,
struct dirent *  d 
)
static

Definition at line 1761 of file symbol.c.

Here is the call graph for this function:

◆ vmlinux_path__add()

static int vmlinux_path__add ( const char *  new_entry)
static

Definition at line 1996 of file symbol.c.

◆ vmlinux_path__exit()

static void vmlinux_path__exit ( void  )
static

Definition at line 1974 of file symbol.c.

◆ vmlinux_path__init()

static int vmlinux_path__init ( struct perf_env env)
static

Definition at line 2006 of file symbol.c.

Here is the call graph for this function:

Variable Documentation

◆ binary_type_symtab

enum dso_binary_type binary_type_symtab[]
static

◆ symbol_conf

Initial value:
= {
.use_modules = true,
.try_vmlinux_path = true,
.demangle = true,
.demangle_kernel = false,
.cumulate_callchain = true,
.show_hist_headers = true,
.symfs = "",
.event_group = true,
.inline_name = true,
}

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.

◆ vmlinux_paths

const char* const vmlinux_paths[]
static
Initial value:
= {
"vmlinux",
"/boot/vmlinux"
}

Definition at line 1983 of file symbol.c.

◆ vmlinux_paths_upd

const char* const vmlinux_paths_upd[]
static
Initial value:
= {
"/boot/vmlinux-%s",
"/usr/lib/debug/boot/vmlinux-%s",
"/lib/modules/%s/build/vmlinux",
"/usr/lib/debug/lib/modules/%s/vmlinux",
"/usr/lib/debug/boot/vmlinux-%s.debug"
}

Definition at line 1988 of file symbol.c.