]> bbs.cooldavid.org Git - net-next-2.6.git/blame - tools/perf/util/symbol.h
perf symbols: Check if a struct machine instance was found
[net-next-2.6.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
4cf40131
ACM
12#define DEBUG_CACHE_DIR ".debug"
13
247648e3
ACM
14#ifdef HAVE_CPLUS_DEMANGLE
15extern char *cplus_demangle(const char *, int);
16
17static 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
23static 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
5aab621b
ACM
33int hex2u64(const char *ptr, u64 *val);
34char *strxfrchar(char *s, char from, char to);
35
84087126
MR
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
247648e3
ACM
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
5aab621b
ACM
51#define BUILD_ID_SIZE 20
52
a2928c42
ACM
53struct symbol {
54 struct rb_node rb_node;
9cffa8d5
PM
55 u64 start;
56 u64 end;
a2928c42
ACM
57 char name[0];
58};
59
628ada0c
ACM
60void symbol__delete(struct symbol *self);
61
655000e7
ACM
62struct strlist;
63
b32d133a
ACM
64struct symbol_conf {
65 unsigned short priv_size;
66 bool try_vmlinux_path,
79406cd7 67 use_modules,
d599db3f
ACM
68 sort_by_name,
69 show_nr_samples,
70 use_callchain,
f7d87444 71 exclude_other,
a1645ce1
ZY
72 full_paths,
73 show_cpu_utilization;
c410a338
ACM
74 const char *vmlinux_name,
75 *field_sep;
a1645ce1
ZY
76 const char *default_guest_vmlinux_name,
77 *default_guest_kallsyms,
78 *default_guest_modules;
79 const char *guestmount;
80 char *dso_list_str,
655000e7
ACM
81 *comm_list_str,
82 *sym_list_str,
83 *col_width_list_str;
84 struct strlist *dso_list,
85 *comm_list,
86 *sym_list;
b32d133a
ACM
87};
88
75be6cf4 89extern struct symbol_conf symbol_conf;
00a192b3
ACM
90
91static inline void *symbol__priv(struct symbol *self)
92{
75be6cf4 93 return ((void *)self) - symbol_conf.priv_size;
00a192b3
ACM
94}
95
9de89fe7
ACM
96struct ref_reloc_sym {
97 const char *name;
98 u64 addr;
99 u64 unrelocated_addr;
100};
101
59fd5306
ACM
102struct map_symbol {
103 struct map *map;
104 struct symbol *sym;
105};
106
1ed091c4
ACM
107struct addr_location {
108 struct thread *thread;
109 struct map *map;
110 struct symbol *sym;
111 u64 addr;
112 char level;
c410a338 113 bool filtered;
a1645ce1
ZY
114 unsigned int cpumode;
115};
116
117enum dso_kernel_type {
118 DSO_TYPE_USER = 0,
119 DSO_TYPE_KERNEL,
120 DSO_TYPE_GUEST_KERNEL
1ed091c4
ACM
121};
122
a2928c42
ACM
123struct dso {
124 struct list_head node;
6a4694a4 125 struct rb_root symbols[MAP__NR_TYPES];
79406cd7 126 struct rb_root symbol_names[MAP__NR_TYPES];
8d06367f
ACM
127 u8 adjust_symbols:1;
128 u8 slen_calculated:1;
8d06367f 129 u8 has_build_id:1;
a1645ce1 130 enum dso_kernel_type kernel;
88d3d9b7 131 u8 hit:1;
d06d92b7 132 u8 annotate_warned:1;
94cb9e38 133 unsigned char origin;
79406cd7 134 u8 sorted_by_name;
3610583c 135 u8 loaded;
8d06367f 136 u8 build_id[BUILD_ID_SIZE];
439d473b
ACM
137 const char *short_name;
138 char *long_name;
b63be8d7
ACM
139 u16 long_name_len;
140 u16 short_name_len;
a2928c42
ACM
141 char name[0];
142};
143
00a192b3 144struct dso *dso__new(const char *name);
fd1d908c 145struct dso *dso__new_kernel(const char *name);
a2928c42
ACM
146void dso__delete(struct dso *self);
147
3610583c 148bool dso__loaded(const struct dso *self, enum map_type type);
79406cd7
ACM
149bool dso__sorted_by_name(const struct dso *self, enum map_type type);
150
8d92c02a
ACM
151static inline void dso__set_loaded(struct dso *self, enum map_type type)
152{
153 self->loaded |= (1 << type);
154}
155
79406cd7 156void dso__sort_by_name(struct dso *self, enum map_type type);
3610583c 157
a89e5abe
ACM
158struct dso *__dsos__findnew(struct list_head *head, const char *name);
159
9de89fe7 160int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
a19afe46 161int dso__load_vmlinux_path(struct dso *self, struct map *map,
9de89fe7
ACM
162 symbol_filter_t filter);
163int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
164 symbol_filter_t filter);
5c0541d5
ACM
165int machine__load_kallsyms(struct machine *self, const char *filename,
166 enum map_type type, symbol_filter_t filter);
167int machine__load_vmlinux_path(struct machine *self, enum map_type type,
168 symbol_filter_t filter);
169
cbf69680
ACM
170size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp);
171size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits);
a2928c42 172
9e03eb2d 173size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
95011c60 174size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
b0a9ab62
ACM
175
176enum dso_origin {
177 DSO__ORIG_KERNEL = 0,
a1645ce1 178 DSO__ORIG_GUEST_KERNEL,
b0a9ab62
ACM
179 DSO__ORIG_JAVA_JIT,
180 DSO__ORIG_BUILD_ID_CACHE,
181 DSO__ORIG_FEDORA,
182 DSO__ORIG_UBUNTU,
183 DSO__ORIG_BUILDID,
184 DSO__ORIG_DSO,
a1645ce1 185 DSO__ORIG_GUEST_KMODULE,
b0a9ab62
ACM
186 DSO__ORIG_KMODULE,
187 DSO__ORIG_NOT_FOUND,
188};
189
94cb9e38 190char dso__symtab_origin(const struct dso *self);
b7cece76 191void dso__set_long_name(struct dso *self, char *name);
8d06367f 192void dso__set_build_id(struct dso *self, void *build_id);
23346f21 193void dso__read_running_kernel_build_id(struct dso *self, struct machine *machine);
ea08d8cb 194struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
79406cd7
ACM
195struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
196 const char *name);
a2928c42 197
2643ce11 198int filename__read_build_id(const char *filename, void *bf, size_t size);
f1617b40 199int sysfs__read_build_id(const char *filename, void *bf, size_t size);
a1645ce1 200bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
ef12a141 201int build_id__sprintf(const u8 *self, int len, char *bf);
9e201442
ACM
202int kallsyms__parse(const char *filename, void *arg,
203 int (*process_symbol)(void *arg, const char *name,
204 char type, u64 start));
2643ce11 205
d28c6223 206int __machine__create_kernel_maps(struct machine *self, struct dso *kernel);
5c0541d5
ACM
207int machine__create_kernel_maps(struct machine *self);
208
d28c6223
ACM
209int machines__create_kernel_maps(struct rb_root *self, pid_t pid);
210int machines__create_guest_kernel_maps(struct rb_root *self);
a1645ce1 211
75be6cf4 212int symbol__init(void);
36a3e646
ACM
213bool symbol_type__is_a(char symbol_type, enum map_type map_type);
214
b0a9ab62
ACM
215size_t vmlinux_path__fprintf(FILE *fp);
216
8b40f521 217#endif /* __PERF_SYMBOL */