symbol.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef __PERF_SYMBOL
  2. #define __PERF_SYMBOL 1
  3. #include <linux/types.h>
  4. #include "types.h"
  5. #include <linux/list.h>
  6. #include <linux/rbtree.h>
  7. #include "event.h"
  8. #ifdef HAVE_CPLUS_DEMANGLE
  9. extern char *cplus_demangle(const char *, int);
  10. static inline char *bfd_demangle(void __used *v, const char *c, int i)
  11. {
  12. return cplus_demangle(c, i);
  13. }
  14. #else
  15. #ifdef NO_DEMANGLE
  16. static inline char *bfd_demangle(void __used *v, const char __used *c,
  17. int __used i)
  18. {
  19. return NULL;
  20. }
  21. #else
  22. #include <bfd.h>
  23. #endif
  24. #endif
  25. #ifndef DMGL_PARAMS
  26. #define DMGL_PARAMS (1 << 0) /* Include function args */
  27. #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
  28. #endif
  29. struct symbol {
  30. struct rb_node rb_node;
  31. u64 start;
  32. u64 end;
  33. u64 hist_sum;
  34. u64 *hist;
  35. void *priv;
  36. char name[0];
  37. };
  38. struct dso {
  39. struct list_head node;
  40. struct rb_root syms;
  41. struct symbol *(*find_symbol)(struct dso *, u64 ip);
  42. unsigned int sym_priv_size;
  43. unsigned char adjust_symbols;
  44. unsigned char slen_calculated;
  45. unsigned char origin;
  46. const char *short_name;
  47. char *long_name;
  48. char name[0];
  49. };
  50. extern const char *sym_hist_filter;
  51. typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
  52. struct dso *dso__new(const char *name, unsigned int sym_priv_size);
  53. void dso__delete(struct dso *self);
  54. static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
  55. {
  56. return ((void *)sym) - self->sym_priv_size;
  57. }
  58. struct symbol *dso__find_symbol(struct dso *self, u64 ip);
  59. int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size,
  60. symbol_filter_t filter, int verbose, int modules);
  61. int dsos__load_modules(unsigned int sym_priv_size, symbol_filter_t filter,
  62. int verbose);
  63. int dso__load(struct dso *self, struct map *map, symbol_filter_t filter,
  64. int verbose);
  65. struct dso *dsos__findnew(const char *name);
  66. void dsos__fprintf(FILE *fp);
  67. size_t dso__fprintf(struct dso *self, FILE *fp);
  68. char dso__symtab_origin(const struct dso *self);
  69. int load_kernel(void);
  70. void symbol__init(void);
  71. extern struct list_head dsos;
  72. extern struct map *kernel_map;
  73. extern struct dso *vdso;
  74. extern const char *vmlinux_name;
  75. extern int modules;
  76. #endif /* __PERF_SYMBOL */