blob: 3d9d346d101b2abb033b34942ded1764261c433e [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 Melo00a192b2009-10-30 16:28:24 -020052extern unsigned int symbol__priv_size;
53
54static inline void *symbol__priv(struct symbol *self)
55{
56 return ((void *)self) - symbol__priv_size;
57}
58
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030059struct dso {
60 struct list_head node;
61 struct rb_root syms;
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100062 struct symbol *(*find_symbol)(struct dso *, u64 ip);
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020063 u8 adjust_symbols:1;
64 u8 slen_calculated:1;
65 u8 loaded:1;
66 u8 has_build_id:1;
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030067 unsigned char origin;
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020068 u8 build_id[BUILD_ID_SIZE];
Arnaldo Carvalho de Melocfc10d32009-11-17 15:40:53 -020069 u16 long_name_len;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030070 const char *short_name;
71 char *long_name;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030072 char name[0];
73};
74
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020075struct dso *dso__new(const char *name);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030076void dso__delete(struct dso *self);
77
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100078struct symbol *dso__find_symbol(struct dso *self, u64 ip);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030079
Arnaldo Carvalho de Melof1617b42009-11-18 20:20:52 -020080int dsos__load_modules(void);
Arnaldo Carvalho de Melo6671cb12009-11-20 20:51:24 -020081int dsos__load_modules_sym(symbol_filter_t filter);
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020082struct dso *dsos__findnew(const char *name);
Arnaldo Carvalho de Melo6beba7a2009-10-21 17:34:06 -020083int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
Arnaldo Carvalho de Melo6671cb12009-11-20 20:51:24 -020084int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter,
85 int use_modules);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020086void dsos__fprintf(FILE *fp);
Arnaldo Carvalho de Melo9e03eb22009-11-16 16:32:44 -020087size_t dsos__fprintf_buildid(FILE *fp);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030088
Arnaldo Carvalho de Melo9e03eb22009-11-16 16:32:44 -020089size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030090size_t dso__fprintf(struct dso *self, FILE *fp);
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030091char dso__symtab_origin(const struct dso *self);
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020092void dso__set_build_id(struct dso *self, void *build_id);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030093
Arnaldo Carvalho de Melo2643ce1142009-11-03 21:46:10 -020094int filename__read_build_id(const char *filename, void *bf, size_t size);
Arnaldo Carvalho de Melof1617b42009-11-18 20:20:52 -020095int sysfs__read_build_id(const char *filename, void *bf, size_t size);
Arnaldo Carvalho de Meloe30a3d12009-11-18 20:20:51 -020096bool dsos__read_build_ids(void);
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -020097int build_id__sprintf(u8 *self, int len, char *bf);
Arnaldo Carvalho de Melo2643ce1142009-11-03 21:46:10 -020098
Arnaldo Carvalho de Melo24460422009-11-18 20:20:53 -020099struct dso *dsos__load_kernel(void);
Arnaldo Carvalho de Melo6671cb12009-11-20 20:51:24 -0200100int load_kernel(symbol_filter_t filter, bool use_modules);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200101
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -0200102void symbol__init(unsigned int priv_size);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200103
104extern struct list_head dsos;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -0300105extern struct map *kernel_map;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +0200106extern struct dso *vdso;
Ingo Molnar83a09442009-08-15 12:26:57 +0200107extern const char *vmlinux_name;
John Kacur8b40f522009-09-24 18:02:18 +0200108#endif /* __PERF_SYMBOL */