jitdump.h 2.5 KB

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