1 #ifndef JITDUMP_H
2 #define JITDUMP_H
3 
4 #include <sys/time.h>
5 #include <time.h>
6 #include <stdint.h>
7 
8 /* JiTD */
9 #define JITHEADER_MAGIC 0x4A695444
10 #define JITHEADER_MAGIC_SW 0x4454694A
11 
12 #define PADDING_8ALIGNED(x) ((((x) + 7) & 7) ^ 7)
13 
14 #define JITHEADER_VERSION 1
15 
16 struct jitheader {
17   uint32_t magic;      /* characters "jItD" */
18   uint32_t version;    /* header version */
19   uint32_t total_size; /* total size of header */
20   uint32_t elf_mach;   /* elf mach target */
21   uint32_t pad1;       /* reserved */
22   uint32_t pid;        /* JIT process id */
23   uint64_t timestamp;  /* timestamp */
24 };
25 
26 enum jit_record_type {
27   JIT_CODE_LOAD = 0,
28   JIT_CODE_MOVE = 1,
29   JIT_CODE_DEBUG_INFO = 2,
30   JIT_CODE_CLOSE = 3,
31   JIT_CODE_MAX
32 };
33 
34 /* record prefix (mandatory in each record) */
35 struct jr_prefix {
36   uint32_t id;
37   uint32_t total_size;
38   uint64_t timestamp;
39 };
40 
41 struct jr_code_load {
42   struct jr_prefix p;
43 
44   uint32_t pid;
45   uint32_t tid;
46   uint64_t vma;
47   uint64_t code_addr;
48   uint64_t code_size;
49   uint64_t code_index;
50 };
51 
52 struct jr_code_close {
53   struct jr_prefix p;
54 };
55 
56 struct jr_code_move {
57   struct jr_prefix p;
58 
59   uint32_t pid;
60   uint32_t tid;
61   uint64_t vma;
62   uint64_t old_code_addr;
63   uint64_t new_code_addr;
64   uint64_t code_size;
65   uint64_t code_index;
66 };
67 
68 struct jr_code_debug_info {
69   struct jr_prefix p;
70 
71   uint64_t code_addr;
72   uint64_t nr_entry;
73 };
74 
75 union jr_entry {
76   struct jr_code_debug_info info;
77   struct jr_code_close close;
78   struct jr_code_load load;
79   struct jr_code_move move;
80   struct jr_prefix prefix;
81 };
82 
83 #endif /* !JITDUMP_H */
84