blob: 5339fd82ec96b8d15ca14dd2869c4453c85689c7 [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>
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +02005#include "types.h"
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -03006#include <linux/list.h>
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -03007#include <linux/rbtree.h>
Frederic Weisbecker66e274f2009-08-12 11:07:25 +02008#include "event.h"
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -03009
Arnaldo Carvalho de Melo247648e2009-08-11 16:22:11 -030010#ifdef HAVE_CPLUS_DEMANGLE
11extern char *cplus_demangle(const char *, int);
12
13static inline char *bfd_demangle(void __used *v, const char *c, int i)
14{
15 return cplus_demangle(c, i);
16}
17#else
18#ifdef NO_DEMANGLE
19static inline char *bfd_demangle(void __used *v, const char __used *c,
20 int __used i)
21{
22 return NULL;
23}
24#else
25#include <bfd.h>
26#endif
27#endif
28
29#ifndef DMGL_PARAMS
30#define DMGL_PARAMS (1 << 0) /* Include function args */
31#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
32#endif
33
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030034struct symbol {
35 struct rb_node rb_node;
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100036 u64 start;
37 u64 end;
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100038 u64 hist_sum;
39 u64 *hist;
Frederic Weisbecker301406b2009-06-13 00:11:21 +020040 void *priv;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030041 char name[0];
42};
43
44struct dso {
45 struct list_head node;
46 struct rb_root syms;
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100047 struct symbol *(*find_symbol)(struct dso *, u64 ip);
Arnaldo Carvalho de Melof5812a72009-06-30 11:43:17 -030048 unsigned int sym_priv_size;
Arnaldo Carvalho de Melo30d7a772009-07-02 21:24:14 -030049 unsigned char adjust_symbols;
Arnaldo Carvalho de Melo52d422d2009-07-10 22:47:28 -030050 unsigned char slen_calculated;
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030051 unsigned char origin;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030052 const char *short_name;
53 char *long_name;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030054 char name[0];
55};
56
Ingo Molnar83a09442009-08-15 12:26:57 +020057extern const char *sym_hist_filter;
Ingo Molnar0b73da32009-06-06 15:48:52 +020058
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030059typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
Arnaldo Carvalho de Melo69ee69f2009-05-28 14:55:26 -030060
Arnaldo Carvalho de Melo0085c9542009-05-28 14:55:13 -030061struct dso *dso__new(const char *name, unsigned int sym_priv_size);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030062void dso__delete(struct dso *self);
63
Arnaldo Carvalho de Melo0085c9542009-05-28 14:55:13 -030064static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
65{
66 return ((void *)sym) - self->sym_priv_size;
67}
68
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100069struct symbol *dso__find_symbol(struct dso *self, u64 ip);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030070
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030071int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size,
72 symbol_filter_t filter, int verbose, int modules);
73int dsos__load_modules(unsigned int sym_priv_size, symbol_filter_t filter,
74 int verbose);
75int dso__load(struct dso *self, struct map *map, symbol_filter_t filter,
76 int verbose);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020077struct dso *dsos__findnew(const char *name);
78void dsos__fprintf(FILE *fp);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030079
80size_t dso__fprintf(struct dso *self, FILE *fp);
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030081char dso__symtab_origin(const struct dso *self);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030082
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020083int load_kernel(void);
84
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030085void symbol__init(void);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020086
87extern struct list_head dsos;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030088extern struct map *kernel_map;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020089extern struct dso *vdso;
Ingo Molnar83a09442009-08-15 12:26:57 +020090extern const char *vmlinux_name;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020091extern int modules;
John Kacur8b40f522009-09-24 18:02:18 +020092#endif /* __PERF_SYMBOL */