aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/symbol.h')
-rw-r--r--tools/perf/util/symbol.h74
1 files changed, 58 insertions, 16 deletions
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index f30a37428919..478f5ab37787 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -3,10 +3,11 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include "types.h" 6#include <stdint.h>
7#include "map.h"
7#include <linux/list.h> 8#include <linux/list.h>
8#include <linux/rbtree.h> 9#include <linux/rbtree.h>
9#include "event.h" 10#include <stdio.h>
10 11
11#define DEBUG_CACHE_DIR ".debug" 12#define DEBUG_CACHE_DIR ".debug"
12 13
@@ -29,6 +30,9 @@ static inline char *bfd_demangle(void __used *v, const char __used *c,
29#endif 30#endif
30#endif 31#endif
31 32
33int hex2u64(const char *ptr, u64 *val);
34char *strxfrchar(char *s, char from, char to);
35
32/* 36/*
33 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; 37 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
34 * for newer versions we can use mmap to reduce memory usage: 38 * for newer versions we can use mmap to reduce memory usage:
@@ -44,6 +48,8 @@ static inline char *bfd_demangle(void __used *v, const char __used *c,
44#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ 48#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
45#endif 49#endif
46 50
51#define BUILD_ID_SIZE 20
52
47struct symbol { 53struct symbol {
48 struct rb_node rb_node; 54 struct rb_node rb_node;
49 u64 start; 55 u64 start;
@@ -63,10 +69,15 @@ struct symbol_conf {
63 show_nr_samples, 69 show_nr_samples,
64 use_callchain, 70 use_callchain,
65 exclude_other, 71 exclude_other,
66 full_paths; 72 full_paths,
73 show_cpu_utilization;
67 const char *vmlinux_name, 74 const char *vmlinux_name,
68 *field_sep; 75 *field_sep;
69 char *dso_list_str, 76 const char *default_guest_vmlinux_name,
77 *default_guest_kallsyms,
78 *default_guest_modules;
79 const char *guestmount;
80 char *dso_list_str,
70 *comm_list_str, 81 *comm_list_str,
71 *sym_list_str, 82 *sym_list_str,
72 *col_width_list_str; 83 *col_width_list_str;
@@ -88,6 +99,11 @@ struct ref_reloc_sym {
88 u64 unrelocated_addr; 99 u64 unrelocated_addr;
89}; 100};
90 101
102struct map_symbol {
103 struct map *map;
104 struct symbol *sym;
105};
106
91struct addr_location { 107struct addr_location {
92 struct thread *thread; 108 struct thread *thread;
93 struct map *map; 109 struct map *map;
@@ -95,6 +111,13 @@ struct addr_location {
95 u64 addr; 111 u64 addr;
96 char level; 112 char level;
97 bool filtered; 113 bool filtered;
114 unsigned int cpumode;
115};
116
117enum dso_kernel_type {
118 DSO_TYPE_USER = 0,
119 DSO_TYPE_KERNEL,
120 DSO_TYPE_GUEST_KERNEL
98}; 121};
99 122
100struct dso { 123struct dso {
@@ -104,8 +127,9 @@ struct dso {
104 u8 adjust_symbols:1; 127 u8 adjust_symbols:1;
105 u8 slen_calculated:1; 128 u8 slen_calculated:1;
106 u8 has_build_id:1; 129 u8 has_build_id:1;
107 u8 kernel:1; 130 enum dso_kernel_type kernel;
108 u8 hit:1; 131 u8 hit:1;
132 u8 annotate_warned:1;
109 unsigned char origin; 133 unsigned char origin;
110 u8 sorted_by_name; 134 u8 sorted_by_name;
111 u8 loaded; 135 u8 loaded;
@@ -131,42 +155,60 @@ static inline void dso__set_loaded(struct dso *self, enum map_type type)
131 155
132void dso__sort_by_name(struct dso *self, enum map_type type); 156void dso__sort_by_name(struct dso *self, enum map_type type);
133 157
134extern struct list_head dsos__user, dsos__kernel;
135
136struct dso *__dsos__findnew(struct list_head *head, const char *name); 158struct dso *__dsos__findnew(struct list_head *head, const char *name);
137 159
138static inline struct dso *dsos__findnew(const char *name)
139{
140 return __dsos__findnew(&dsos__user, name);
141}
142
143int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); 160int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
144int dso__load_vmlinux_path(struct dso *self, struct map *map, 161int dso__load_vmlinux_path(struct dso *self, struct map *map,
145 symbol_filter_t filter); 162 symbol_filter_t filter);
146int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map, 163int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
147 symbol_filter_t filter); 164 symbol_filter_t filter);
148void dsos__fprintf(FILE *fp); 165void dsos__fprintf(struct rb_root *kerninfo_root, FILE *fp);
149size_t dsos__fprintf_buildid(FILE *fp, bool with_hits); 166size_t dsos__fprintf_buildid(struct rb_root *kerninfo_root,
167 FILE *fp, bool with_hits);
150 168
151size_t dso__fprintf_buildid(struct dso *self, FILE *fp); 169size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
152size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp); 170size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
171
172enum dso_origin {
173 DSO__ORIG_KERNEL = 0,
174 DSO__ORIG_GUEST_KERNEL,
175 DSO__ORIG_JAVA_JIT,
176 DSO__ORIG_BUILD_ID_CACHE,
177 DSO__ORIG_FEDORA,
178 DSO__ORIG_UBUNTU,
179 DSO__ORIG_BUILDID,
180 DSO__ORIG_DSO,
181 DSO__ORIG_GUEST_KMODULE,
182 DSO__ORIG_KMODULE,
183 DSO__ORIG_NOT_FOUND,
184};
185
153char dso__symtab_origin(const struct dso *self); 186char dso__symtab_origin(const struct dso *self);
154void dso__set_long_name(struct dso *self, char *name); 187void dso__set_long_name(struct dso *self, char *name);
155void dso__set_build_id(struct dso *self, void *build_id); 188void dso__set_build_id(struct dso *self, void *build_id);
156void dso__read_running_kernel_build_id(struct dso *self); 189void dso__read_running_kernel_build_id(struct dso *self,
190 struct kernel_info *kerninfo);
157struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr); 191struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
158struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type, 192struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
159 const char *name); 193 const char *name);
160 194
161int filename__read_build_id(const char *filename, void *bf, size_t size); 195int filename__read_build_id(const char *filename, void *bf, size_t size);
162int sysfs__read_build_id(const char *filename, void *bf, size_t size); 196int sysfs__read_build_id(const char *filename, void *bf, size_t size);
163bool dsos__read_build_ids(bool with_hits); 197bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
164int build_id__sprintf(const u8 *self, int len, char *bf); 198int build_id__sprintf(const u8 *self, int len, char *bf);
165int kallsyms__parse(const char *filename, void *arg, 199int kallsyms__parse(const char *filename, void *arg,
166 int (*process_symbol)(void *arg, const char *name, 200 int (*process_symbol)(void *arg, const char *name,
167 char type, u64 start)); 201 char type, u64 start));
168 202
203int __map_groups__create_kernel_maps(struct map_groups *self,
204 struct map *vmlinux_maps[MAP__NR_TYPES],
205 struct dso *kernel);
206int map_groups__create_kernel_maps(struct rb_root *kerninfo_root, pid_t pid);
207int map_groups__create_guest_kernel_maps(struct rb_root *kerninfo_root);
208
169int symbol__init(void); 209int symbol__init(void);
170bool symbol_type__is_a(char symbol_type, enum map_type map_type); 210bool symbol_type__is_a(char symbol_type, enum map_type map_type);
171 211
212size_t vmlinux_path__fprintf(FILE *fp);
213
172#endif /* __PERF_SYMBOL */ 214#endif /* __PERF_SYMBOL */