jitdump.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 ALIGN_8(x) (((x) + 7) & (~7))
  20. #define JITHEADER_VERSION 1
  21. enum jitdump_flags_bits {
  22. JITDUMP_FLAGS_ARCH_TIMESTAMP_BIT,
  23. JITDUMP_FLAGS_MAX_BIT,
  24. };
  25. #define JITDUMP_FLAGS_ARCH_TIMESTAMP (1ULL << JITDUMP_FLAGS_ARCH_TIMESTAMP_BIT)
  26. #define JITDUMP_FLAGS_RESERVED (JITDUMP_FLAGS_MAX_BIT < 64 ? \
  27. (~((1ULL << JITDUMP_FLAGS_MAX_BIT) - 1)) : 0)
  28. struct jitheader {
  29. uint32_t magic; /* characters "jItD" */
  30. uint32_t version; /* header version */
  31. uint32_t total_size; /* total size of header */
  32. uint32_t elf_mach; /* elf mach target */
  33. uint32_t pad1; /* reserved */
  34. uint32_t pid; /* JIT process id */
  35. uint64_t timestamp; /* timestamp */
  36. uint64_t flags; /* flags */
  37. };
  38. enum jit_record_type {
  39. JIT_CODE_LOAD = 0,
  40. JIT_CODE_MOVE = 1,
  41. JIT_CODE_DEBUG_INFO = 2,
  42. JIT_CODE_CLOSE = 3,
  43. JIT_CODE_UNWINDING_INFO = 4,
  44. JIT_CODE_MAX,
  45. };
  46. /* record prefix (mandatory in each record) */
  47. struct jr_prefix {
  48. uint32_t id;
  49. uint32_t total_size;
  50. uint64_t timestamp;
  51. };
  52. struct jr_code_load {
  53. struct jr_prefix p;
  54. uint32_t pid;
  55. uint32_t tid;
  56. uint64_t vma;
  57. uint64_t code_addr;
  58. uint64_t code_size;
  59. uint64_t code_index;
  60. };
  61. struct jr_code_close {
  62. struct jr_prefix p;
  63. };
  64. struct jr_code_move {
  65. struct jr_prefix p;
  66. uint32_t pid;
  67. uint32_t tid;
  68. uint64_t vma;
  69. uint64_t old_code_addr;
  70. uint64_t new_code_addr;
  71. uint64_t code_size;
  72. uint64_t code_index;
  73. };
  74. struct debug_entry {
  75. uint64_t addr;
  76. int lineno; /* source line number starting at 1 */
  77. int discrim; /* column discriminator, 0 is default */
  78. const char name[0]; /* null terminated filename, \xff\0 if same as previous entry */
  79. };
  80. struct jr_code_debug_info {
  81. struct jr_prefix p;
  82. uint64_t code_addr;
  83. uint64_t nr_entry;
  84. struct debug_entry entries[0];
  85. };
  86. struct jr_code_unwinding_info {
  87. struct jr_prefix p;
  88. uint64_t unwinding_size;
  89. uint64_t eh_frame_hdr_size;
  90. uint64_t mapped_size;
  91. const char unwinding_data[0];
  92. };
  93. union jr_entry {
  94. struct jr_code_debug_info info;
  95. struct jr_code_close close;
  96. struct jr_code_load load;
  97. struct jr_code_move move;
  98. struct jr_prefix prefix;
  99. struct jr_code_unwinding_info unwinding;
  100. };
  101. static inline struct debug_entry *
  102. debug_entry_next(struct debug_entry *ent)
  103. {
  104. void *a = ent + 1;
  105. size_t l = strlen(ent->name) + 1;
  106. return a + l;
  107. }
  108. static inline char *
  109. debug_entry_file(struct debug_entry *ent)
  110. {
  111. void *a = ent + 1;
  112. return a;
  113. }
  114. #endif /* !JITDUMP_H */