From 8908432dc48908b505d7c00c7d8288d4071d4c4b Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 20 Aug 2009 18:02:45 +0000 Subject: Add interface for JIT code generation. * NEWS: Announce JIT interface. * Makefile.in (SFILES): Add jit.c. (HFILES_NO_SRCDIR): Add jit.h. (COMMON_OBS): Add jit.o. * jit.c: New file. * jit.h: New file. * breakpoint.h (enum bptype): Add bp_jit_event to enum. * breakpoint.c: (update_breakpoints_after_exec): Delete jit breakpoints after exec. (bpstat_what): Update event table for bp_jit_event. (print_it_typical): Added case for bp_jit_event. (print_one_breakpoint_location): Added case for bp_jit_event. (allocate_bp_location): Added case for bp_jit_event. (mention): Added case for bp_jit_event. (delete_command): Added case for bp_jit_event. (breakpoint_re_set_one): Added case for bp_jit_event. (breakpoint_re_set): Added call to jit_inferior_created_hook. (create_jit_event_breakpoint): New. * infrun.c (handle_inferior_event): Add handler for jit event. (follow_exec): Add call to jit_inferior_created_hook. * doc/gdb.texinfo: Add chapter on JIT interface. --- gdb/jit.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 gdb/jit.h (limited to 'gdb/jit.h') diff --git a/gdb/jit.h b/gdb/jit.h new file mode 100644 index 00000000000..6473d257c30 --- /dev/null +++ b/gdb/jit.h @@ -0,0 +1,77 @@ +/* JIT declarations for GDB, the GNU Debugger. + + Copyright (C) 2009 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef JIT_H +#define JIT_H + +/* When the JIT breakpoint fires, the inferior wants us to take one of these + actions. These values are used by the inferior, so the values of these enums + cannot be changed. */ + +typedef enum +{ + JIT_NOACTION = 0, + JIT_REGISTER, + JIT_UNREGISTER +} jit_actions_t; + +/* This struct describes a single symbol file in a linked list of symbol files + describing generated code. As the inferior generates code, it adds these + entries to the list, and when we attach to the inferior, we read them all. + For the first element prev_entry should be NULL, and for the last element + next_entry should be NULL. */ + +struct jit_code_entry +{ + CORE_ADDR next_entry; + CORE_ADDR prev_entry; + CORE_ADDR symfile_addr; + uint64_t symfile_size; +}; + +/* This is the global descriptor that the inferior uses to communicate + information to the debugger. To alert the debugger to take an action, the + inferior sets the action_flag to the appropriate enum value, updates + relevant_entry to point to the relevant code entry, and calls the function at + the well-known symbol with our breakpoint. We then read this descriptor from + another global well-known symbol. */ + +struct jit_descriptor +{ + uint32_t version; + /* This should be jit_actions_t, but we want to be specific about the + bit-width. */ + uint32_t action_flag; + CORE_ADDR relevant_entry; + CORE_ADDR first_entry; +}; + +/* Looks for the descriptor and registration symbols and breakpoints the + registration function. If it finds both, it registers all the already JITed + code. If it has already found the symbols, then it doesn't try again. */ + +extern void jit_inferior_created_hook (void); + +/* This function is called by handle_inferior_event when it decides that the JIT + event breakpoint has fired. */ + +extern void jit_event_handler (void); + +#endif /* JIT_H */ -- cgit v1.2.1