blob: 941ef331790ef70d80cade87fa89af2fbab14859 [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 Melob32d1332009-11-24 12:05:15 -020052struct symbol_conf {
53 unsigned short priv_size;
54 bool try_vmlinux_path,
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020055 use_modules,
56 sort_by_name;
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -020057 const char *vmlinux_name;
58};
59
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020060extern unsigned int symbol__priv_size;
61
62static inline void *symbol__priv(struct symbol *self)
63{
64 return ((void *)self) - symbol__priv_size;
65}
66
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020067struct addr_location {
68 struct thread *thread;
69 struct map *map;
70 struct symbol *sym;
71 u64 addr;
72 char level;
73};
74
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030075struct dso {
76 struct list_head node;
Arnaldo Carvalho de Melo6a4694a2009-11-27 16:29:17 -020077 struct rb_root symbols[MAP__NR_TYPES];
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020078 struct rb_root symbol_names[MAP__NR_TYPES];
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020079 u8 adjust_symbols:1;
80 u8 slen_calculated:1;
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020081 u8 has_build_id:1;
Arnaldo Carvalho de Meloc338aee2009-11-20 20:51:27 -020082 u8 kernel:1;
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030083 unsigned char origin;
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020084 u8 sorted_by_name;
Arnaldo Carvalho de Melo36105832009-11-27 16:29:16 -020085 u8 loaded;
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020086 u8 build_id[BUILD_ID_SIZE];
Arnaldo Carvalho de Melocfc10d32009-11-17 15:40:53 -020087 u16 long_name_len;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030088 const char *short_name;
89 char *long_name;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030090 char name[0];
91};
92
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020093struct dso *dso__new(const char *name);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030094void dso__delete(struct dso *self);
95
Arnaldo Carvalho de Melo36105832009-11-27 16:29:16 -020096bool dso__loaded(const struct dso *self, enum map_type type);
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020097bool dso__sorted_by_name(const struct dso *self, enum map_type type);
98
99void dso__sort_by_name(struct dso *self, enum map_type type);
Arnaldo Carvalho de Melo36105832009-11-27 16:29:16 -0200100
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200101struct perf_session;
102
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -0200103struct dso *dsos__findnew(const char *name);
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200104int dso__load(struct dso *self, struct map *map, struct perf_session *session,
105 symbol_filter_t filter);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200106void dsos__fprintf(FILE *fp);
Arnaldo Carvalho de Melo9e03eb22009-11-16 16:32:44 -0200107size_t dsos__fprintf_buildid(FILE *fp);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300108
Arnaldo Carvalho de Melo9e03eb22009-11-16 16:32:44 -0200109size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -0200110size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -0300111char dso__symtab_origin(const struct dso *self);
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -0200112void dso__set_build_id(struct dso *self, void *build_id);
Arnaldo Carvalho de Meloea08d8c2009-12-11 18:56:39 -0200113struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -0200114struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
115 const char *name);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300116
Arnaldo Carvalho de Melo2643ce12009-11-03 21:46:10 -0200117int filename__read_build_id(const char *filename, void *bf, size_t size);
Arnaldo Carvalho de Melof1617b42009-11-18 20:20:52 -0200118int sysfs__read_build_id(const char *filename, void *bf, size_t size);
Arnaldo Carvalho de Meloe30a3d12009-11-18 20:20:51 -0200119bool dsos__read_build_ids(void);
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -0200120int build_id__sprintf(u8 *self, int len, char *bf);
Arnaldo Carvalho de Melo2643ce12009-11-03 21:46:10 -0200121
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -0200122int symbol__init(struct symbol_conf *conf);
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200123int perf_session__create_kernel_maps(struct perf_session *self,
124 struct symbol_conf *conf);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200125
Arnaldo Carvalho de Melob0da9542009-11-27 16:29:14 -0200126extern struct list_head dsos__user, dsos__kernel;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200127extern struct dso *vdso;
John Kacur8b40f522009-09-24 18:02:18 +0200128#endif /* __PERF_SYMBOL */