symbol.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef __PERF_SYMBOL
  2. #define __PERF_SYMBOL 1
  3. #include <linux/types.h>
  4. #include <stdbool.h>
  5. #include "types.h"
  6. #include <linux/list.h>
  7. #include <linux/rbtree.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. /*
  27. * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
  28. * for newer versions we can use mmap to reduce memory usage:
  29. */
  30. #ifdef LIBELF_NO_MMAP
  31. # define PERF_ELF_C_READ_MMAP ELF_C_READ
  32. #else
  33. # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
  34. #endif
  35. #ifndef DMGL_PARAMS
  36. #define DMGL_PARAMS (1 << 0) /* Include function args */
  37. #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
  38. #endif
  39. struct symbol {
  40. struct rb_node rb_node;
  41. u64 start;
  42. u64 end;
  43. char name[0];
  44. };
  45. struct symbol_conf {
  46. unsigned short priv_size;
  47. bool try_vmlinux_path,
  48. use_modules;
  49. const char *vmlinux_name;
  50. };
  51. extern unsigned int symbol__priv_size;
  52. static inline void *symbol__priv(struct symbol *self)
  53. {
  54. return ((void *)self) - symbol__priv_size;
  55. }
  56. struct dso {
  57. struct list_head node;
  58. struct rb_root symbols[MAP__NR_TYPES];
  59. struct symbol *(*find_symbol)(struct dso *self,
  60. enum map_type type, u64 addr);
  61. u8 adjust_symbols:1;
  62. u8 slen_calculated:1;
  63. u8 has_build_id:1;
  64. u8 kernel:1;
  65. unsigned char origin;
  66. u8 loaded;
  67. u8 build_id[BUILD_ID_SIZE];
  68. u16 long_name_len;
  69. const char *short_name;
  70. char *long_name;
  71. char name[0];
  72. };
  73. struct dso *dso__new(const char *name);
  74. void dso__delete(struct dso *self);
  75. bool dso__loaded(const struct dso *self, enum map_type type);
  76. struct dso *dsos__findnew(const char *name);
  77. int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
  78. void dsos__fprintf(FILE *fp);
  79. size_t dsos__fprintf_buildid(FILE *fp);
  80. size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
  81. size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
  82. char dso__symtab_origin(const struct dso *self);
  83. void dso__set_build_id(struct dso *self, void *build_id);
  84. int filename__read_build_id(const char *filename, void *bf, size_t size);
  85. int sysfs__read_build_id(const char *filename, void *bf, size_t size);
  86. bool dsos__read_build_ids(void);
  87. int build_id__sprintf(u8 *self, int len, char *bf);
  88. size_t kernel_maps__fprintf(FILE *fp);
  89. int symbol__init(struct symbol_conf *conf);
  90. extern struct list_head dsos__user, dsos__kernel;
  91. extern struct dso *vdso;
  92. #endif /* __PERF_SYMBOL */