2009-05-28 13:55:04 -04:00
|
|
|
#ifndef _PERF_SYMBOL_
|
|
|
|
#define _PERF_SYMBOL_ 1
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
2009-06-25 11:05:54 -04:00
|
|
|
#include "types.h"
|
2009-07-01 13:46:08 -04:00
|
|
|
#include <linux/list.h>
|
2009-07-01 11:28:37 -04:00
|
|
|
#include <linux/rbtree.h>
|
2009-07-02 02:08:36 -04:00
|
|
|
#include "module.h"
|
2009-08-12 05:07:25 -04:00
|
|
|
#include "event.h"
|
2009-05-28 13:55:04 -04:00
|
|
|
|
2009-08-11 15:22:11 -04:00
|
|
|
#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
|
|
|
|
|
2009-10-24 12:10:36 -04:00
|
|
|
/*
|
|
|
|
* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
|
|
|
|
* for newer versions we can use mmap to reduce memory usage:
|
|
|
|
*/
|
|
|
|
#ifdef LIBELF_NO_MMAP
|
|
|
|
# define PERF_ELF_C_READ_MMAP ELF_C_READ
|
|
|
|
#else
|
|
|
|
# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
|
|
|
|
#endif
|
|
|
|
|
2009-08-11 15:22:11 -04:00
|
|
|
#ifndef DMGL_PARAMS
|
|
|
|
#define DMGL_PARAMS (1 << 0) /* Include function args */
|
|
|
|
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
|
|
|
|
#endif
|
|
|
|
|
2009-05-28 13:55:04 -04:00
|
|
|
struct symbol {
|
|
|
|
struct rb_node rb_node;
|
perf_counter tools: Define and use our own u64, s64 etc. definitions
On 64-bit powerpc, __u64 is defined to be unsigned long rather than
unsigned long long. This causes compiler warnings every time we
print a __u64 value with %Lx.
Rather than changing __u64, we define our own u64 to be unsigned long
long on all architectures, and similarly s64 as signed long long.
For consistency we also define u32, s32, u16, s16, u8 and s8. These
definitions are put in a new header, types.h, because these definitions
are needed in util/string.h and util/symbol.h.
The main change here is the mechanical change of __[us]{64,32,16,8}
to remove the "__". The other changes are:
* Create types.h
* Include types.h in perf.h, util/string.h and util/symbol.h
* Add types.h to the LIB_H definition in Makefile
* Added (u64) casts in process_overflow_event() and print_sym_table()
to kill two remaining warnings.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: benh@kernel.crashing.org
LKML-Reference: <19003.33494.495844.956580@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-06-19 08:21:42 -04:00
|
|
|
u64 start;
|
|
|
|
u64 end;
|
|
|
|
u64 obj_start;
|
|
|
|
u64 hist_sum;
|
|
|
|
u64 *hist;
|
2009-07-02 02:08:36 -04:00
|
|
|
struct module *module;
|
2009-06-12 18:11:21 -04:00
|
|
|
void *priv;
|
2009-05-28 13:55:04 -04:00
|
|
|
char name[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dso {
|
|
|
|
struct list_head node;
|
|
|
|
struct rb_root syms;
|
perf_counter tools: Define and use our own u64, s64 etc. definitions
On 64-bit powerpc, __u64 is defined to be unsigned long rather than
unsigned long long. This causes compiler warnings every time we
print a __u64 value with %Lx.
Rather than changing __u64, we define our own u64 to be unsigned long
long on all architectures, and similarly s64 as signed long long.
For consistency we also define u32, s32, u16, s16, u8 and s8. These
definitions are put in a new header, types.h, because these definitions
are needed in util/string.h and util/symbol.h.
The main change here is the mechanical change of __[us]{64,32,16,8}
to remove the "__". The other changes are:
* Create types.h
* Include types.h in perf.h, util/string.h and util/symbol.h
* Add types.h to the LIB_H definition in Makefile
* Added (u64) casts in process_overflow_event() and print_sym_table()
to kill two remaining warnings.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: benh@kernel.crashing.org
LKML-Reference: <19003.33494.495844.956580@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-06-19 08:21:42 -04:00
|
|
|
struct symbol *(*find_symbol)(struct dso *, u64 ip);
|
2009-06-30 10:43:17 -04:00
|
|
|
unsigned int sym_priv_size;
|
2009-07-02 20:24:14 -04:00
|
|
|
unsigned char adjust_symbols;
|
2009-07-10 21:47:28 -04:00
|
|
|
unsigned char slen_calculated;
|
2009-08-06 13:43:17 -04:00
|
|
|
unsigned char origin;
|
2009-05-28 13:55:04 -04:00
|
|
|
char name[0];
|
|
|
|
};
|
|
|
|
|
2009-08-15 06:26:57 -04:00
|
|
|
extern const char *sym_hist_filter;
|
perf_counter tools: Add 'perf annotate' feature
Add new perf sub-command to display annotated source code:
$ perf annotate decode_tree_entry
------------------------------------------------
Percent | Source code & Disassembly of /home/mingo/git/git
------------------------------------------------
:
: /home/mingo/git/git: file format elf64-x86-64
:
:
: Disassembly of section .text:
:
: 00000000004a0da0 <decode_tree_entry>:
: *modep = mode;
: return str;
: }
:
: static void decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size)
: {
3.82 : 4a0da0: 41 54 push %r12
: const char *path;
: unsigned int mode, len;
:
: if (size < 24 || buf[size - 21])
0.17 : 4a0da2: 48 83 fa 17 cmp $0x17,%rdx
: *modep = mode;
: return str;
: }
:
: static void decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size)
: {
0.00 : 4a0da6: 49 89 fc mov %rdi,%r12
0.00 : 4a0da9: 55 push %rbp
3.37 : 4a0daa: 53 push %rbx
: const char *path;
: unsigned int mode, len;
:
: if (size < 24 || buf[size - 21])
0.08 : 4a0dab: 76 73 jbe 4a0e20 <decode_tree_entry+0x80>
0.00 : 4a0dad: 80 7c 16 eb 00 cmpb $0x0,-0x15(%rsi,%rdx,1)
3.48 : 4a0db2: 75 6c jne 4a0e20 <decode_tree_entry+0x80>
: static const char *get_mode(const char *str, unsigned int *modep)
: {
: unsigned char c;
: unsigned int mode = 0;
:
: if (*str == ' ')
1.94 : 4a0db4: 0f b6 06 movzbl (%rsi),%eax
0.39 : 4a0db7: 3c 20 cmp $0x20,%al
0.00 : 4a0db9: 74 65 je 4a0e20 <decode_tree_entry+0x80>
: return NULL;
:
: while ((c = *str++) != ' ') {
0.06 : 4a0dbb: 89 c2 mov %eax,%edx
: if (c < '0' || c > '7')
1.99 : 4a0dbd: 31 ed xor %ebp,%ebp
: unsigned int mode = 0;
:
: if (*str == ' ')
: return NULL;
:
: while ((c = *str++) != ' ') {
1.74 : 4a0dbf: 48 8d 5e 01 lea 0x1(%rsi),%rbx
: if (c < '0' || c > '7')
0.00 : 4a0dc3: 8d 42 d0 lea -0x30(%rdx),%eax
0.17 : 4a0dc6: 3c 07 cmp $0x7,%al
0.00 : 4a0dc8: 76 0d jbe 4a0dd7 <decode_tree_entry+0x37>
0.00 : 4a0dca: eb 54 jmp 4a0e20 <decode_tree_entry+0x80>
0.00 : 4a0dcc: 0f 1f 40 00 nopl 0x0(%rax)
16.57 : 4a0dd0: 8d 42 d0 lea -0x30(%rdx),%eax
0.14 : 4a0dd3: 3c 07 cmp $0x7,%al
0.00 : 4a0dd5: 77 49 ja 4a0e20 <decode_tree_entry+0x80>
: return NULL;
: mode = (mode << 3) + (c - '0');
3.12 : 4a0dd7: 0f b6 c2 movzbl %dl,%eax
: unsigned int mode = 0;
:
: if (*str == ' ')
: return NULL;
:
: while ((c = *str++) != ' ') {
0.00 : 4a0dda: 0f b6 13 movzbl (%rbx),%edx
16.74 : 4a0ddd: 48 83 c3 01 add $0x1,%rbx
: if (c < '0' || c > '7')
: return NULL;
: mode = (mode << 3) + (c - '0');
The first column is the percentage of samples that arrived on that
particular line - relative to the total cost of the function.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-06-06 09:48:52 -04:00
|
|
|
|
2009-05-28 13:55:26 -04:00
|
|
|
typedef int (*symbol_filter_t)(struct dso *self, struct symbol *sym);
|
|
|
|
|
2009-05-28 13:55:13 -04:00
|
|
|
struct dso *dso__new(const char *name, unsigned int sym_priv_size);
|
2009-05-28 13:55:04 -04:00
|
|
|
void dso__delete(struct dso *self);
|
|
|
|
|
2009-05-28 13:55:13 -04:00
|
|
|
static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
|
|
|
|
{
|
|
|
|
return ((void *)sym) - self->sym_priv_size;
|
|
|
|
}
|
|
|
|
|
perf_counter tools: Define and use our own u64, s64 etc. definitions
On 64-bit powerpc, __u64 is defined to be unsigned long rather than
unsigned long long. This causes compiler warnings every time we
print a __u64 value with %Lx.
Rather than changing __u64, we define our own u64 to be unsigned long
long on all architectures, and similarly s64 as signed long long.
For consistency we also define u32, s32, u16, s16, u8 and s8. These
definitions are put in a new header, types.h, because these definitions
are needed in util/string.h and util/symbol.h.
The main change here is the mechanical change of __[us]{64,32,16,8}
to remove the "__". The other changes are:
* Create types.h
* Include types.h in perf.h, util/string.h and util/symbol.h
* Add types.h to the LIB_H definition in Makefile
* Added (u64) casts in process_overflow_event() and print_sym_table()
to kill two remaining warnings.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: benh@kernel.crashing.org
LKML-Reference: <19003.33494.495844.956580@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-06-19 08:21:42 -04:00
|
|
|
struct symbol *dso__find_symbol(struct dso *self, u64 ip);
|
2009-05-28 13:55:04 -04:00
|
|
|
|
2009-05-28 13:55:26 -04:00
|
|
|
int dso__load_kernel(struct dso *self, const char *vmlinux,
|
2009-07-02 02:08:36 -04:00
|
|
|
symbol_filter_t filter, int verbose, int modules);
|
|
|
|
int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
|
2009-06-04 08:13:04 -04:00
|
|
|
int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
|
2009-08-12 04:03:49 -04:00
|
|
|
struct dso *dsos__findnew(const char *name);
|
|
|
|
void dsos__fprintf(FILE *fp);
|
2009-05-28 13:55:04 -04:00
|
|
|
|
|
|
|
size_t dso__fprintf(struct dso *self, FILE *fp);
|
2009-08-06 13:43:17 -04:00
|
|
|
char dso__symtab_origin(const struct dso *self);
|
2009-05-28 13:55:04 -04:00
|
|
|
|
2009-08-12 04:03:49 -04:00
|
|
|
int load_kernel(void);
|
|
|
|
|
2009-05-28 13:55:04 -04:00
|
|
|
void symbol__init(void);
|
2009-08-12 04:03:49 -04:00
|
|
|
|
|
|
|
extern struct list_head dsos;
|
|
|
|
extern struct dso *kernel_dso;
|
|
|
|
extern struct dso *vdso;
|
|
|
|
extern struct dso *hypervisor_dso;
|
2009-08-15 06:26:57 -04:00
|
|
|
extern const char *vmlinux_name;
|
2009-08-12 04:03:49 -04:00
|
|
|
extern int modules;
|
2009-05-28 13:55:04 -04:00
|
|
|
#endif /* _PERF_SYMBOL_ */
|