jitdump.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * jitdump.h: jitted code info encapsulation file format
  3. *
  4. * Adapted from OProfile GPLv2 support jidump.h:
  5. * Copyright 2007 OProfile authors
  6. * Jens Wilke
  7. * Daniel Hansel
  8. * Copyright IBM Corporation 2007
  9. */
  10. #ifndef JITDUMP_H
  11. #define JITDUMP_H
  12. #include <sys/time.h>
  13. #include <time.h>
  14. #include <stdint.h>
  15. /* JiTD */
  16. #define JITHEADER_MAGIC 0x4A695444
  17. #define JITHEADER_MAGIC_SW 0x4454694A
  18. #define PADDING_8ALIGNED(x) ((((x) + 7) & 7) ^ 7)
  19. #define JITHEADER_VERSION 1
  20. enum jitdump_flags_bits {
  21. JITDUMP_FLAGS_MAX_BIT,
  22. };
  23. #define JITDUMP_FLAGS_RESERVED (JITDUMP_FLAGS_MAX_BIT < 64 ? \
  24. (~((1ULL << JITDUMP_FLAGS_MAX_BIT) - 1)) : 0)
  25. struct jitheader {
  26. uint32_t magic; /* characters "jItD" */
  27. uint32_t version; /* header version */
  28. uint32_t total_size; /* total size of header */
  29. uint32_t elf_mach; /* elf mach target */
  30. uint32_t pad1; /* reserved */
  31. uint32_t pid; /* JIT process id */
  32. uint64_t timestamp; /* timestamp */
  33. uint64_t flags; /* flags */
  34. };
  35. enum jit_record_type {
  36. JIT_CODE_LOAD = 0,
  37. JIT_CODE_MOVE = 1,
  38. JIT_CODE_DEBUG_INFO = 2,
  39. JIT_CODE_CLOSE = 3,
  40. JIT_CODE_MAX,
  41. };
  42. /* record prefix (mandatory in each record) */
  43. struct jr_prefix {
  44. uint32_t id;
  45. uint32_t total_size;
  46. uint64_t timestamp;
  47. };
  48. struct jr_code_load {
  49. struct jr_prefix p;
  50. uint32_t pid;
  51. uint32_t tid;
  52. uint64_t vma;
  53. uint64_t code_addr;
  54. uint64_t code_size;
  55. uint64_t code_index;
  56. };
  57. struct jr_code_close {
  58. struct jr_prefix p;
  59. };
  60. struct jr_code_move {
  61. struct jr_prefix p;
  62. uint32_t pid;
  63. uint32_t tid;
  64. uint64_t vma;
  65. uint64_t old_code_addr;
  66. uint64_t new_code_addr;
  67. uint64_t code_size;
  68. uint64_t code_index;
  69. };
  70. struct debug_entry {
  71. uint64_t addr;
  72. int lineno; /* source line number starting at 1 */
  73. int discrim; /* column discriminator, 0 is default */
  74. const char name[0]; /* null terminated filename, \xff\0 if same as previous entry */
  75. };
  76. struct jr_code_debug_info {
  77. struct jr_prefix p;
  78. uint64_t code_addr;
  79. uint64_t nr_entry;
  80. struct debug_entry entries[0];
  81. };
  82. union jr_entry {
  83. struct jr_code_debug_info info;
  84. struct jr_code_close close;
  85. struct jr_code_load load;
  86. struct jr_code_move move;
  87. struct jr_prefix prefix;
  88. };
  89. static inline struct debug_entry *
  90. debug_entry_next(struct debug_entry *ent)
  91. {
  92. void *a = ent + 1;
  93. size_t l = strlen(ent->name) + 1;
  94. return a + l;
  95. }
  96. static inline char *
  97. debug_entry_file(struct debug_entry *ent)
  98. {
  99. void *a = ent + 1;
  100. return a;
  101. }
  102. #endif /* !JITDUMP_H */