hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/tools/perf/util/symbol.h
....@@ -3,18 +3,15 @@
33 #define __PERF_SYMBOL 1
44
55 #include <linux/types.h>
6
+#include <linux/refcount.h>
67 #include <stdbool.h>
78 #include <stdint.h>
8
-#include "map.h"
9
-#include "../perf.h"
109 #include <linux/list.h>
1110 #include <linux/rbtree.h>
1211 #include <stdio.h>
13
-#include <byteswap.h>
14
-#include <libgen.h>
15
-#include "build-id.h"
16
-#include "event.h"
1712 #include "path.h"
13
+#include "symbol_conf.h"
14
+#include "spark.h"
1815
1916 #ifdef HAVE_LIBELF_SUPPORT
2017 #include <libelf.h>
....@@ -22,13 +19,17 @@
2219 #endif
2320 #include <elf.h>
2421
25
-#include "dso.h"
22
+struct dso;
23
+struct map;
24
+struct maps;
25
+struct option;
26
+struct build_id;
2627
2728 /*
2829 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
2930 * for newer versions we can use mmap to reduce memory usage:
3031 */
31
-#ifdef HAVE_LIBELF_MMAP_SUPPORT
32
+#ifdef ELF_C_READ_MMAP
3233 # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
3334 #else
3435 # define PERF_ELF_C_READ_MMAP ELF_C_READ
....@@ -38,15 +39,6 @@
3839 Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
3940 GElf_Shdr *shp, const char *name, size_t *idx);
4041 #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]"
5042
5143 /** struct symbol - symtab entry
5244 *
....@@ -63,11 +55,12 @@
6355 u8 ignore:1;
6456 u8 inlined:1;
6557 u8 arch_sym;
66
- char name[0];
58
+ bool annotate2;
59
+ char name[];
6760 };
6861
6962 void symbol__delete(struct symbol *sym);
70
-void symbols__delete(struct rb_root *symbols);
63
+void symbols__delete(struct rb_root_cached *symbols);
7164
7265 /* symbols__for_each_entry - iterate over symbols (rb_root)
7366 *
....@@ -76,7 +69,7 @@
7669 * @nd: the 'struct rb_node *' to use as a temporary storage
7770 */
7871 #define symbols__for_each_entry(symbols, pos, nd) \
79
- for (nd = rb_first(symbols); \
72
+ for (nd = rb_first_cached(symbols); \
8073 nd && (pos = rb_entry(nd, struct symbol, rb_node)); \
8174 nd = rb_next(nd))
8275
....@@ -87,68 +80,6 @@
8780
8881 struct strlist;
8982 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;
15283
15384 struct symbol_name_rb_node {
15485 struct rb_node rb_node;
....@@ -176,37 +107,9 @@
176107 u64 unrelocated_addr;
177108 };
178109
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
-
207110 struct addr_location {
208
- struct machine *machine;
209111 struct thread *thread;
112
+ struct maps *maps;
210113 struct map *map;
211114 struct symbol *sym;
212115 const char *srcline;
....@@ -218,37 +121,6 @@
218121 s32 socket;
219122 };
220123
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
-
252124 int dso__load(struct dso *dso, struct map *map);
253125 int dso__load_vmlinux(struct dso *dso, struct map *map,
254126 const char *vmlinux, bool vmlinux_allocated);
....@@ -258,6 +130,8 @@
258130 int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map);
259131
260132 void dso__insert_symbol(struct dso *dso,
133
+ struct symbol *sym);
134
+void dso__delete_symbol(struct dso *dso,
261135 struct symbol *sym);
262136
263137 struct symbol *dso__find_symbol(struct dso *dso, u64 addr);
....@@ -271,8 +145,8 @@
271145
272146 enum dso_type dso__type_fd(int fd);
273147
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);
276150 int modules__parse(const char *filename, void *arg,
277151 int (*process_module)(void *arg, const char *name,
278152 u64 start, u64 size));
....@@ -302,17 +176,24 @@
302176 int symbol__config_symfs(const struct option *opt __maybe_unused,
303177 const char *dir, int unset __maybe_unused);
304178
179
+struct symsrc;
180
+
181
+#ifdef HAVE_LIBBFD_SUPPORT
182
+int dso__load_bfd_symbols(struct dso *dso, const char *debugfile);
183
+#endif
184
+
305185 int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
306186 struct symsrc *runtime_ss, int kmodule);
307187 int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss);
308188
309189 char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name);
310190
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);
316197
317198 typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);
318199 int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
....@@ -349,7 +230,6 @@
349230 #define SYMBOL_A 0
350231 #define SYMBOL_B 1
351232
352
-void arch__symbols__fixup_end(struct symbol *p, struct symbol *c);
353233 int arch__compare_symbol_names(const char *namea, const char *nameb);
354234 int arch__compare_symbol_names_n(const char *namea, const char *nameb,
355235 unsigned int n);
....@@ -380,12 +260,19 @@
380260 int cleanup_sdt_note_list(struct list_head *sdt_notes);
381261 int sdt_notes__get_count(struct list_head *start);
382262
263
+#define SDT_PROBES_SCN ".probes"
383264 #define SDT_BASE_SCN ".stapsdt.base"
384265 #define SDT_NOTE_SCN ".note.stapsdt"
385266 #define SDT_NOTE_TYPE 3
386267 #define SDT_NOTE_NAME "stapsdt"
387268 #define NR_ADDR 3
388269
270
+enum {
271
+ SDT_NOTE_IDX_LOC = 0,
272
+ SDT_NOTE_IDX_BASE,
273
+ SDT_NOTE_IDX_REFCTR,
274
+};
275
+
389276 struct mem_info *mem_info__new(void);
390277 struct mem_info *mem_info__get(struct mem_info *mi);
391278 void mem_info__put(struct mem_info *mi);