15796c8dcSSimon Schubert /* JIT declarations for GDB, the GNU Debugger. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright (C) 2009-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #ifndef JIT_H 215796c8dcSSimon Schubert #define JIT_H 225796c8dcSSimon Schubert 23c50c785cSJohn Marino /* When the JIT breakpoint fires, the inferior wants us to take one of 24c50c785cSJohn Marino these actions. These values are used by the inferior, so the 25c50c785cSJohn Marino values of these enums cannot be changed. */ 265796c8dcSSimon Schubert 275796c8dcSSimon Schubert typedef enum 285796c8dcSSimon Schubert { 295796c8dcSSimon Schubert JIT_NOACTION = 0, 305796c8dcSSimon Schubert JIT_REGISTER, 315796c8dcSSimon Schubert JIT_UNREGISTER 325796c8dcSSimon Schubert } jit_actions_t; 335796c8dcSSimon Schubert 34c50c785cSJohn Marino /* This struct describes a single symbol file in a linked list of 35c50c785cSJohn Marino symbol files describing generated code. As the inferior generates 36c50c785cSJohn Marino code, it adds these entries to the list, and when we attach to the 37c50c785cSJohn Marino inferior, we read them all. For the first element prev_entry 38c50c785cSJohn Marino should be NULL, and for the last element next_entry should be 39c50c785cSJohn Marino NULL. */ 405796c8dcSSimon Schubert 415796c8dcSSimon Schubert struct jit_code_entry 425796c8dcSSimon Schubert { 435796c8dcSSimon Schubert CORE_ADDR next_entry; 445796c8dcSSimon Schubert CORE_ADDR prev_entry; 455796c8dcSSimon Schubert CORE_ADDR symfile_addr; 46c50c785cSJohn Marino ULONGEST symfile_size; 475796c8dcSSimon Schubert }; 485796c8dcSSimon Schubert 495796c8dcSSimon Schubert /* This is the global descriptor that the inferior uses to communicate 50c50c785cSJohn Marino information to the debugger. To alert the debugger to take an 51c50c785cSJohn Marino action, the inferior sets the action_flag to the appropriate enum 52c50c785cSJohn Marino value, updates relevant_entry to point to the relevant code entry, 53c50c785cSJohn Marino and calls the function at the well-known symbol with our 54c50c785cSJohn Marino breakpoint. We then read this descriptor from another global 55c50c785cSJohn Marino well-known symbol. */ 565796c8dcSSimon Schubert 575796c8dcSSimon Schubert struct jit_descriptor 585796c8dcSSimon Schubert { 595796c8dcSSimon Schubert uint32_t version; 605796c8dcSSimon Schubert /* This should be jit_actions_t, but we want to be specific about the 615796c8dcSSimon Schubert bit-width. */ 625796c8dcSSimon Schubert uint32_t action_flag; 635796c8dcSSimon Schubert CORE_ADDR relevant_entry; 645796c8dcSSimon Schubert CORE_ADDR first_entry; 655796c8dcSSimon Schubert }; 665796c8dcSSimon Schubert 67c50c785cSJohn Marino /* Looks for the descriptor and registration symbols and breakpoints 68c50c785cSJohn Marino the registration function. If it finds both, it registers all the 69c50c785cSJohn Marino already JITed code. If it has already found the symbols, then it 70c50c785cSJohn Marino doesn't try again. */ 715796c8dcSSimon Schubert 725796c8dcSSimon Schubert extern void jit_inferior_created_hook (void); 735796c8dcSSimon Schubert 745796c8dcSSimon Schubert /* Re-establish the jit breakpoint(s). */ 755796c8dcSSimon Schubert 765796c8dcSSimon Schubert extern void jit_breakpoint_re_set (void); 775796c8dcSSimon Schubert 78c50c785cSJohn Marino /* This function is called by handle_inferior_event when it decides 79c50c785cSJohn Marino that the JIT event breakpoint has fired. */ 805796c8dcSSimon Schubert 815796c8dcSSimon Schubert extern void jit_event_handler (struct gdbarch *gdbarch); 825796c8dcSSimon Schubert 835796c8dcSSimon Schubert #endif /* JIT_H */ 84