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