| 1 | /* JIT declarations for GDB, the GNU Debugger. |
| 2 | |
| 3 | Copyright (C) 2009 |
| 4 | Free Software Foundation, Inc. |
| 5 | |
| 6 | This file is part of GDB. |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 20 | |
| 21 | #ifndef JIT_H |
| 22 | #define JIT_H |
| 23 | |
| 24 | /* When the JIT breakpoint fires, the inferior wants us to take one of these |
| 25 | actions. These values are used by the inferior, so the values of these enums |
| 26 | cannot be changed. */ |
| 27 | |
| 28 | typedef enum |
| 29 | { |
| 30 | JIT_NOACTION = 0, |
| 31 | JIT_REGISTER, |
| 32 | JIT_UNREGISTER |
| 33 | } jit_actions_t; |
| 34 | |
| 35 | /* This struct describes a single symbol file in a linked list of symbol files |
| 36 | describing generated code. As the inferior generates code, it adds these |
| 37 | entries to the list, and when we attach to the inferior, we read them all. |
| 38 | For the first element prev_entry should be NULL, and for the last element |
| 39 | next_entry should be NULL. */ |
| 40 | |
| 41 | struct jit_code_entry |
| 42 | { |
| 43 | CORE_ADDR next_entry; |
| 44 | CORE_ADDR prev_entry; |
| 45 | CORE_ADDR symfile_addr; |
| 46 | uint64_t symfile_size; |
| 47 | }; |
| 48 | |
| 49 | /* This is the global descriptor that the inferior uses to communicate |
| 50 | information to the debugger. To alert the debugger to take an action, the |
| 51 | inferior sets the action_flag to the appropriate enum value, updates |
| 52 | relevant_entry to point to the relevant code entry, and calls the function at |
| 53 | the well-known symbol with our breakpoint. We then read this descriptor from |
| 54 | another global well-known symbol. */ |
| 55 | |
| 56 | struct jit_descriptor |
| 57 | { |
| 58 | uint32_t version; |
| 59 | /* This should be jit_actions_t, but we want to be specific about the |
| 60 | bit-width. */ |
| 61 | uint32_t action_flag; |
| 62 | CORE_ADDR relevant_entry; |
| 63 | CORE_ADDR first_entry; |
| 64 | }; |
| 65 | |
| 66 | /* Looks for the descriptor and registration symbols and breakpoints the |
| 67 | registration function. If it finds both, it registers all the already JITed |
| 68 | code. If it has already found the symbols, then it doesn't try again. */ |
| 69 | |
| 70 | extern void jit_inferior_created_hook (void); |
| 71 | |
| 72 | /* Re-establish the jit breakpoint(s). */ |
| 73 | |
| 74 | extern void jit_breakpoint_re_set (void); |
| 75 | |
| 76 | /* This function is called by handle_inferior_event when it decides that the JIT |
| 77 | event breakpoint has fired. */ |
| 78 | |
| 79 | extern void jit_event_handler (struct gdbarch *gdbarch); |
| 80 | |
| 81 | #endif /* JIT_H */ |