symbol.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #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 obj_start;
  34. u64 hist_sum;
  35. u64 *hist;
  36. struct module *module;
  37. void *priv;
  38. char name[0];
  39. };
  40. struct dso {
  41. struct list_head node;
  42. struct rb_root syms;
  43. struct symbol *(*find_symbol)(struct dso *, u64 ip);
  44. unsigned int sym_priv_size;
  45. unsigned char adjust_symbols;
  46. unsigned char slen_calculated;
  47. unsigned char origin;
  48. char name[0];
  49. };
  50. const char *sym_hist_filter;
  51. typedef int (*symbol_filter_t)(struct dso *self, 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 dso__load_kernel(struct dso *self, const char *vmlinux,
  60. symbol_filter_t filter, int verbose, int modules);
  61. int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
  62. int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
  63. size_t dso__fprintf(struct dso *self, FILE *fp);
  64. char dso__symtab_origin(const struct dso *self);
  65. void symbol__init(void);
  66. #endif /* _PERF_SYMBOL_ */