blob: 08c1bc987c5048b6af772b617c42f3685d0a1c38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "JitObject.h"
#include "LinkerInternals.h"
#include "RtsUtils.h"
/*
* GDB JIT interface
*/
typedef enum
{
JIT_NOACTION = 0,
JIT_REGISTER_FN,
JIT_UNREGISTER_FN
} jit_actions_t;
struct jit_code_entry
{
struct jit_code_entry *next_entry;
struct jit_code_entry *prev_entry;
const char *symfile_addr;
uint64_t symfile_size;
};
struct jit_descriptor
{
uint32_t version;
/* This type should be jit_actions_t, but we use uint32_t
to be explicit about the bitwidth. */
uint32_t action_flag;
struct jit_code_entry *relevant_entry;
struct jit_code_entry *first_entry;
};
/* GDB puts a breakpoint in this function. */
void __jit_debug_register_code(void);
void __attribute__((noinline)) __jit_debug_register_code() { };
/* Make sure to specify the version statically, because the
debugger may check the version before we can set it. */
struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
/*
* Registering a JIT object
*/
void register_jit_object(ObjectCode *oc)
{
struct JitObject obj = build_jit_object(oc);
if (obj.buffer == NULL) {
debugBelch("Failed to build JIT object for %s\n", OC_INFORMATIVE_FILENAME(oc));
return;
}
struct jit_code_entry *code_entry = stgMallocBytes(sizeof(struct jit_code_entry), "register_jit_object");
code_entry->next_entry = __jit_debug_descriptor.first_entry;
code_entry->prev_entry = NULL;
code_entry->symfile_addr = (const char *) obj.buffer;
code_entry->symfile_size = obj.size;
__jit_debug_descriptor.action_flag = JIT_REGISTER_FN;
__jit_debug_descriptor.first_entry = code_entry;
__jit_debug_descriptor.relevant_entry = code_entry;
__jit_debug_register_code();
}
|