blob: a471a38407367d7432dad83d939ab922f4854bb8 [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
30#ifndef DMGL_PARAMS
31#define DMGL_PARAMS (1 << 0) /* Include function args */
32#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
33#endif
34
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030035struct symbol {
36 struct rb_node rb_node;
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100037 u64 start;
38 u64 end;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030039 char name[0];
40};
41
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020042extern unsigned int symbol__priv_size;
43
44static inline void *symbol__priv(struct symbol *self)
45{
46 return ((void *)self) - symbol__priv_size;
47}
48
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030049struct dso {
50 struct list_head node;
51 struct rb_root syms;
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100052 struct symbol *(*find_symbol)(struct dso *, u64 ip);
Arnaldo Carvalho de Melo30d7a772009-07-02 21:24:14 -030053 unsigned char adjust_symbols;
Arnaldo Carvalho de Melo52d422d2009-07-10 22:47:28 -030054 unsigned char slen_calculated;
Arnaldo Carvalho de Melo66bd8422009-10-28 21:51:21 -020055 bool loaded;
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030056 unsigned char origin;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030057 const char *short_name;
58 char *long_name;
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030059 char name[0];
60};
61
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020062struct dso *dso__new(const char *name);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030063void dso__delete(struct dso *self);
64
Paul Mackerras9cffa8d2009-06-19 22:21:42 +100065struct symbol *dso__find_symbol(struct dso *self, u64 ip);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030066
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020067int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, int modules);
68struct dso *dsos__findnew(const char *name);
Arnaldo Carvalho de Melo6beba7a2009-10-21 17:34:06 -020069int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020070void dsos__fprintf(FILE *fp);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030071
72size_t dso__fprintf(struct dso *self, FILE *fp);
Arnaldo Carvalho de Melo94cb9e32009-08-06 14:43:17 -030073char dso__symtab_origin(const struct dso *self);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030074
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020075int load_kernel(symbol_filter_t filter);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020076
Arnaldo Carvalho de Melo00a192b2009-10-30 16:28:24 -020077void symbol__init(unsigned int priv_size);
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020078
79extern struct list_head dsos;
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030080extern struct map *kernel_map;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020081extern struct dso *vdso;
Ingo Molnar83a09442009-08-15 12:26:57 +020082extern const char *vmlinux_name;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020083extern int modules;
John Kacur8b40f522009-09-24 18:02:18 +020084#endif /* __PERF_SYMBOL */