2 #define __PERF_SYMBOL 1
4 #include <linux/types.h>
9 #include <linux/list.h>
10 #include <linux/rbtree.h>
18 #ifdef HAVE_LIBELF_SUPPORT
27 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
28 * for newer versions we can use mmap to reduce memory usage:
30 #ifdef HAVE_LIBELF_MMAP_SUPPORT
31 # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
33 # define PERF_ELF_C_READ_MMAP ELF_C_READ
36 #ifdef HAVE_LIBELF_SUPPORT
37 Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
38 GElf_Shdr *shp, const char *name, size_t *idx);
42 #define DMGL_NO_OPTS 0 /* For readability... */
43 #define DMGL_PARAMS (1 << 0) /* Include function args */
44 #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
47 /** struct symbol - symtab entry
49 * @ignore - resolvable but tools ignore it (e.g. idle routines)
52 struct rb_node rb_node;
62 void symbol__delete(struct symbol *sym);
63 void symbols__delete(struct rb_root *symbols);
65 /* symbols__for_each_entry - iterate over symbols (rb_root)
67 * @symbols: the rb_root of symbols
68 * @pos: the 'struct symbol *' to use as a loop cursor
69 * @nd: the 'struct rb_node *' to use as a temporary storage
71 #define symbols__for_each_entry(symbols, pos, nd) \
72 for (nd = rb_first(symbols); \
73 nd && (pos = rb_entry(nd, struct symbol, rb_node)); \
76 static inline size_t symbol__size(const struct symbol *sym)
78 return sym->end - sym->start;
85 unsigned short priv_size;
86 unsigned short nr_events;
87 bool try_vmlinux_path,
90 ignore_vmlinux_buildid,
100 show_cpu_utilization,
116 const char *vmlinux_name,
120 const char *default_guest_vmlinux_name,
121 *default_guest_kallsyms,
122 *default_guest_modules;
123 const char *guestmount;
124 const char *dso_list_str,
130 struct strlist *dso_list,
137 struct intlist *pid_list,
142 extern struct symbol_conf symbol_conf;
144 struct symbol_name_rb_node {
145 struct rb_node rb_node;
149 static inline int __symbol__join_symfs(char *bf, size_t size, const char *path)
151 return path__join(bf, size, symbol_conf.symfs, path);
154 #define symbol__join_symfs(bf, path) __symbol__join_symfs(bf, sizeof(bf), path)
156 extern int vmlinux_path__nr_entries;
157 extern char **vmlinux_path;
159 static inline void *symbol__priv(struct symbol *sym)
161 return ((void *)sym) - symbol_conf.priv_size;
164 struct ref_reloc_sym {
167 u64 unrelocated_addr;
175 struct addr_map_symbol {
183 struct addr_map_symbol from;
184 struct addr_map_symbol to;
185 struct branch_flags flags;
189 struct addr_map_symbol iaddr;
190 struct addr_map_symbol daddr;
191 union perf_mem_data_src data_src;
194 struct addr_location {
195 struct machine *machine;
196 struct thread *thread;
210 enum dso_binary_type type;
212 #ifdef HAVE_LIBELF_SUPPORT
232 void symsrc__destroy(struct symsrc *ss);
233 int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
234 enum dso_binary_type type);
235 bool symsrc__has_symtab(struct symsrc *ss);
236 bool symsrc__possibly_runtime(struct symsrc *ss);
238 int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter);
239 int dso__load_vmlinux(struct dso *dso, struct map *map,
240 const char *vmlinux, bool vmlinux_allocated,
241 symbol_filter_t filter);
242 int dso__load_vmlinux_path(struct dso *dso, struct map *map,
243 symbol_filter_t filter);
244 int __dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
245 bool no_kcore, symbol_filter_t filter);
246 int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
247 symbol_filter_t filter);
249 void dso__insert_symbol(struct dso *dso, enum map_type type,
252 struct symbol *dso__find_symbol(struct dso *dso, enum map_type type,
254 struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
256 struct symbol *symbol__next_by_name(struct symbol *sym);
258 struct symbol *dso__first_symbol(struct dso *dso, enum map_type type);
259 struct symbol *dso__next_symbol(struct symbol *sym);
261 enum dso_type dso__type_fd(int fd);
263 int filename__read_build_id(const char *filename, void *bf, size_t size);
264 int sysfs__read_build_id(const char *filename, void *bf, size_t size);
265 int modules__parse(const char *filename, void *arg,
266 int (*process_module)(void *arg, const char *name,
268 int filename__read_debuglink(const char *filename, char *debuglink,
272 int symbol__init(struct perf_env *env);
273 void symbol__exit(void);
274 void symbol__elf_init(void);
275 struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
276 size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
277 const struct addr_location *al,
278 bool unknown_as_addr, FILE *fp);
279 size_t symbol__fprintf_symname_offs(const struct symbol *sym,
280 const struct addr_location *al, FILE *fp);
281 size_t __symbol__fprintf_symname(const struct symbol *sym,
282 const struct addr_location *al,
283 bool unknown_as_addr, FILE *fp);
284 size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
285 size_t symbol__fprintf(struct symbol *sym, FILE *fp);
286 bool symbol_type__is_a(char symbol_type, enum map_type map_type);
287 bool symbol__restricted_filename(const char *filename,
288 const char *restricted_filename);
289 bool symbol__is_idle(struct symbol *sym);
291 int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
292 struct symsrc *runtime_ss, symbol_filter_t filter,
294 int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss,
295 struct map *map, symbol_filter_t filter);
297 void symbols__insert(struct rb_root *symbols, struct symbol *sym);
298 void symbols__fixup_duplicate(struct rb_root *symbols);
299 void symbols__fixup_end(struct rb_root *symbols);
300 void __map_groups__fixup_end(struct map_groups *mg, enum map_type type);
302 typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);
303 int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
306 #define PERF_KCORE_EXTRACT "/tmp/perf-kcore-XXXXXX"
308 struct kcore_extract {
309 char *kcore_filename;
313 char extract_filename[sizeof(PERF_KCORE_EXTRACT)];
317 int kcore_extract__create(struct kcore_extract *kce);
318 void kcore_extract__delete(struct kcore_extract *kce);
320 int kcore_copy(const char *from_dir, const char *to_dir);
321 int compare_proc_modules(const char *from, const char *to);
323 int setup_list(struct strlist **list, const char *list_str,
324 const char *list_name);
325 int setup_intlist(struct intlist **list, const char *list_str,
326 const char *list_name);
328 #ifdef HAVE_LIBELF_SUPPORT
329 bool elf__needs_adjust_symbols(GElf_Ehdr ehdr);
330 void arch__sym_update(struct symbol *s, GElf_Sym *sym);
336 int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb);
338 #endif /* __PERF_SYMBOL */