.. | .. |
---|
3 | 3 | #define __PERF_SYMBOL 1 |
---|
4 | 4 | |
---|
5 | 5 | #include <linux/types.h> |
---|
| 6 | +#include <linux/refcount.h> |
---|
6 | 7 | #include <stdbool.h> |
---|
7 | 8 | #include <stdint.h> |
---|
8 | | -#include "map.h" |
---|
9 | | -#include "../perf.h" |
---|
10 | 9 | #include <linux/list.h> |
---|
11 | 10 | #include <linux/rbtree.h> |
---|
12 | 11 | #include <stdio.h> |
---|
13 | | -#include <byteswap.h> |
---|
14 | | -#include <libgen.h> |
---|
15 | | -#include "build-id.h" |
---|
16 | | -#include "event.h" |
---|
17 | 12 | #include "path.h" |
---|
| 13 | +#include "symbol_conf.h" |
---|
| 14 | +#include "spark.h" |
---|
18 | 15 | |
---|
19 | 16 | #ifdef HAVE_LIBELF_SUPPORT |
---|
20 | 17 | #include <libelf.h> |
---|
.. | .. |
---|
22 | 19 | #endif |
---|
23 | 20 | #include <elf.h> |
---|
24 | 21 | |
---|
25 | | -#include "dso.h" |
---|
| 22 | +struct dso; |
---|
| 23 | +struct map; |
---|
| 24 | +struct maps; |
---|
| 25 | +struct option; |
---|
| 26 | +struct build_id; |
---|
26 | 27 | |
---|
27 | 28 | /* |
---|
28 | 29 | * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; |
---|
29 | 30 | * for newer versions we can use mmap to reduce memory usage: |
---|
30 | 31 | */ |
---|
31 | | -#ifdef HAVE_LIBELF_MMAP_SUPPORT |
---|
| 32 | +#ifdef ELF_C_READ_MMAP |
---|
32 | 33 | # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP |
---|
33 | 34 | #else |
---|
34 | 35 | # define PERF_ELF_C_READ_MMAP ELF_C_READ |
---|
.. | .. |
---|
38 | 39 | Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, |
---|
39 | 40 | GElf_Shdr *shp, const char *name, size_t *idx); |
---|
40 | 41 | #endif |
---|
41 | | - |
---|
42 | | -#ifndef DMGL_PARAMS |
---|
43 | | -#define DMGL_NO_OPTS 0 /* For readability... */ |
---|
44 | | -#define DMGL_PARAMS (1 << 0) /* Include function args */ |
---|
45 | | -#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ |
---|
46 | | -#endif |
---|
47 | | - |
---|
48 | | -#define DSO__NAME_KALLSYMS "[kernel.kallsyms]" |
---|
49 | | -#define DSO__NAME_KCORE "[kernel.kcore]" |
---|
50 | 42 | |
---|
51 | 43 | /** struct symbol - symtab entry |
---|
52 | 44 | * |
---|
.. | .. |
---|
63 | 55 | u8 ignore:1; |
---|
64 | 56 | u8 inlined:1; |
---|
65 | 57 | u8 arch_sym; |
---|
66 | | - char name[0]; |
---|
| 58 | + bool annotate2; |
---|
| 59 | + char name[]; |
---|
67 | 60 | }; |
---|
68 | 61 | |
---|
69 | 62 | void symbol__delete(struct symbol *sym); |
---|
70 | | -void symbols__delete(struct rb_root *symbols); |
---|
| 63 | +void symbols__delete(struct rb_root_cached *symbols); |
---|
71 | 64 | |
---|
72 | 65 | /* symbols__for_each_entry - iterate over symbols (rb_root) |
---|
73 | 66 | * |
---|
.. | .. |
---|
76 | 69 | * @nd: the 'struct rb_node *' to use as a temporary storage |
---|
77 | 70 | */ |
---|
78 | 71 | #define symbols__for_each_entry(symbols, pos, nd) \ |
---|
79 | | - for (nd = rb_first(symbols); \ |
---|
| 72 | + for (nd = rb_first_cached(symbols); \ |
---|
80 | 73 | nd && (pos = rb_entry(nd, struct symbol, rb_node)); \ |
---|
81 | 74 | nd = rb_next(nd)) |
---|
82 | 75 | |
---|
.. | .. |
---|
87 | 80 | |
---|
88 | 81 | struct strlist; |
---|
89 | 82 | struct intlist; |
---|
90 | | - |
---|
91 | | -struct symbol_conf { |
---|
92 | | - unsigned short priv_size; |
---|
93 | | - bool try_vmlinux_path, |
---|
94 | | - init_annotation, |
---|
95 | | - force, |
---|
96 | | - ignore_vmlinux, |
---|
97 | | - ignore_vmlinux_buildid, |
---|
98 | | - show_kernel_path, |
---|
99 | | - use_modules, |
---|
100 | | - allow_aliases, |
---|
101 | | - sort_by_name, |
---|
102 | | - show_nr_samples, |
---|
103 | | - show_total_period, |
---|
104 | | - use_callchain, |
---|
105 | | - cumulate_callchain, |
---|
106 | | - show_branchflag_count, |
---|
107 | | - exclude_other, |
---|
108 | | - show_cpu_utilization, |
---|
109 | | - initialized, |
---|
110 | | - kptr_restrict, |
---|
111 | | - event_group, |
---|
112 | | - demangle, |
---|
113 | | - demangle_kernel, |
---|
114 | | - filter_relative, |
---|
115 | | - show_hist_headers, |
---|
116 | | - branch_callstack, |
---|
117 | | - has_filter, |
---|
118 | | - show_ref_callgraph, |
---|
119 | | - hide_unresolved, |
---|
120 | | - raw_trace, |
---|
121 | | - report_hierarchy, |
---|
122 | | - inline_name; |
---|
123 | | - const char *vmlinux_name, |
---|
124 | | - *kallsyms_name, |
---|
125 | | - *source_prefix, |
---|
126 | | - *field_sep; |
---|
127 | | - const char *default_guest_vmlinux_name, |
---|
128 | | - *default_guest_kallsyms, |
---|
129 | | - *default_guest_modules; |
---|
130 | | - const char *guestmount; |
---|
131 | | - const char *dso_list_str, |
---|
132 | | - *comm_list_str, |
---|
133 | | - *pid_list_str, |
---|
134 | | - *tid_list_str, |
---|
135 | | - *sym_list_str, |
---|
136 | | - *col_width_list_str, |
---|
137 | | - *bt_stop_list_str; |
---|
138 | | - struct strlist *dso_list, |
---|
139 | | - *comm_list, |
---|
140 | | - *sym_list, |
---|
141 | | - *dso_from_list, |
---|
142 | | - *dso_to_list, |
---|
143 | | - *sym_from_list, |
---|
144 | | - *sym_to_list, |
---|
145 | | - *bt_stop_list; |
---|
146 | | - struct intlist *pid_list, |
---|
147 | | - *tid_list; |
---|
148 | | - const char *symfs; |
---|
149 | | -}; |
---|
150 | | - |
---|
151 | | -extern struct symbol_conf symbol_conf; |
---|
152 | 83 | |
---|
153 | 84 | struct symbol_name_rb_node { |
---|
154 | 85 | struct rb_node rb_node; |
---|
.. | .. |
---|
176 | 107 | u64 unrelocated_addr; |
---|
177 | 108 | }; |
---|
178 | 109 | |
---|
179 | | -struct map_symbol { |
---|
180 | | - struct map *map; |
---|
181 | | - struct symbol *sym; |
---|
182 | | -}; |
---|
183 | | - |
---|
184 | | -struct addr_map_symbol { |
---|
185 | | - struct map *map; |
---|
186 | | - struct symbol *sym; |
---|
187 | | - u64 addr; |
---|
188 | | - u64 al_addr; |
---|
189 | | - u64 phys_addr; |
---|
190 | | -}; |
---|
191 | | - |
---|
192 | | -struct branch_info { |
---|
193 | | - struct addr_map_symbol from; |
---|
194 | | - struct addr_map_symbol to; |
---|
195 | | - struct branch_flags flags; |
---|
196 | | - char *srcline_from; |
---|
197 | | - char *srcline_to; |
---|
198 | | -}; |
---|
199 | | - |
---|
200 | | -struct mem_info { |
---|
201 | | - struct addr_map_symbol iaddr; |
---|
202 | | - struct addr_map_symbol daddr; |
---|
203 | | - union perf_mem_data_src data_src; |
---|
204 | | - refcount_t refcnt; |
---|
205 | | -}; |
---|
206 | | - |
---|
207 | 110 | struct addr_location { |
---|
208 | | - struct machine *machine; |
---|
209 | 111 | struct thread *thread; |
---|
| 112 | + struct maps *maps; |
---|
210 | 113 | struct map *map; |
---|
211 | 114 | struct symbol *sym; |
---|
212 | 115 | const char *srcline; |
---|
.. | .. |
---|
218 | 121 | s32 socket; |
---|
219 | 122 | }; |
---|
220 | 123 | |
---|
221 | | -struct symsrc { |
---|
222 | | - char *name; |
---|
223 | | - int fd; |
---|
224 | | - enum dso_binary_type type; |
---|
225 | | - |
---|
226 | | -#ifdef HAVE_LIBELF_SUPPORT |
---|
227 | | - Elf *elf; |
---|
228 | | - GElf_Ehdr ehdr; |
---|
229 | | - |
---|
230 | | - Elf_Scn *opdsec; |
---|
231 | | - size_t opdidx; |
---|
232 | | - GElf_Shdr opdshdr; |
---|
233 | | - |
---|
234 | | - Elf_Scn *symtab; |
---|
235 | | - GElf_Shdr symshdr; |
---|
236 | | - |
---|
237 | | - Elf_Scn *dynsym; |
---|
238 | | - size_t dynsym_idx; |
---|
239 | | - GElf_Shdr dynshdr; |
---|
240 | | - |
---|
241 | | - bool adjust_symbols; |
---|
242 | | - bool is_64_bit; |
---|
243 | | -#endif |
---|
244 | | -}; |
---|
245 | | - |
---|
246 | | -void symsrc__destroy(struct symsrc *ss); |
---|
247 | | -int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, |
---|
248 | | - enum dso_binary_type type); |
---|
249 | | -bool symsrc__has_symtab(struct symsrc *ss); |
---|
250 | | -bool symsrc__possibly_runtime(struct symsrc *ss); |
---|
251 | | - |
---|
252 | 124 | int dso__load(struct dso *dso, struct map *map); |
---|
253 | 125 | int dso__load_vmlinux(struct dso *dso, struct map *map, |
---|
254 | 126 | const char *vmlinux, bool vmlinux_allocated); |
---|
.. | .. |
---|
258 | 130 | int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map); |
---|
259 | 131 | |
---|
260 | 132 | void dso__insert_symbol(struct dso *dso, |
---|
| 133 | + struct symbol *sym); |
---|
| 134 | +void dso__delete_symbol(struct dso *dso, |
---|
261 | 135 | struct symbol *sym); |
---|
262 | 136 | |
---|
263 | 137 | struct symbol *dso__find_symbol(struct dso *dso, u64 addr); |
---|
.. | .. |
---|
271 | 145 | |
---|
272 | 146 | enum dso_type dso__type_fd(int fd); |
---|
273 | 147 | |
---|
274 | | -int filename__read_build_id(const char *filename, void *bf, size_t size); |
---|
275 | | -int sysfs__read_build_id(const char *filename, void *bf, size_t size); |
---|
| 148 | +int filename__read_build_id(const char *filename, struct build_id *id); |
---|
| 149 | +int sysfs__read_build_id(const char *filename, struct build_id *bid); |
---|
276 | 150 | int modules__parse(const char *filename, void *arg, |
---|
277 | 151 | int (*process_module)(void *arg, const char *name, |
---|
278 | 152 | u64 start, u64 size)); |
---|
.. | .. |
---|
302 | 176 | int symbol__config_symfs(const struct option *opt __maybe_unused, |
---|
303 | 177 | const char *dir, int unset __maybe_unused); |
---|
304 | 178 | |
---|
| 179 | +struct symsrc; |
---|
| 180 | + |
---|
| 181 | +#ifdef HAVE_LIBBFD_SUPPORT |
---|
| 182 | +int dso__load_bfd_symbols(struct dso *dso, const char *debugfile); |
---|
| 183 | +#endif |
---|
| 184 | + |
---|
305 | 185 | int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, |
---|
306 | 186 | struct symsrc *runtime_ss, int kmodule); |
---|
307 | 187 | int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss); |
---|
308 | 188 | |
---|
309 | 189 | char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name); |
---|
310 | 190 | |
---|
311 | | -void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel); |
---|
312 | | -void symbols__insert(struct rb_root *symbols, struct symbol *sym); |
---|
313 | | -void symbols__fixup_duplicate(struct rb_root *symbols); |
---|
314 | | -void symbols__fixup_end(struct rb_root *symbols); |
---|
315 | | -void map_groups__fixup_end(struct map_groups *mg); |
---|
| 191 | +void __symbols__insert(struct rb_root_cached *symbols, struct symbol *sym, |
---|
| 192 | + bool kernel); |
---|
| 193 | +void symbols__insert(struct rb_root_cached *symbols, struct symbol *sym); |
---|
| 194 | +void symbols__fixup_duplicate(struct rb_root_cached *symbols); |
---|
| 195 | +void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms); |
---|
| 196 | +void maps__fixup_end(struct maps *maps); |
---|
316 | 197 | |
---|
317 | 198 | typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data); |
---|
318 | 199 | int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data, |
---|
.. | .. |
---|
349 | 230 | #define SYMBOL_A 0 |
---|
350 | 231 | #define SYMBOL_B 1 |
---|
351 | 232 | |
---|
352 | | -void arch__symbols__fixup_end(struct symbol *p, struct symbol *c); |
---|
353 | 233 | int arch__compare_symbol_names(const char *namea, const char *nameb); |
---|
354 | 234 | int arch__compare_symbol_names_n(const char *namea, const char *nameb, |
---|
355 | 235 | unsigned int n); |
---|
.. | .. |
---|
380 | 260 | int cleanup_sdt_note_list(struct list_head *sdt_notes); |
---|
381 | 261 | int sdt_notes__get_count(struct list_head *start); |
---|
382 | 262 | |
---|
| 263 | +#define SDT_PROBES_SCN ".probes" |
---|
383 | 264 | #define SDT_BASE_SCN ".stapsdt.base" |
---|
384 | 265 | #define SDT_NOTE_SCN ".note.stapsdt" |
---|
385 | 266 | #define SDT_NOTE_TYPE 3 |
---|
386 | 267 | #define SDT_NOTE_NAME "stapsdt" |
---|
387 | 268 | #define NR_ADDR 3 |
---|
388 | 269 | |
---|
| 270 | +enum { |
---|
| 271 | + SDT_NOTE_IDX_LOC = 0, |
---|
| 272 | + SDT_NOTE_IDX_BASE, |
---|
| 273 | + SDT_NOTE_IDX_REFCTR, |
---|
| 274 | +}; |
---|
| 275 | + |
---|
389 | 276 | struct mem_info *mem_info__new(void); |
---|
390 | 277 | struct mem_info *mem_info__get(struct mem_info *mi); |
---|
391 | 278 | void mem_info__put(struct mem_info *mi); |
---|