Merge branch 'linus' into perf/core
[deliverable/linux.git] / tools / perf / util / symbol.h
1 #ifndef __PERF_SYMBOL
2 #define __PERF_SYMBOL 1
3
4 #include <linux/types.h>
5 #include <stdbool.h>
6 #include <stdint.h>
7 #include "map.h"
8 #include <linux/list.h>
9 #include <linux/rbtree.h>
10 #include <stdio.h>
11
12 #define DEBUG_CACHE_DIR ".debug"
13
14 #ifdef HAVE_CPLUS_DEMANGLE
15 extern char *cplus_demangle(const char *, int);
16
17 static inline char *bfd_demangle(void __used *v, const char *c, int i)
18 {
19 return cplus_demangle(c, i);
20 }
21 #else
22 #ifdef NO_DEMANGLE
23 static inline char *bfd_demangle(void __used *v, const char __used *c,
24 int __used i)
25 {
26 return NULL;
27 }
28 #else
29 #include <bfd.h>
30 #endif
31 #endif
32
33 int hex2u64(const char *ptr, u64 *val);
34 char *strxfrchar(char *s, char from, char to);
35
36 /*
37 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
38 * for newer versions we can use mmap to reduce memory usage:
39 */
40 #ifdef LIBELF_NO_MMAP
41 # define PERF_ELF_C_READ_MMAP ELF_C_READ
42 #else
43 # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
44 #endif
45
46 #ifndef DMGL_PARAMS
47 #define DMGL_PARAMS (1 << 0) /* Include function args */
48 #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
49 #endif
50
51 #define BUILD_ID_SIZE 20
52
53 struct symbol {
54 struct rb_node rb_node;
55 u64 start;
56 u64 end;
57 char name[0];
58 };
59
60 void symbol__delete(struct symbol *self);
61
62 struct strlist;
63
64 struct symbol_conf {
65 unsigned short priv_size;
66 bool try_vmlinux_path,
67 use_modules,
68 sort_by_name,
69 show_nr_samples,
70 use_callchain,
71 exclude_other,
72 full_paths;
73 const char *vmlinux_name,
74 *field_sep;
75 char *dso_list_str,
76 *comm_list_str,
77 *sym_list_str,
78 *col_width_list_str;
79 struct strlist *dso_list,
80 *comm_list,
81 *sym_list;
82 };
83
84 extern struct symbol_conf symbol_conf;
85
86 static inline void *symbol__priv(struct symbol *self)
87 {
88 return ((void *)self) - symbol_conf.priv_size;
89 }
90
91 struct ref_reloc_sym {
92 const char *name;
93 u64 addr;
94 u64 unrelocated_addr;
95 };
96
97 struct map_symbol {
98 struct map *map;
99 struct symbol *sym;
100 };
101
102 struct addr_location {
103 struct thread *thread;
104 struct map *map;
105 struct symbol *sym;
106 u64 addr;
107 char level;
108 bool filtered;
109 };
110
111 struct dso {
112 struct list_head node;
113 struct rb_root symbols[MAP__NR_TYPES];
114 struct rb_root symbol_names[MAP__NR_TYPES];
115 u8 adjust_symbols:1;
116 u8 slen_calculated:1;
117 u8 has_build_id:1;
118 u8 kernel:1;
119 u8 hit:1;
120 u8 annotate_warned:1;
121 unsigned char origin;
122 u8 sorted_by_name;
123 u8 loaded;
124 u8 build_id[BUILD_ID_SIZE];
125 const char *short_name;
126 char *long_name;
127 u16 long_name_len;
128 u16 short_name_len;
129 char name[0];
130 };
131
132 struct dso *dso__new(const char *name);
133 struct dso *dso__new_kernel(const char *name);
134 void dso__delete(struct dso *self);
135
136 bool dso__loaded(const struct dso *self, enum map_type type);
137 bool dso__sorted_by_name(const struct dso *self, enum map_type type);
138
139 static inline void dso__set_loaded(struct dso *self, enum map_type type)
140 {
141 self->loaded |= (1 << type);
142 }
143
144 void dso__sort_by_name(struct dso *self, enum map_type type);
145
146 extern struct list_head dsos__user, dsos__kernel;
147
148 struct dso *__dsos__findnew(struct list_head *head, const char *name);
149
150 static inline struct dso *dsos__findnew(const char *name)
151 {
152 return __dsos__findnew(&dsos__user, name);
153 }
154
155 int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
156 int dso__load_vmlinux_path(struct dso *self, struct map *map,
157 symbol_filter_t filter);
158 int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
159 symbol_filter_t filter);
160 void dsos__fprintf(FILE *fp);
161 size_t dsos__fprintf_buildid(FILE *fp, bool with_hits);
162
163 size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
164 size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
165
166 enum dso_origin {
167 DSO__ORIG_KERNEL = 0,
168 DSO__ORIG_JAVA_JIT,
169 DSO__ORIG_BUILD_ID_CACHE,
170 DSO__ORIG_FEDORA,
171 DSO__ORIG_UBUNTU,
172 DSO__ORIG_BUILDID,
173 DSO__ORIG_DSO,
174 DSO__ORIG_KMODULE,
175 DSO__ORIG_NOT_FOUND,
176 };
177
178 char dso__symtab_origin(const struct dso *self);
179 void dso__set_long_name(struct dso *self, char *name);
180 void dso__set_build_id(struct dso *self, void *build_id);
181 void dso__read_running_kernel_build_id(struct dso *self);
182 struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
183 struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
184 const char *name);
185
186 int filename__read_build_id(const char *filename, void *bf, size_t size);
187 int sysfs__read_build_id(const char *filename, void *bf, size_t size);
188 bool dsos__read_build_ids(bool with_hits);
189 int build_id__sprintf(const u8 *self, int len, char *bf);
190 int kallsyms__parse(const char *filename, void *arg,
191 int (*process_symbol)(void *arg, const char *name,
192 char type, u64 start));
193
194 int symbol__init(void);
195 bool symbol_type__is_a(char symbol_type, enum map_type map_type);
196
197 size_t vmlinux_path__fprintf(FILE *fp);
198
199 #endif /* __PERF_SYMBOL */
This page took 0.035624 seconds and 6 git commands to generate.