blob: 60151521f41d6bf959a1a003a9fbbf001cb7c03f [file] [log] [blame]
John Kacur8b40f522009-09-24 18:02:18 +02001#ifndef __PERF_SYMBOL
2#define __PERF_SYMBOL 1
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -03003
4#include <linux/types.h>
Arnaldo Carvalho de Meloe4204992009-10-20 14:25:40 -02005#include <stdbool.h>
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +02006#include "types.h"
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -03007#include <linux/list.h>
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -03008#include <linux/rbtree.h>
Frederic Weisbecker66e274f2009-08-12 11:07:25 +02009#include "event.h"
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030010
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -030011#ifdef HAVE_CPLUS_DEMANGLE
12extern char *cplus_demangle(const char *, int);
13
14static inline char *bfd_demangle(void __used *v, const char *c, int i)
15{
16 return cplus_demangle(c, i);
17}
18#else
19#ifdef NO_DEMANGLE
20static inline char *bfd_demangle(void __used *v, const char __used *c,
21 int __used i)
22{
23 return NULL;
24}
25#else
26#include <bfd.h>
27#endif
28#endif
29
Marti Raudsepp84087122009-10-24 19:10:36 +030030/*
31 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
32 * for newer versions we can use mmap to reduce memory usage:
33 */
34#ifdef LIBELF_NO_MMAP
35# define PERF_ELF_C_READ_MMAP ELF_C_READ
36#else
37# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
38#endif
39
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -030040#ifndef DMGL_PARAMS
41#define DMGL_PARAMS (1 << 0) /* Include function args */
42#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
43#endif
44
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030045struct symbol {
46 struct rb_node rb_node;
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100047 u64 start;
48 u64 end;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030049 char name[0];
50};
51
Arnaldo Carvalho de Melo655000e2009-12-15 20:04:40 -020052struct strlist;
53
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -020054struct symbol_conf {
55 unsigned short priv_size;
56 bool try_vmlinux_path,
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020057 use_modules,
58 sort_by_name;
Arnaldo Carvalho de Meloc410a332009-12-15 20:04:41 -020059 const char *vmlinux_name,
60 *field_sep;
Arnaldo Carvalho de Melo655000e2009-12-15 20:04:40 -020061 char *dso_list_str,
62 *comm_list_str,
63 *sym_list_str,
64 *col_width_list_str;
65 struct strlist *dso_list,
66 *comm_list,
67 *sym_list;
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -020068};
69
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -020070extern struct symbol_conf symbol_conf;
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020071
72static inline void *symbol__priv(struct symbol *self)
73{
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -020074 return ((void *)self) - symbol_conf.priv_size;
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020075}
76
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020077struct addr_location {
78 struct thread *thread;
79 struct map *map;
80 struct symbol *sym;
81 u64 addr;
82 char level;
Arnaldo Carvalho de Meloc410a332009-12-15 20:04:41 -020083 bool filtered;
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020084};
85
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030086struct dso {
87 struct list_head node;
Arnaldo Carvalho de Melo6a4694a2009-11-27 16:29:17 -020088 struct rb_root symbols[MAP__NR_TYPES];
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020089 struct rb_root symbol_names[MAP__NR_TYPES];
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020090 u8 adjust_symbols:1;
91 u8 slen_calculated:1;
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020092 u8 has_build_id:1;
Arnaldo Carvalho de Meloc338aee2009-11-20 20:51:27 -020093 u8 kernel:1;
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030094 unsigned char origin;
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020095 u8 sorted_by_name;
Arnaldo Carvalho de Melo36105832009-11-27 16:29:16 -020096 u8 loaded;
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020097 u8 build_id[BUILD_ID_SIZE];
Arnaldo Carvalho de Melocfc10d32009-11-17 15:40:53 -020098 u16 long_name_len;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030099 const char *short_name;
100 char *long_name;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300101 char name[0];
102};
103
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -0200104struct dso *dso__new(const char *name);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300105void dso__delete(struct dso *self);
106
Arnaldo Carvalho de Melo36105832009-11-27 16:29:16 -0200107bool dso__loaded(const struct dso *self, enum map_type type);
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -0200108bool dso__sorted_by_name(const struct dso *self, enum map_type type);
109
110void dso__sort_by_name(struct dso *self, enum map_type type);
Arnaldo Carvalho de Melo36105832009-11-27 16:29:16 -0200111
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200112struct perf_session;
113
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -0200114struct dso *dsos__findnew(const char *name);
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200115int dso__load(struct dso *self, struct map *map, struct perf_session *session,
116 symbol_filter_t filter);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200117void dsos__fprintf(FILE *fp);
Arnaldo Carvalho de Melo9e03eb22009-11-16 16:32:44 -0200118size_t dsos__fprintf_buildid(FILE *fp);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300119
Arnaldo Carvalho de Melo9e03eb22009-11-16 16:32:44 -0200120size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -0200121size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -0300122char dso__symtab_origin(const struct dso *self);
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -0200123void dso__set_build_id(struct dso *self, void *build_id);
Arnaldo Carvalho de Meloea08d8c2009-12-11 18:56:39 -0200124struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -0200125struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
126 const char *name);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300127
Arnaldo Carvalho de Melo2643ce12009-11-03 21:46:10 -0200128int filename__read_build_id(const char *filename, void *bf, size_t size);
Arnaldo Carvalho de Melof1617b42009-11-18 20:20:52 -0200129int sysfs__read_build_id(const char *filename, void *bf, size_t size);
Arnaldo Carvalho de Meloe30a3d12009-11-18 20:20:51 -0200130bool dsos__read_build_ids(void);
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -0200131int build_id__sprintf(u8 *self, int len, char *bf);
Arnaldo Carvalho de Melo2643ce12009-11-03 21:46:10 -0200132
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -0200133int symbol__init(void);
134int perf_session__create_kernel_maps(struct perf_session *self);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200135
Arnaldo Carvalho de Melob0da9542009-11-27 16:29:14 -0200136extern struct list_head dsos__user, dsos__kernel;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200137extern struct dso *vdso;
John Kacur8b40f522009-09-24 18:02:18 +0200138#endif /* __PERF_SYMBOL */