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