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