symbol.h 2.2 KB
Newer Older
1 2 3 4
#ifndef _PERF_SYMBOL_
#define _PERF_SYMBOL_ 1

#include <linux/types.h>
5
#include "types.h"
6
#include <linux/list.h>
7
#include <linux/rbtree.h>
8
#include "module.h"
9
#include "event.h"
10

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#ifdef HAVE_CPLUS_DEMANGLE
extern char *cplus_demangle(const char *, int);

static inline char *bfd_demangle(void __used *v, const char *c, int i)
{
	return cplus_demangle(c, i);
}
#else
#ifdef NO_DEMANGLE
static inline char *bfd_demangle(void __used *v, const char __used *c,
				 int __used i)
{
	return NULL;
}
#else
#include <bfd.h>
#endif
#endif

#ifndef DMGL_PARAMS
#define DMGL_PARAMS      (1 << 0)       /* Include function args */
#define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
#endif

35 36
struct symbol {
	struct rb_node	rb_node;
37 38 39 40 41
	u64		start;
	u64		end;
	u64		obj_start;
	u64		hist_sum;
	u64		*hist;
42
	struct module	*module;
43
	void		*priv;
44 45 46 47 48 49
	char		name[0];
};

struct dso {
	struct list_head node;
	struct rb_root	 syms;
50
	struct symbol    *(*find_symbol)(struct dso *, u64 ip);
51
	unsigned int	 sym_priv_size;
52
	unsigned char	 adjust_symbols;
53
	unsigned char	 slen_calculated;
54
	unsigned char	 origin;
55 56 57
	char		 name[0];
};

58
extern const char *sym_hist_filter;
59

60 61
typedef int (*symbol_filter_t)(struct dso *self, struct symbol *sym);

62
struct dso *dso__new(const char *name, unsigned int sym_priv_size);
63 64
void dso__delete(struct dso *self);

65 66 67 68 69
static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
{
	return ((void *)sym) - self->sym_priv_size;
}

70
struct symbol *dso__find_symbol(struct dso *self, u64 ip);
71

72
int dso__load_kernel(struct dso *self, const char *vmlinux,
73 74
		     symbol_filter_t filter, int verbose, int modules);
int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
75
int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
76 77
struct dso *dsos__findnew(const char *name);
void dsos__fprintf(FILE *fp);
78 79

size_t dso__fprintf(struct dso *self, FILE *fp);
80
char dso__symtab_origin(const struct dso *self);
81

82 83
int load_kernel(void);

84
void symbol__init(void);
85 86 87 88 89

extern struct list_head dsos;
extern struct dso *kernel_dso;
extern struct dso *vdso;
extern struct dso *hypervisor_dso;
90
extern const char *vmlinux_name;
91
extern int   modules;
92
#endif /* _PERF_SYMBOL_ */