symbol.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 strlist;
  46. struct symbol_conf {
  47. unsigned short priv_size;
  48. bool try_vmlinux_path,
  49. use_modules,
  50. sort_by_name,
  51. show_nr_samples,
  52. use_callchain,
  53. exclude_other,
  54. full_paths;
  55. const char *vmlinux_name,
  56. *field_sep;
  57. char *dso_list_str,
  58. *comm_list_str,
  59. *sym_list_str,
  60. *col_width_list_str;
  61. struct strlist *dso_list,
  62. *comm_list,
  63. *sym_list;
  64. };
  65. extern struct symbol_conf symbol_conf;
  66. static inline void *symbol__priv(struct symbol *self)
  67. {
  68. return ((void *)self) - symbol_conf.priv_size;
  69. }
  70. struct addr_location {
  71. struct thread *thread;
  72. struct map *map;
  73. struct symbol *sym;
  74. u64 addr;
  75. char level;
  76. bool filtered;
  77. };
  78. struct dso {
  79. struct list_head node;
  80. struct rb_root symbols[MAP__NR_TYPES];
  81. struct rb_root symbol_names[MAP__NR_TYPES];
  82. u8 adjust_symbols:1;
  83. u8 slen_calculated:1;
  84. u8 has_build_id:1;
  85. u8 kernel:1;
  86. unsigned char origin;
  87. u8 sorted_by_name;
  88. u8 loaded;
  89. u8 build_id[BUILD_ID_SIZE];
  90. u16 long_name_len;
  91. const char *short_name;
  92. char *long_name;
  93. char name[0];
  94. };
  95. struct dso *dso__new(const char *name);
  96. void dso__delete(struct dso *self);
  97. bool dso__loaded(const struct dso *self, enum map_type type);
  98. bool dso__sorted_by_name(const struct dso *self, enum map_type type);
  99. void dso__sort_by_name(struct dso *self, enum map_type type);
  100. struct perf_session;
  101. struct dso *dsos__findnew(const char *name);
  102. int dso__load(struct dso *self, struct map *map, struct perf_session *session,
  103. symbol_filter_t filter);
  104. void dsos__fprintf(FILE *fp);
  105. size_t dsos__fprintf_buildid(FILE *fp);
  106. size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
  107. size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
  108. char dso__symtab_origin(const struct dso *self);
  109. void dso__set_build_id(struct dso *self, void *build_id);
  110. struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
  111. struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
  112. const char *name);
  113. int filename__read_build_id(const char *filename, void *bf, size_t size);
  114. int sysfs__read_build_id(const char *filename, void *bf, size_t size);
  115. bool dsos__read_build_ids(void);
  116. int build_id__sprintf(u8 *self, int len, char *bf);
  117. int symbol__init(void);
  118. int perf_session__create_kernel_maps(struct perf_session *self);
  119. extern struct list_head dsos__user, dsos__kernel;
  120. extern struct dso *vdso;
  121. #endif /* __PERF_SYMBOL */