gdb/jit: move cached_code_address and jit_breakpoint to jiter_objfile_data
[deliverable/binutils-gdb.git] / gdb / jit.h
CommitLineData
4efc6507
DE
1/* JIT declarations for GDB, the GNU Debugger.
2
b811d2c2 3 Copyright (C) 2009-2020 Free Software Foundation, Inc.
4efc6507
DE
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef JIT_H
21#define JIT_H
22
fe053b9e 23struct objfile;
238b5c9f 24struct minimal_symbol;
fe053b9e 25
1777feb0
MS
26/* When the JIT breakpoint fires, the inferior wants us to take one of
27 these actions. These values are used by the inferior, so the
28 values of these enums cannot be changed. */
4efc6507
DE
29
30typedef enum
31{
32 JIT_NOACTION = 0,
33 JIT_REGISTER,
34 JIT_UNREGISTER
35} jit_actions_t;
36
1777feb0
MS
37/* This struct describes a single symbol file in a linked list of
38 symbol files describing generated code. As the inferior generates
39 code, it adds these entries to the list, and when we attach to the
40 inferior, we read them all. For the first element prev_entry
41 should be NULL, and for the last element next_entry should be
42 NULL. */
4efc6507
DE
43
44struct jit_code_entry
45{
46 CORE_ADDR next_entry;
47 CORE_ADDR prev_entry;
48 CORE_ADDR symfile_addr;
a255712f 49 ULONGEST symfile_size;
4efc6507
DE
50};
51
52/* This is the global descriptor that the inferior uses to communicate
1777feb0
MS
53 information to the debugger. To alert the debugger to take an
54 action, the inferior sets the action_flag to the appropriate enum
55 value, updates relevant_entry to point to the relevant code entry,
56 and calls the function at the well-known symbol with our
57 breakpoint. We then read this descriptor from another global
58 well-known symbol. */
4efc6507
DE
59
60struct jit_descriptor
61{
62 uint32_t version;
63 /* This should be jit_actions_t, but we want to be specific about the
64 bit-width. */
65 uint32_t action_flag;
66 CORE_ADDR relevant_entry;
67 CORE_ADDR first_entry;
68};
69
0e74a041
SM
70/* An objfile that defines the required symbols of the JIT interface has an
71 instance of this type attached to it. */
238b5c9f 72
0e74a041 73struct jiter_objfile_data
238b5c9f 74{
0e74a041 75 jiter_objfile_data (struct objfile *objfile)
238b5c9f
SM
76 : objfile (objfile)
77 {}
78
0e74a041 79 ~jiter_objfile_data ();
238b5c9f
SM
80
81 /* Back-link to the objfile. */
82 struct objfile *objfile;
83
84 /* Symbol for __jit_debug_register_code. */
85 minimal_symbol *register_code = nullptr;
86
87 /* Symbol for __jit_debug_descriptor. */
88 minimal_symbol *descriptor = nullptr;
77208eb7
SM
89
90 /* This is the relocated address of the __jit_debug_register_code function
91 provided by this objfile. This is used to detect relocations changes
92 requiring the breakpoint to be re-created. */
93 CORE_ADDR cached_code_address = 0;
94
95 /* This is the JIT event breakpoint, or nullptr if it has been deleted. */
96 breakpoint *jit_breakpoint = nullptr;
0e74a041
SM
97};
98
99/* An objfile that is the product of JIT compilation and was registered
100 using the JIT interface has an instance of this type attached to it. */
101
102struct jited_objfile_data
103{
104 jited_objfile_data (CORE_ADDR addr)
105 : addr (addr)
106 {}
238b5c9f 107
0e74a041
SM
108 /* Address of struct jit_code_entry for this objfile. */
109 CORE_ADDR addr;
238b5c9f
SM
110};
111
1777feb0
MS
112/* Looks for the descriptor and registration symbols and breakpoints
113 the registration function. If it finds both, it registers all the
114 already JITed code. If it has already found the symbols, then it
115 doesn't try again. */
4efc6507
DE
116
117extern void jit_inferior_created_hook (void);
118
0756c555
DE
119/* Re-establish the jit breakpoint(s). */
120
121extern void jit_breakpoint_re_set (void);
122
1777feb0 123/* This function is called by handle_inferior_event when it decides
fe053b9e
TBA
124 that the JIT event breakpoint has fired. JITER is the objfile
125 whose JIT event breakpoint has been hit. */
4efc6507 126
fe053b9e 127extern void jit_event_handler (gdbarch *gdbarch, objfile *jiter);
4efc6507
DE
128
129#endif /* JIT_H */
This page took 0.923482 seconds and 4 git commands to generate.