xref: /llvm-project/lldb/test/API/functionalities/jitloader_gdb/main.c (revision 99451b4453688a94c6014cac233d371ab4cc342d)
1 #include <inttypes.h>
2 
3 // GDB JIT interface
4 enum JITAction { JIT_NOACTION, JIT_REGISTER_FN, JIT_UNREGISTER_FN };
5 
6 struct JITCodeEntry
7 {
8     struct JITCodeEntry* next;
9     struct JITCodeEntry* prev;
10     const char *symfile_addr;
11     uint64_t symfile_size;
12 };
13 
14 struct JITDescriptor
15 {
16     uint32_t version;
17     uint32_t action_flag;
18     struct JITCodeEntry* relevant_entry;
19     struct JITCodeEntry* first_entry;
20 };
21 
22 struct JITDescriptor __jit_debug_descriptor = { 1, JIT_NOACTION, 0, 0 };
23 
__jit_debug_register_code()24 void __jit_debug_register_code()
25 {
26 }
27 // end GDB JIT interface
28 
29 struct JITCodeEntry entry;
30 
main()31 int main()
32 {
33     // Create a code entry with a bogus size
34     entry.next = entry.prev = 0;
35     entry.symfile_addr = (char *)&entry;
36     entry.symfile_size = (uint64_t)47<<32;
37 
38     __jit_debug_descriptor.relevant_entry = __jit_debug_descriptor.first_entry = &entry;
39     __jit_debug_descriptor.action_flag = JIT_REGISTER_FN;
40 
41     __jit_debug_register_code();
42 
43     return 0;
44 }
45