Blame view
tools/perf/util/symbol.h
9.98 KB
8b40f521c
|
1 2 |
#ifndef __PERF_SYMBOL #define __PERF_SYMBOL 1 |
a2928c42a
|
3 4 |
#include <linux/types.h> |
e42049926
|
5 |
#include <stdbool.h> |
5aab621b7
|
6 7 |
#include <stdint.h> #include "map.h" |
b5387528f
|
8 |
#include "../perf.h" |
5da502585
|
9 |
#include <linux/list.h> |
43cbcd8ac
|
10 |
#include <linux/rbtree.h> |
5aab621b7
|
11 |
#include <stdio.h> |
8db4841fc
|
12 |
#include <byteswap.h> |
b771a8306
|
13 |
#include <libgen.h> |
4383db88a
|
14 |
#include "build-id.h" |
0776eb593
|
15 |
#include "event.h" |
9a3993d40
|
16 |
#include "path.h" |
a2928c42a
|
17 |
|
89fe808ae
|
18 |
#ifdef HAVE_LIBELF_SUPPORT |
b68e2f919
|
19 20 |
#include <libelf.h> #include <gelf.h> |
b68e2f919
|
21 |
#endif |
eec185ab6
|
22 |
#include <elf.h> |
b68e2f919
|
23 |
|
cdd059d73
|
24 |
#include "dso.h" |
84087126d
|
25 26 27 28 |
/* * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; * for newer versions we can use mmap to reduce memory usage: */ |
89fe808ae
|
29 |
#ifdef HAVE_LIBELF_MMAP_SUPPORT |
84087126d
|
30 |
# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP |
29a0fc9b2
|
31 32 |
#else # define PERF_ELF_C_READ_MMAP ELF_C_READ |
84087126d
|
33 |
#endif |
99ca42338
|
34 |
#ifdef HAVE_LIBELF_SUPPORT |
3938bad44
|
35 36 |
Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, GElf_Shdr *shp, const char *name, size_t *idx); |
99ca42338
|
37 |
#endif |
247648e37
|
38 |
#ifndef DMGL_PARAMS |
e71e79457
|
39 |
#define DMGL_NO_OPTS 0 /* For readability... */ |
247648e37
|
40 41 42 |
#define DMGL_PARAMS (1 << 0) /* Include function args */ #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ #endif |
0a77582f0
|
43 44 |
#define DSO__NAME_KALLSYMS "[kernel.kallsyms]" #define DSO__NAME_KCORE "[kernel.kcore]" |
171b3be9c
|
45 46 47 48 |
/** struct symbol - symtab entry * * @ignore - resolvable but tools ignore it (e.g. idle routines) */ |
a2928c42a
|
49 50 |
struct symbol { struct rb_node rb_node; |
9cffa8d53
|
51 52 |
u64 start; u64 end; |
fefb0b94b
|
53 |
u16 namelen; |
c408fedfc
|
54 |
u8 binding; |
b55cc4ed2
|
55 |
u8 idle:1; |
cdeb01bf7
|
56 |
u8 ignore:1; |
0b3c2264a
|
57 |
u8 arch_sym; |
a2928c42a
|
58 59 |
char name[0]; }; |
aeafcbaf4
|
60 |
void symbol__delete(struct symbol *sym); |
cdd059d73
|
61 |
void symbols__delete(struct rb_root *symbols); |
628ada0cb
|
62 |
|
eb948e508
|
63 64 65 66 67 68 69 70 71 72 |
/* symbols__for_each_entry - iterate over symbols (rb_root) * * @symbols: the rb_root of symbols * @pos: the 'struct symbol *' to use as a loop cursor * @nd: the 'struct rb_node *' to use as a temporary storage */ #define symbols__for_each_entry(symbols, pos, nd) \ for (nd = rb_first(symbols); \ nd && (pos = rb_entry(nd, struct symbol, rb_node)); \ nd = rb_next(nd)) |
1b2e2df4e
|
73 74 |
static inline size_t symbol__size(const struct symbol *sym) { |
2c241bd35
|
75 |
return sym->end - sym->start; |
1b2e2df4e
|
76 |
} |
655000e7c
|
77 |
struct strlist; |
e03eaa400
|
78 |
struct intlist; |
655000e7c
|
79 |
|
b32d133ae
|
80 81 |
struct symbol_conf { unsigned short priv_size; |
d04b35f80
|
82 |
unsigned short nr_events; |
b32d133ae
|
83 |
bool try_vmlinux_path, |
b01141f4f
|
84 |
init_annotation, |
2059fc7a5
|
85 |
force, |
fc2be6968
|
86 |
ignore_vmlinux, |
00dc86579
|
87 |
ignore_vmlinux_buildid, |
0bc8d2058
|
88 |
show_kernel_path, |
79406cd78
|
89 |
use_modules, |
680d926a8
|
90 |
allow_aliases, |
d599db3fc
|
91 92 |
sort_by_name, show_nr_samples, |
3f2728bdb
|
93 |
show_total_period, |
d599db3fc
|
94 |
use_callchain, |
f8be1c8c4
|
95 |
cumulate_callchain, |
f9a7be7c0
|
96 |
show_branchflag_count, |
f7d87444e
|
97 |
exclude_other, |
85e00b555
|
98 |
show_cpu_utilization, |
ec80fde74
|
99 |
initialized, |
3e6a2a7f3
|
100 101 |
kptr_restrict, annotate_asm_raw, |
6e1f601a1
|
102 |
annotate_src, |
328ccdace
|
103 |
event_group, |
f21483305
|
104 |
demangle, |
763122ade
|
105 |
demangle_kernel, |
c83023676
|
106 |
filter_relative, |
8b7bad58e
|
107 |
show_hist_headers, |
0bc2f2f7d
|
108 |
branch_callstack, |
9e207ddfa
|
109 |
has_filter, |
b49a8fe52
|
110 |
show_ref_callgraph, |
053a3989e
|
111 |
hide_unresolved, |
aef810ec4
|
112 |
raw_trace, |
f3a60646c
|
113 114 |
report_hierarchy, inline_name; |
c410a3388
|
115 |
const char *vmlinux_name, |
b226a5a72
|
116 |
*kallsyms_name, |
9ed7e1b85
|
117 |
*source_prefix, |
c410a3388
|
118 |
*field_sep; |
a1645ce12
|
119 120 121 122 |
const char *default_guest_vmlinux_name, *default_guest_kallsyms, *default_guest_modules; const char *guestmount; |
edb7c60e2
|
123 |
const char *dso_list_str, |
655000e7c
|
124 |
*comm_list_str, |
e03eaa400
|
125 126 |
*pid_list_str, *tid_list_str, |
655000e7c
|
127 |
*sym_list_str, |
64eff7d9c
|
128 129 |
*col_width_list_str, *bt_stop_list_str; |
655000e7c
|
130 131 |
struct strlist *dso_list, *comm_list, |
a68c2c581
|
132 133 134 135 |
*sym_list, *dso_from_list, *dso_to_list, *sym_from_list, |
64eff7d9c
|
136 137 |
*sym_to_list, *bt_stop_list; |
e03eaa400
|
138 139 |
struct intlist *pid_list, *tid_list; |
ec5761eab
|
140 |
const char *symfs; |
b32d133ae
|
141 |
}; |
75be6cf48
|
142 |
extern struct symbol_conf symbol_conf; |
972f393bc
|
143 |
|
bfbba189b
|
144 145 146 147 |
struct symbol_name_rb_node { struct rb_node rb_node; struct symbol sym; }; |
972f393bc
|
148 149 150 151 152 153 |
static inline int __symbol__join_symfs(char *bf, size_t size, const char *path) { return path__join(bf, size, symbol_conf.symfs, path); } #define symbol__join_symfs(bf, path) __symbol__join_symfs(bf, sizeof(bf), path) |
3f067dcab
|
154 155 |
extern int vmlinux_path__nr_entries; extern char **vmlinux_path; |
00a192b39
|
156 |
|
aeafcbaf4
|
157 |
static inline void *symbol__priv(struct symbol *sym) |
00a192b39
|
158 |
{ |
aeafcbaf4
|
159 |
return ((void *)sym) - symbol_conf.priv_size; |
00a192b39
|
160 |
} |
9de89fe7c
|
161 162 163 164 165 |
struct ref_reloc_sym { const char *name; u64 addr; u64 unrelocated_addr; }; |
59fd53062
|
166 167 168 169 |
struct map_symbol { struct map *map; struct symbol *sym; }; |
b5387528f
|
170 171 172 173 |
struct addr_map_symbol { struct map *map; struct symbol *sym; u64 addr; |
a68c2c581
|
174 |
u64 al_addr; |
b5387528f
|
175 176 177 178 179 180 |
}; struct branch_info { struct addr_map_symbol from; struct addr_map_symbol to; struct branch_flags flags; |
508be0dfe
|
181 182 |
char *srcline_from; char *srcline_to; |
b5387528f
|
183 |
}; |
98a3b32c9
|
184 185 186 187 188 |
struct mem_info { struct addr_map_symbol iaddr; struct addr_map_symbol daddr; union perf_mem_data_src data_src; }; |
1ed091c45
|
189 |
struct addr_location { |
cc22e575a
|
190 |
struct machine *machine; |
1ed091c45
|
191 192 193 194 195 |
struct thread *thread; struct map *map; struct symbol *sym; u64 addr; char level; |
b3cef7f60
|
196 |
u8 filtered; |
f60f35938
|
197 198 |
u8 cpumode; s32 cpu; |
0c4c4debb
|
199 |
s32 socket; |
a1645ce12
|
200 |
}; |
b68e2f919
|
201 202 203 204 |
struct symsrc { char *name; int fd; enum dso_binary_type type; |
89fe808ae
|
205 |
#ifdef HAVE_LIBELF_SUPPORT |
b68e2f919
|
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
Elf *elf; GElf_Ehdr ehdr; Elf_Scn *opdsec; size_t opdidx; GElf_Shdr opdshdr; Elf_Scn *symtab; GElf_Shdr symshdr; Elf_Scn *dynsym; size_t dynsym_idx; GElf_Shdr dynshdr; bool adjust_symbols; |
c6d8f2a4a
|
221 |
bool is_64_bit; |
b68e2f919
|
222 223 224 225 226 227 |
#endif }; void symsrc__destroy(struct symsrc *ss); int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, enum dso_binary_type type); |
d26cd12b4
|
228 |
bool symsrc__has_symtab(struct symsrc *ss); |
3aafe5ae0
|
229 |
bool symsrc__possibly_runtime(struct symsrc *ss); |
b68e2f919
|
230 |
|
be39db9f2
|
231 |
int dso__load(struct dso *dso, struct map *map); |
aeafcbaf4
|
232 |
int dso__load_vmlinux(struct dso *dso, struct map *map, |
be39db9f2
|
233 234 |
const char *vmlinux, bool vmlinux_allocated); int dso__load_vmlinux_path(struct dso *dso, struct map *map); |
e02092b9a
|
235 |
int __dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map, |
be39db9f2
|
236 237 |
bool no_kcore); int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map); |
cdd059d73
|
238 |
|
ae93a6c70
|
239 240 |
void dso__insert_symbol(struct dso *dso, enum map_type type, struct symbol *sym); |
aeafcbaf4
|
241 242 243 |
struct symbol *dso__find_symbol(struct dso *dso, enum map_type type, u64 addr); struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, |
79406cd78
|
244 |
const char *name); |
18bd72641
|
245 |
struct symbol *symbol__next_by_name(struct symbol *sym); |
a2928c42a
|
246 |
|
9c00a81b6
|
247 |
struct symbol *dso__first_symbol(struct dso *dso, enum map_type type); |
cd67f99fe
|
248 |
struct symbol *dso__last_symbol(struct dso *dso, enum map_type type); |
9c00a81b6
|
249 |
struct symbol *dso__next_symbol(struct symbol *sym); |
2b5b8bb27
|
250 |
enum dso_type dso__type_fd(int fd); |
2643ce114
|
251 |
int filename__read_build_id(const char *filename, void *bf, size_t size); |
f1617b405
|
252 |
int sysfs__read_build_id(const char *filename, void *bf, size_t size); |
316d70d6d
|
253 254 255 |
int modules__parse(const char *filename, void *arg, int (*process_module)(void *arg, const char *name, u64 start)); |
e5a1845fc
|
256 257 |
int filename__read_debuglink(const char *filename, char *debuglink, size_t size); |
2643ce114
|
258 |
|
ce80d3bef
|
259 260 |
struct perf_env; int symbol__init(struct perf_env *env); |
d65a458b3
|
261 |
void symbol__exit(void); |
166ccc9c2
|
262 |
void symbol__elf_init(void); |
b01141f4f
|
263 |
int symbol__annotation_init(void); |
e5a1845fc
|
264 |
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name); |
fd4be1306
|
265 266 |
size_t __symbol__fprintf_symname_offs(const struct symbol *sym, const struct addr_location *al, |
a8763445f
|
267 268 |
bool unknown_as_addr, bool print_offsets, FILE *fp); |
a978f2ab4
|
269 270 |
size_t symbol__fprintf_symname_offs(const struct symbol *sym, const struct addr_location *al, FILE *fp); |
fd4be1306
|
271 272 273 |
size_t __symbol__fprintf_symname(const struct symbol *sym, const struct addr_location *al, bool unknown_as_addr, FILE *fp); |
547a92e0a
|
274 |
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp); |
cdd059d73
|
275 |
size_t symbol__fprintf(struct symbol *sym, FILE *fp); |
36a3e6461
|
276 |
bool symbol_type__is_a(char symbol_type, enum map_type map_type); |
3f067dcab
|
277 278 |
bool symbol__restricted_filename(const char *filename, const char *restricted_filename); |
a70667090
|
279 280 |
int symbol__config_symfs(const struct option *opt __maybe_unused, const char *dir, int unset __maybe_unused); |
36a3e6461
|
281 |
|
261360b6e
|
282 |
int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, |
be39db9f2
|
283 |
struct symsrc *runtime_ss, int kmodule); |
a44f605b2
|
284 |
int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, |
be39db9f2
|
285 |
struct map *map); |
e5a1845fc
|
286 |
|
a64489c56
|
287 |
char *dso__demangle_sym(struct dso *dso, int kmodule, char *elf_name); |
608c34de0
|
288 |
void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel); |
e5a1845fc
|
289 290 291 292 |
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, enum map_type type); |
8e0cf965f
|
293 294 295 |
typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data); int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data, bool *is_64_bit); |
afba19d9d
|
296 297 298 299 300 301 302 303 304 305 306 307 308 |
#define PERF_KCORE_EXTRACT "/tmp/perf-kcore-XXXXXX" struct kcore_extract { char *kcore_filename; u64 addr; u64 offs; u64 len; char extract_filename[sizeof(PERF_KCORE_EXTRACT)]; int fd; }; int kcore_extract__create(struct kcore_extract *kce); void kcore_extract__delete(struct kcore_extract *kce); |
fc1b691d7
|
309 310 |
int kcore_copy(const char *from_dir, const char *to_dir); int compare_proc_modules(const char *from, const char *to); |
3bfe5f81f
|
311 312 |
int setup_list(struct strlist **list, const char *list_str, const char *list_name); |
e03eaa400
|
313 314 |
int setup_intlist(struct intlist **list, const char *list_str, const char *list_name); |
3bfe5f81f
|
315 |
|
d23320983
|
316 317 |
#ifdef HAVE_LIBELF_SUPPORT bool elf__needs_adjust_symbols(GElf_Ehdr ehdr); |
0b3c2264a
|
318 |
void arch__sym_update(struct symbol *s, GElf_Sym *sym); |
d23320983
|
319 |
#endif |
fb6d59423
|
320 321 |
#define SYMBOL_A 0 #define SYMBOL_B 1 |
d80406453
|
322 323 324 |
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); |
fb6d59423
|
325 |
int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); |
d80406453
|
326 327 328 329 330 331 332 |
enum symbol_tag_include { SYMBOL_TAG_INCLUDE__NONE = 0, SYMBOL_TAG_INCLUDE__DEFAULT_ONLY }; int symbol__match_symbol_name(const char *namea, const char *nameb, enum symbol_tag_include includes); |
060fa0c7a
|
333 334 335 336 |
/* structure containing an SDT note's info */ struct sdt_note { char *name; /* name of the note*/ char *provider; /* provider name */ |
be88184b1
|
337 |
char *args; |
060fa0c7a
|
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
bool bit32; /* whether the location is 32 bits? */ union { /* location, base and semaphore addrs */ Elf64_Addr a64[3]; Elf32_Addr a32[3]; } addr; struct list_head note_list; /* SDT notes' list */ }; 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); #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 |
8b40f521c
|
355 |
#endif /* __PERF_SYMBOL */ |