perf, x86: Use ALTERNATIVE() to check for X86_FEATURE_PERFCTR_CORE
[deliverable/linux.git] / tools / perf / util / symbol.h
CommitLineData
8b40f521
JK
1#ifndef __PERF_SYMBOL
2#define __PERF_SYMBOL 1
a2928c42
ACM
3
4#include <linux/types.h>
e4204992 5#include <stdbool.h>
5aab621b
ACM
6#include <stdint.h>
7#include "map.h"
5da50258 8#include <linux/list.h>
43cbcd8a 9#include <linux/rbtree.h>
5aab621b 10#include <stdio.h>
a2928c42 11
247648e3
ACM
12#ifdef HAVE_CPLUS_DEMANGLE
13extern char *cplus_demangle(const char *, int);
14
15static inline char *bfd_demangle(void __used *v, const char *c, int i)
16{
17 return cplus_demangle(c, i);
18}
19#else
20#ifdef NO_DEMANGLE
21static inline char *bfd_demangle(void __used *v, const char __used *c,
22 int __used i)
23{
24 return NULL;
25}
26#else
27#include <bfd.h>
28#endif
29#endif
30
5aab621b
ACM
31int hex2u64(const char *ptr, u64 *val);
32char *strxfrchar(char *s, char from, char to);
33
84087126
MR
34/*
35 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
36 * for newer versions we can use mmap to reduce memory usage:
37 */
38#ifdef LIBELF_NO_MMAP
39# define PERF_ELF_C_READ_MMAP ELF_C_READ
40#else
41# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
42#endif
43
247648e3
ACM
44#ifndef DMGL_PARAMS
45#define DMGL_PARAMS (1 << 0) /* Include function args */
46#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
47#endif
48
5aab621b
ACM
49#define BUILD_ID_SIZE 20
50
171b3be9
ACM
51/** struct symbol - symtab entry
52 *
53 * @ignore - resolvable but tools ignore it (e.g. idle routines)
54 */
a2928c42
ACM
55struct symbol {
56 struct rb_node rb_node;
9cffa8d5
PM
57 u64 start;
58 u64 end;
fefb0b94 59 u16 namelen;
c408fedf 60 u8 binding;
171b3be9 61 bool ignore;
a2928c42
ACM
62 char name[0];
63};
64
628ada0c
ACM
65void symbol__delete(struct symbol *self);
66
655000e7
ACM
67struct strlist;
68
b32d133a
ACM
69struct symbol_conf {
70 unsigned short priv_size;
71 bool try_vmlinux_path,
79406cd7 72 use_modules,
d599db3f
ACM
73 sort_by_name,
74 show_nr_samples,
75 use_callchain,
f7d87444 76 exclude_other,
85e00b55
JZ
77 show_cpu_utilization,
78 initialized;
c410a338 79 const char *vmlinux_name,
b226a5a7 80 *kallsyms_name,
9ed7e1b8 81 *source_prefix,
c410a338 82 *field_sep;
a1645ce1
ZY
83 const char *default_guest_vmlinux_name,
84 *default_guest_kallsyms,
85 *default_guest_modules;
86 const char *guestmount;
edb7c60e 87 const char *dso_list_str,
655000e7
ACM
88 *comm_list_str,
89 *sym_list_str,
90 *col_width_list_str;
91 struct strlist *dso_list,
92 *comm_list,
93 *sym_list;
ec5761ea 94 const char *symfs;
b32d133a
ACM
95};
96
75be6cf4 97extern struct symbol_conf symbol_conf;
00a192b3
ACM
98
99static inline void *symbol__priv(struct symbol *self)
100{
75be6cf4 101 return ((void *)self) - symbol_conf.priv_size;
00a192b3
ACM
102}
103
9de89fe7
ACM
104struct ref_reloc_sym {
105 const char *name;
106 u64 addr;
107 u64 unrelocated_addr;
108};
109
59fd5306
ACM
110struct map_symbol {
111 struct map *map;
112 struct symbol *sym;
0f0cbf7a
ACM
113 bool unfolded;
114 bool has_children;
59fd5306
ACM
115};
116
1ed091c4
ACM
117struct addr_location {
118 struct thread *thread;
119 struct map *map;
120 struct symbol *sym;
121 u64 addr;
122 char level;
c410a338 123 bool filtered;
f60f3593
AS
124 u8 cpumode;
125 s32 cpu;
a1645ce1
ZY
126};
127
128enum dso_kernel_type {
129 DSO_TYPE_USER = 0,
130 DSO_TYPE_KERNEL,
131 DSO_TYPE_GUEST_KERNEL
1ed091c4
ACM
132};
133
a2928c42
ACM
134struct dso {
135 struct list_head node;
6a4694a4 136 struct rb_root symbols[MAP__NR_TYPES];
79406cd7 137 struct rb_root symbol_names[MAP__NR_TYPES];
6e406257 138 enum dso_kernel_type kernel;
8d06367f 139 u8 adjust_symbols:1;
8d06367f 140 u8 has_build_id:1;
88d3d9b7 141 u8 hit:1;
d06d92b7 142 u8 annotate_warned:1;
6e406257
ACM
143 u8 sname_alloc:1;
144 u8 lname_alloc:1;
878b439d 145 unsigned char symtab_type;
79406cd7 146 u8 sorted_by_name;
3610583c 147 u8 loaded;
8d06367f 148 u8 build_id[BUILD_ID_SIZE];
439d473b
ACM
149 const char *short_name;
150 char *long_name;
b63be8d7
ACM
151 u16 long_name_len;
152 u16 short_name_len;
a2928c42
ACM
153 char name[0];
154};
155
00a192b3 156struct dso *dso__new(const char *name);
fd1d908c 157struct dso *dso__new_kernel(const char *name);
a2928c42
ACM
158void dso__delete(struct dso *self);
159
8a6c5b26
ACM
160int dso__name_len(const struct dso *self);
161
3610583c 162bool dso__loaded(const struct dso *self, enum map_type type);
79406cd7
ACM
163bool dso__sorted_by_name(const struct dso *self, enum map_type type);
164
8d92c02a
ACM
165static inline void dso__set_loaded(struct dso *self, enum map_type type)
166{
167 self->loaded |= (1 << type);
168}
169
79406cd7 170void dso__sort_by_name(struct dso *self, enum map_type type);
3610583c 171
a89e5abe
ACM
172struct dso *__dsos__findnew(struct list_head *head, const char *name);
173
9de89fe7 174int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
fd930ff9
FBH
175int dso__load_vmlinux(struct dso *self, struct map *map,
176 const char *vmlinux, symbol_filter_t filter);
a19afe46 177int dso__load_vmlinux_path(struct dso *self, struct map *map,
9de89fe7
ACM
178 symbol_filter_t filter);
179int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
180 symbol_filter_t filter);
5c0541d5
ACM
181int machine__load_kallsyms(struct machine *self, const char *filename,
182 enum map_type type, symbol_filter_t filter);
183int machine__load_vmlinux_path(struct machine *self, enum map_type type,
184 symbol_filter_t filter);
185
1f626bc3
ACM
186size_t __dsos__fprintf(struct list_head *head, FILE *fp);
187
f869097e 188size_t machine__fprintf_dsos_buildid(struct machine *self, FILE *fp, bool with_hits);
cbf69680
ACM
189size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp);
190size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits);
a2928c42 191
9e03eb2d 192size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
90f18e63 193size_t dso__fprintf_symbols_by_name(struct dso *self, enum map_type type, FILE *fp);
95011c60 194size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
b0a9ab62 195
878b439d
ACM
196enum symtab_type {
197 SYMTAB__KALLSYMS = 0,
198 SYMTAB__GUEST_KALLSYMS,
199 SYMTAB__JAVA_JIT,
200 SYMTAB__BUILD_ID_CACHE,
201 SYMTAB__FEDORA_DEBUGINFO,
202 SYMTAB__UBUNTU_DEBUGINFO,
203 SYMTAB__BUILDID_DEBUGINFO,
204 SYMTAB__SYSTEM_PATH_DSO,
205 SYMTAB__GUEST_KMODULE,
206 SYMTAB__SYSTEM_PATH_KMODULE,
207 SYMTAB__NOT_FOUND,
b0a9ab62
ACM
208};
209
94cb9e38 210char dso__symtab_origin(const struct dso *self);
b7cece76 211void dso__set_long_name(struct dso *self, char *name);
8d06367f 212void dso__set_build_id(struct dso *self, void *build_id);
23346f21 213void dso__read_running_kernel_build_id(struct dso *self, struct machine *machine);
ea08d8cb 214struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
79406cd7
ACM
215struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
216 const char *name);
a2928c42 217
2643ce11 218int filename__read_build_id(const char *filename, void *bf, size_t size);
f1617b40 219int sysfs__read_build_id(const char *filename, void *bf, size_t size);
a1645ce1 220bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
ef12a141 221int build_id__sprintf(const u8 *self, int len, char *bf);
9e201442
ACM
222int kallsyms__parse(const char *filename, void *arg,
223 int (*process_symbol)(void *arg, const char *name,
3b01a413 224 char type, u64 start, u64 end));
2643ce11 225
076c6e45 226void machine__destroy_kernel_maps(struct machine *self);
d28c6223 227int __machine__create_kernel_maps(struct machine *self, struct dso *kernel);
5c0541d5
ACM
228int machine__create_kernel_maps(struct machine *self);
229
d28c6223
ACM
230int machines__create_kernel_maps(struct rb_root *self, pid_t pid);
231int machines__create_guest_kernel_maps(struct rb_root *self);
076c6e45 232void machines__destroy_guest_kernel_maps(struct rb_root *self);
a1645ce1 233
75be6cf4 234int symbol__init(void);
d65a458b 235void symbol__exit(void);
36a3e646
ACM
236bool symbol_type__is_a(char symbol_type, enum map_type map_type);
237
5ad90e4e 238size_t machine__fprintf_vmlinux_path(struct machine *self, FILE *fp);
b0a9ab62 239
8b40f521 240#endif /* __PERF_SYMBOL */
This page took 0.10399 seconds and 5 git commands to generate.