John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 1 | #ifndef __PERF_SYMBOL |
| 2 | #define __PERF_SYMBOL 1 |
Arnaldo Carvalho de Melo | a2928c4 | 2009-05-28 14:55:04 -0300 | [diff] [blame] | 3 | |
| 4 | #include <linux/types.h> |
Arnaldo Carvalho de Melo | e420499 | 2009-10-20 14:25:40 -0200 | [diff] [blame] | 5 | #include <stdbool.h> |
Arnaldo Carvalho de Melo | 5aab621 | 2010-03-25 19:59:00 -0300 | [diff] [blame] | 6 | #include <stdint.h> |
| 7 | #include "map.h" |
Roberto Agostino Vitillo | b538752 | 2012-02-09 23:21:01 +0100 | [diff] [blame] | 8 | #include "../perf.h" |
Arnaldo Carvalho de Melo | 5da5025 | 2009-07-01 14:46:08 -0300 | [diff] [blame] | 9 | #include <linux/list.h> |
Arnaldo Carvalho de Melo | 43cbcd8 | 2009-07-01 12:28:37 -0300 | [diff] [blame] | 10 | #include <linux/rbtree.h> |
Arnaldo Carvalho de Melo | 5aab621 | 2010-03-25 19:59:00 -0300 | [diff] [blame] | 11 | #include <stdio.h> |
Jiri Olsa | 8db4841 | 2012-05-30 14:23:42 +0200 | [diff] [blame] | 12 | #include <byteswap.h> |
Irina Tirdea | b771a83 | 2012-09-08 03:43:17 +0300 | [diff] [blame] | 13 | #include <libgen.h> |
Jiri Olsa | 4383db8 | 2012-10-27 23:18:29 +0200 | [diff] [blame] | 14 | #include "build-id.h" |
Jiri Olsa | 0776eb5 | 2014-05-05 12:41:45 +0200 | [diff] [blame] | 15 | #include "event.h" |
Arnaldo Carvalho de Melo | 972f393 | 2014-07-29 10:21:58 -0300 | [diff] [blame] | 16 | #include "util.h" |
Arnaldo Carvalho de Melo | a2928c4 | 2009-05-28 14:55:04 -0300 | [diff] [blame] | 17 | |
Ingo Molnar | 89fe808 | 2013-09-30 12:07:11 +0200 | [diff] [blame] | 18 | #ifdef HAVE_LIBELF_SUPPORT |
Cody P Schafer | b68e2f9 | 2012-08-10 15:22:57 -0700 | [diff] [blame] | 19 | #include <libelf.h> |
| 20 | #include <gelf.h> |
Cody P Schafer | b68e2f9 | 2012-08-10 15:22:57 -0700 | [diff] [blame] | 21 | #endif |
Namhyung Kim | eec185a | 2012-12-28 16:16:49 +0900 | [diff] [blame] | 22 | #include <elf.h> |
Cody P Schafer | b68e2f9 | 2012-08-10 15:22:57 -0700 | [diff] [blame] | 23 | |
Jiri Olsa | cdd059d | 2012-10-27 23:18:32 +0200 | [diff] [blame] | 24 | #include "dso.h" |
| 25 | |
Marti Raudsepp | 8408712 | 2009-10-24 19:10:36 +0300 | [diff] [blame] | 26 | /* |
| 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: |
| 29 | */ |
Ingo Molnar | 89fe808 | 2013-09-30 12:07:11 +0200 | [diff] [blame] | 30 | #ifdef HAVE_LIBELF_MMAP_SUPPORT |
Marti Raudsepp | 8408712 | 2009-10-24 19:10:36 +0300 | [diff] [blame] | 31 | # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP |
Namhyung Kim | 29a0fc9 | 2012-09-28 18:31:59 +0900 | [diff] [blame] | 32 | #else |
| 33 | # define PERF_ELF_C_READ_MMAP ELF_C_READ |
Marti Raudsepp | 8408712 | 2009-10-24 19:10:36 +0300 | [diff] [blame] | 34 | #endif |
| 35 | |
Masami Hiramatsu | 99ca423 | 2014-01-16 09:39:49 +0000 | [diff] [blame] | 36 | #ifdef HAVE_LIBELF_SUPPORT |
| 37 | extern Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, |
| 38 | GElf_Shdr *shp, const char *name, size_t *idx); |
| 39 | #endif |
| 40 | |
Arnaldo Carvalho de Melo | 247648e | 2009-08-11 16:22:11 -0300 | [diff] [blame] | 41 | #ifndef DMGL_PARAMS |
Namhyung Kim | e71e794 | 2014-07-31 14:47:42 +0900 | [diff] [blame] | 42 | #define DMGL_NO_OPTS 0 /* For readability... */ |
Arnaldo Carvalho de Melo | 247648e | 2009-08-11 16:22:11 -0300 | [diff] [blame] | 43 | #define DMGL_PARAMS (1 << 0) /* Include function args */ |
| 44 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ |
| 45 | #endif |
| 46 | |
Arnaldo Carvalho de Melo | 171b3be | 2011-03-11 13:36:01 -0300 | [diff] [blame] | 47 | /** struct symbol - symtab entry |
| 48 | * |
| 49 | * @ignore - resolvable but tools ignore it (e.g. idle routines) |
| 50 | */ |
Arnaldo Carvalho de Melo | a2928c4 | 2009-05-28 14:55:04 -0300 | [diff] [blame] | 51 | struct symbol { |
| 52 | struct rb_node rb_node; |
Paul Mackerras | 9cffa8d | 2009-06-19 22:21:42 +1000 | [diff] [blame] | 53 | u64 start; |
| 54 | u64 end; |
Arnaldo Carvalho de Melo | fefb0b9 | 2010-05-10 13:57:51 -0300 | [diff] [blame] | 55 | u16 namelen; |
Arnaldo Carvalho de Melo | c408fed | 2010-08-05 12:59:47 -0300 | [diff] [blame] | 56 | u8 binding; |
Arnaldo Carvalho de Melo | 171b3be | 2011-03-11 13:36:01 -0300 | [diff] [blame] | 57 | bool ignore; |
Arnaldo Carvalho de Melo | a2928c4 | 2009-05-28 14:55:04 -0300 | [diff] [blame] | 58 | char name[0]; |
| 59 | }; |
| 60 | |
Arnaldo Carvalho de Melo | aeafcba | 2011-03-31 10:56:28 -0300 | [diff] [blame] | 61 | void symbol__delete(struct symbol *sym); |
Jiri Olsa | cdd059d | 2012-10-27 23:18:32 +0200 | [diff] [blame] | 62 | void symbols__delete(struct rb_root *symbols); |
Arnaldo Carvalho de Melo | 628ada0 | 2010-02-25 12:57:40 -0300 | [diff] [blame] | 63 | |
Masami Hiramatsu | eb948e5 | 2014-02-06 05:32:25 +0000 | [diff] [blame] | 64 | /* symbols__for_each_entry - iterate over symbols (rb_root) |
| 65 | * |
| 66 | * @symbols: the rb_root of symbols |
| 67 | * @pos: the 'struct symbol *' to use as a loop cursor |
| 68 | * @nd: the 'struct rb_node *' to use as a temporary storage |
| 69 | */ |
| 70 | #define symbols__for_each_entry(symbols, pos, nd) \ |
| 71 | for (nd = rb_first(symbols); \ |
| 72 | nd && (pos = rb_entry(nd, struct symbol, rb_node)); \ |
| 73 | nd = rb_next(nd)) |
| 74 | |
Arnaldo Carvalho de Melo | 1b2e2df | 2012-04-19 10:57:06 -0300 | [diff] [blame] | 75 | static inline size_t symbol__size(const struct symbol *sym) |
| 76 | { |
Arnaldo Carvalho de Melo | 2c241bd | 2014-10-14 17:19:44 -0300 | [diff] [blame] | 77 | return sym->end - sym->start; |
Arnaldo Carvalho de Melo | 1b2e2df | 2012-04-19 10:57:06 -0300 | [diff] [blame] | 78 | } |
| 79 | |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 80 | struct strlist; |
David Ahern | e03eaa4 | 2015-03-24 09:52:41 -0600 | [diff] [blame] | 81 | struct intlist; |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 82 | |
Arnaldo Carvalho de Melo | b32d133 | 2009-11-24 12:05:15 -0200 | [diff] [blame] | 83 | struct symbol_conf { |
| 84 | unsigned short priv_size; |
Arnaldo Carvalho de Melo | d04b35f | 2011-11-11 22:17:32 -0200 | [diff] [blame] | 85 | unsigned short nr_events; |
Arnaldo Carvalho de Melo | b32d133 | 2009-11-24 12:05:15 -0200 | [diff] [blame] | 86 | bool try_vmlinux_path, |
Willy Tarreau | fc2be69 | 2013-09-14 10:32:59 +0200 | [diff] [blame] | 87 | ignore_vmlinux, |
Namhyung Kim | 00dc865 | 2014-11-04 10:14:32 +0900 | [diff] [blame] | 88 | ignore_vmlinux_buildid, |
Akihiro Nagai | 0bc8d20 | 2012-01-30 13:43:20 +0900 | [diff] [blame] | 89 | show_kernel_path, |
Arnaldo Carvalho de Melo | 79406cd | 2009-12-11 18:50:22 -0200 | [diff] [blame] | 90 | use_modules, |
Namhyung Kim | 680d926 | 2015-03-06 16:31:27 +0900 | [diff] [blame] | 91 | allow_aliases, |
Arnaldo Carvalho de Melo | d599db3 | 2009-12-15 20:04:42 -0200 | [diff] [blame] | 92 | sort_by_name, |
| 93 | show_nr_samples, |
Arnaldo Carvalho de Melo | 3f2728b | 2011-10-05 16:10:06 -0300 | [diff] [blame] | 94 | show_total_period, |
Arnaldo Carvalho de Melo | d599db3 | 2009-12-15 20:04:42 -0200 | [diff] [blame] | 95 | use_callchain, |
Namhyung Kim | f8be1c8 | 2012-09-11 13:15:07 +0900 | [diff] [blame] | 96 | cumulate_callchain, |
Arnaldo Carvalho de Melo | f7d8744 | 2009-12-27 21:37:04 -0200 | [diff] [blame] | 97 | exclude_other, |
Jovi Zhang | 85e00b5 | 2010-09-09 13:30:59 -0300 | [diff] [blame] | 98 | show_cpu_utilization, |
Arnaldo Carvalho de Melo | ec80fde | 2011-05-26 09:53:51 -0300 | [diff] [blame] | 99 | initialized, |
Stephane Eranian | 3e6a2a7 | 2011-05-17 17:32:07 +0200 | [diff] [blame] | 100 | kptr_restrict, |
| 101 | annotate_asm_raw, |
Namhyung Kim | 6e1f601 | 2013-01-22 18:09:32 +0900 | [diff] [blame] | 102 | annotate_src, |
Namhyung Kim | 328ccda | 2013-03-25 18:18:18 +0900 | [diff] [blame] | 103 | event_group, |
Namhyung Kim | f214833 | 2014-01-14 11:52:48 +0900 | [diff] [blame] | 104 | demangle, |
Avi Kivity | 763122a | 2014-09-13 07:15:05 +0300 | [diff] [blame] | 105 | demangle_kernel, |
Jiri Olsa | c830236 | 2014-06-27 18:26:58 +0200 | [diff] [blame] | 106 | filter_relative, |
Andi Kleen | 8b7bad5 | 2014-11-12 18:05:20 -0800 | [diff] [blame] | 107 | show_hist_headers, |
Arnaldo Carvalho de Melo | 0bc2f2f | 2015-07-13 08:21:57 -0300 | [diff] [blame] | 108 | branch_callstack, |
Kan Liang | 9e207dd | 2015-08-11 06:30:49 -0400 | [diff] [blame] | 109 | has_filter, |
| 110 | show_ref_callgraph; |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 111 | const char *vmlinux_name, |
David Ahern | b226a5a7 | 2010-12-07 19:39:46 -0700 | [diff] [blame] | 112 | *kallsyms_name, |
Chase Douglas | 9ed7e1b | 2010-06-14 15:26:30 -0400 | [diff] [blame] | 113 | *source_prefix, |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 114 | *field_sep; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 115 | const char *default_guest_vmlinux_name, |
| 116 | *default_guest_kallsyms, |
| 117 | *default_guest_modules; |
| 118 | const char *guestmount; |
Arnaldo Carvalho de Melo | edb7c60 | 2010-05-17 16:22:41 -0300 | [diff] [blame] | 119 | const char *dso_list_str, |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 120 | *comm_list_str, |
David Ahern | e03eaa4 | 2015-03-24 09:52:41 -0600 | [diff] [blame] | 121 | *pid_list_str, |
| 122 | *tid_list_str, |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 123 | *sym_list_str, |
| 124 | *col_width_list_str; |
| 125 | struct strlist *dso_list, |
| 126 | *comm_list, |
Stephane Eranian | a68c2c5 | 2012-03-08 23:47:48 +0100 | [diff] [blame] | 127 | *sym_list, |
| 128 | *dso_from_list, |
| 129 | *dso_to_list, |
| 130 | *sym_from_list, |
| 131 | *sym_to_list; |
David Ahern | e03eaa4 | 2015-03-24 09:52:41 -0600 | [diff] [blame] | 132 | struct intlist *pid_list, |
| 133 | *tid_list; |
David Ahern | ec5761e | 2010-12-09 13:27:07 -0700 | [diff] [blame] | 134 | const char *symfs; |
Arnaldo Carvalho de Melo | b32d133 | 2009-11-24 12:05:15 -0200 | [diff] [blame] | 135 | }; |
| 136 | |
Arnaldo Carvalho de Melo | 75be6cf | 2009-12-15 20:04:39 -0200 | [diff] [blame] | 137 | extern struct symbol_conf symbol_conf; |
Arnaldo Carvalho de Melo | 972f393 | 2014-07-29 10:21:58 -0300 | [diff] [blame] | 138 | |
| 139 | static inline int __symbol__join_symfs(char *bf, size_t size, const char *path) |
| 140 | { |
| 141 | return path__join(bf, size, symbol_conf.symfs, path); |
| 142 | } |
| 143 | |
| 144 | #define symbol__join_symfs(bf, path) __symbol__join_symfs(bf, sizeof(bf), path) |
| 145 | |
Arnaldo Carvalho de Melo | 3f067dc | 2012-12-07 17:39:39 -0300 | [diff] [blame] | 146 | extern int vmlinux_path__nr_entries; |
| 147 | extern char **vmlinux_path; |
Arnaldo Carvalho de Melo | 00a192b | 2009-10-30 16:28:24 -0200 | [diff] [blame] | 148 | |
Arnaldo Carvalho de Melo | aeafcba | 2011-03-31 10:56:28 -0300 | [diff] [blame] | 149 | static inline void *symbol__priv(struct symbol *sym) |
Arnaldo Carvalho de Melo | 00a192b | 2009-10-30 16:28:24 -0200 | [diff] [blame] | 150 | { |
Arnaldo Carvalho de Melo | aeafcba | 2011-03-31 10:56:28 -0300 | [diff] [blame] | 151 | return ((void *)sym) - symbol_conf.priv_size; |
Arnaldo Carvalho de Melo | 00a192b | 2009-10-30 16:28:24 -0200 | [diff] [blame] | 152 | } |
| 153 | |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 154 | struct ref_reloc_sym { |
| 155 | const char *name; |
| 156 | u64 addr; |
| 157 | u64 unrelocated_addr; |
| 158 | }; |
| 159 | |
Arnaldo Carvalho de Melo | 59fd530 | 2010-03-24 16:40:17 -0300 | [diff] [blame] | 160 | struct map_symbol { |
| 161 | struct map *map; |
| 162 | struct symbol *sym; |
| 163 | }; |
| 164 | |
Roberto Agostino Vitillo | b538752 | 2012-02-09 23:21:01 +0100 | [diff] [blame] | 165 | struct addr_map_symbol { |
| 166 | struct map *map; |
| 167 | struct symbol *sym; |
| 168 | u64 addr; |
Stephane Eranian | a68c2c5 | 2012-03-08 23:47:48 +0100 | [diff] [blame] | 169 | u64 al_addr; |
Roberto Agostino Vitillo | b538752 | 2012-02-09 23:21:01 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | struct branch_info { |
| 173 | struct addr_map_symbol from; |
| 174 | struct addr_map_symbol to; |
| 175 | struct branch_flags flags; |
| 176 | }; |
| 177 | |
Stephane Eranian | 98a3b32 | 2013-01-24 16:10:35 +0100 | [diff] [blame] | 178 | struct mem_info { |
| 179 | struct addr_map_symbol iaddr; |
| 180 | struct addr_map_symbol daddr; |
| 181 | union perf_mem_data_src data_src; |
| 182 | }; |
| 183 | |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 184 | struct addr_location { |
Arnaldo Carvalho de Melo | cc22e57 | 2013-12-19 17:20:06 -0300 | [diff] [blame] | 185 | struct machine *machine; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 186 | struct thread *thread; |
| 187 | struct map *map; |
| 188 | struct symbol *sym; |
| 189 | u64 addr; |
| 190 | char level; |
Namhyung Kim | b3cef7f | 2014-03-17 16:59:21 -0300 | [diff] [blame] | 191 | u8 filtered; |
Arun Sharma | f60f359 | 2010-06-04 11:27:10 -0300 | [diff] [blame] | 192 | u8 cpumode; |
| 193 | s32 cpu; |
Kan Liang | 0c4c4de | 2015-09-04 10:45:42 -0400 | [diff] [blame] | 194 | s32 socket; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 195 | }; |
| 196 | |
Cody P Schafer | b68e2f9 | 2012-08-10 15:22:57 -0700 | [diff] [blame] | 197 | struct symsrc { |
| 198 | char *name; |
| 199 | int fd; |
| 200 | enum dso_binary_type type; |
| 201 | |
Ingo Molnar | 89fe808 | 2013-09-30 12:07:11 +0200 | [diff] [blame] | 202 | #ifdef HAVE_LIBELF_SUPPORT |
Cody P Schafer | b68e2f9 | 2012-08-10 15:22:57 -0700 | [diff] [blame] | 203 | Elf *elf; |
| 204 | GElf_Ehdr ehdr; |
| 205 | |
| 206 | Elf_Scn *opdsec; |
| 207 | size_t opdidx; |
| 208 | GElf_Shdr opdshdr; |
| 209 | |
| 210 | Elf_Scn *symtab; |
| 211 | GElf_Shdr symshdr; |
| 212 | |
| 213 | Elf_Scn *dynsym; |
| 214 | size_t dynsym_idx; |
| 215 | GElf_Shdr dynshdr; |
| 216 | |
| 217 | bool adjust_symbols; |
Adrian Hunter | c6d8f2a | 2014-07-14 13:02:41 +0300 | [diff] [blame] | 218 | bool is_64_bit; |
Cody P Schafer | b68e2f9 | 2012-08-10 15:22:57 -0700 | [diff] [blame] | 219 | #endif |
| 220 | }; |
| 221 | |
| 222 | void symsrc__destroy(struct symsrc *ss); |
| 223 | int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, |
| 224 | enum dso_binary_type type); |
Cody P Schafer | d26cd12 | 2012-08-10 15:23:00 -0700 | [diff] [blame] | 225 | bool symsrc__has_symtab(struct symsrc *ss); |
Cody P Schafer | 3aafe5a | 2012-08-10 15:23:02 -0700 | [diff] [blame] | 226 | bool symsrc__possibly_runtime(struct symsrc *ss); |
Cody P Schafer | b68e2f9 | 2012-08-10 15:22:57 -0700 | [diff] [blame] | 227 | |
Arnaldo Carvalho de Melo | aeafcba | 2011-03-31 10:56:28 -0300 | [diff] [blame] | 228 | int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter); |
| 229 | int dso__load_vmlinux(struct dso *dso, struct map *map, |
Arnaldo Carvalho de Melo | 5230fb7 | 2013-12-10 11:58:52 -0300 | [diff] [blame] | 230 | const char *vmlinux, bool vmlinux_allocated, |
| 231 | symbol_filter_t filter); |
Arnaldo Carvalho de Melo | aeafcba | 2011-03-31 10:56:28 -0300 | [diff] [blame] | 232 | int dso__load_vmlinux_path(struct dso *dso, struct map *map, |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 233 | symbol_filter_t filter); |
Arnaldo Carvalho de Melo | aeafcba | 2011-03-31 10:56:28 -0300 | [diff] [blame] | 234 | int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map, |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 235 | symbol_filter_t filter); |
Arnaldo Carvalho de Melo | b0a9ab6 | 2010-03-15 11:46:58 -0300 | [diff] [blame] | 236 | |
Arnaldo Carvalho de Melo | aeafcba | 2011-03-31 10:56:28 -0300 | [diff] [blame] | 237 | struct symbol *dso__find_symbol(struct dso *dso, enum map_type type, |
| 238 | u64 addr); |
| 239 | struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, |
Arnaldo Carvalho de Melo | 79406cd | 2009-12-11 18:50:22 -0200 | [diff] [blame] | 240 | const char *name); |
Arnaldo Carvalho de Melo | 18bd726 | 2015-01-16 15:39:53 -0300 | [diff] [blame] | 241 | struct symbol *symbol__next_by_name(struct symbol *sym); |
Arnaldo Carvalho de Melo | a2928c4 | 2009-05-28 14:55:04 -0300 | [diff] [blame] | 242 | |
Adrian Hunter | 9c00a81 | 2014-07-14 13:02:50 +0300 | [diff] [blame] | 243 | struct symbol *dso__first_symbol(struct dso *dso, enum map_type type); |
| 244 | struct symbol *dso__next_symbol(struct symbol *sym); |
| 245 | |
Adrian Hunter | 2b5b8bb | 2014-07-22 16:17:59 +0300 | [diff] [blame] | 246 | enum dso_type dso__type_fd(int fd); |
| 247 | |
Arnaldo Carvalho de Melo | 2643ce1 | 2009-11-03 21:46:10 -0200 | [diff] [blame] | 248 | int filename__read_build_id(const char *filename, void *bf, size_t size); |
Arnaldo Carvalho de Melo | f1617b4 | 2009-11-18 20:20:52 -0200 | [diff] [blame] | 249 | int sysfs__read_build_id(const char *filename, void *bf, size_t size); |
Adrian Hunter | 316d70d | 2013-10-08 11:45:48 +0300 | [diff] [blame] | 250 | int modules__parse(const char *filename, void *arg, |
| 251 | int (*process_module)(void *arg, const char *name, |
| 252 | u64 start)); |
Namhyung Kim | e5a1845 | 2012-08-06 13:41:20 +0900 | [diff] [blame] | 253 | int filename__read_debuglink(const char *filename, char *debuglink, |
| 254 | size_t size); |
Arnaldo Carvalho de Melo | 2643ce1 | 2009-11-03 21:46:10 -0200 | [diff] [blame] | 255 | |
Kan Liang | ce80d3b | 2015-08-28 05:48:04 -0400 | [diff] [blame] | 256 | struct perf_env; |
| 257 | int symbol__init(struct perf_env *env); |
Arnaldo Carvalho de Melo | d65a458 | 2010-07-30 18:31:28 -0300 | [diff] [blame] | 258 | void symbol__exit(void); |
Namhyung Kim | 166ccc9 | 2012-08-06 13:41:19 +0900 | [diff] [blame] | 259 | void symbol__elf_init(void); |
Namhyung Kim | e5a1845 | 2012-08-06 13:41:20 +0900 | [diff] [blame] | 260 | struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name); |
Akihiro Nagai | a978f2a | 2012-01-30 13:43:15 +0900 | [diff] [blame] | 261 | size_t symbol__fprintf_symname_offs(const struct symbol *sym, |
| 262 | const struct addr_location *al, FILE *fp); |
Akihiro Nagai | 547a92e | 2012-01-30 13:42:57 +0900 | [diff] [blame] | 263 | size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp); |
Jiri Olsa | cdd059d | 2012-10-27 23:18:32 +0200 | [diff] [blame] | 264 | size_t symbol__fprintf(struct symbol *sym, FILE *fp); |
Arnaldo Carvalho de Melo | 36a3e64 | 2010-01-04 16:19:27 -0200 | [diff] [blame] | 265 | bool symbol_type__is_a(char symbol_type, enum map_type map_type); |
Arnaldo Carvalho de Melo | 3f067dc | 2012-12-07 17:39:39 -0300 | [diff] [blame] | 266 | bool symbol__restricted_filename(const char *filename, |
| 267 | const char *restricted_filename); |
David Ahern | 82d1deb | 2013-11-18 13:32:45 -0700 | [diff] [blame] | 268 | bool symbol__is_idle(struct symbol *sym); |
Arnaldo Carvalho de Melo | 36a3e64 | 2010-01-04 16:19:27 -0200 | [diff] [blame] | 269 | |
Cody P Schafer | 261360b | 2012-08-10 15:23:01 -0700 | [diff] [blame] | 270 | int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, |
| 271 | struct symsrc *runtime_ss, symbol_filter_t filter, |
| 272 | int kmodule); |
Cody P Schafer | a44f605 | 2012-08-10 15:22:59 -0700 | [diff] [blame] | 273 | int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, |
| 274 | struct map *map, symbol_filter_t filter); |
Namhyung Kim | e5a1845 | 2012-08-06 13:41:20 +0900 | [diff] [blame] | 275 | |
| 276 | void symbols__insert(struct rb_root *symbols, struct symbol *sym); |
| 277 | void symbols__fixup_duplicate(struct rb_root *symbols); |
| 278 | void symbols__fixup_end(struct rb_root *symbols); |
| 279 | void __map_groups__fixup_end(struct map_groups *mg, enum map_type type); |
| 280 | |
Adrian Hunter | 8e0cf96 | 2013-08-07 14:38:51 +0300 | [diff] [blame] | 281 | typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data); |
| 282 | int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data, |
| 283 | bool *is_64_bit); |
| 284 | |
Adrian Hunter | afba19d | 2013-10-09 15:01:12 +0300 | [diff] [blame] | 285 | #define PERF_KCORE_EXTRACT "/tmp/perf-kcore-XXXXXX" |
| 286 | |
| 287 | struct kcore_extract { |
| 288 | char *kcore_filename; |
| 289 | u64 addr; |
| 290 | u64 offs; |
| 291 | u64 len; |
| 292 | char extract_filename[sizeof(PERF_KCORE_EXTRACT)]; |
| 293 | int fd; |
| 294 | }; |
| 295 | |
| 296 | int kcore_extract__create(struct kcore_extract *kce); |
| 297 | void kcore_extract__delete(struct kcore_extract *kce); |
| 298 | |
Adrian Hunter | fc1b691 | 2013-10-14 16:57:29 +0300 | [diff] [blame] | 299 | int kcore_copy(const char *from_dir, const char *to_dir); |
| 300 | int compare_proc_modules(const char *from, const char *to); |
| 301 | |
David Ahern | 3bfe5f8 | 2013-11-18 13:32:48 -0700 | [diff] [blame] | 302 | int setup_list(struct strlist **list, const char *list_str, |
| 303 | const char *list_name); |
David Ahern | e03eaa4 | 2015-03-24 09:52:41 -0600 | [diff] [blame] | 304 | int setup_intlist(struct intlist **list, const char *list_str, |
| 305 | const char *list_name); |
David Ahern | 3bfe5f8 | 2013-11-18 13:32:48 -0700 | [diff] [blame] | 306 | |
Naveen N. Rao | d233209 | 2015-04-28 17:35:35 +0530 | [diff] [blame] | 307 | #ifdef HAVE_LIBELF_SUPPORT |
| 308 | bool elf__needs_adjust_symbols(GElf_Ehdr ehdr); |
Ananth N Mavinakayanahalli | c50fc0a | 2015-04-28 17:35:38 +0530 | [diff] [blame] | 309 | void arch__elf_sym_adjust(GElf_Sym *sym); |
Naveen N. Rao | d233209 | 2015-04-28 17:35:35 +0530 | [diff] [blame] | 310 | #endif |
| 311 | |
Naveen N. Rao | fb6d594 | 2015-04-28 17:35:36 +0530 | [diff] [blame] | 312 | #define SYMBOL_A 0 |
| 313 | #define SYMBOL_B 1 |
| 314 | |
| 315 | int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); |
| 316 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 317 | #endif /* __PERF_SYMBOL */ |