28 #include "filenames.h" 42 #include "readline/tilde.h" 105 file_ptr nbytes, file_ptr
offset)
132 memset (sb, 0,
sizeof (
struct stat));
133 sb->st_size =
buffer->size;
195 error (
_(
"Could not locate initialization function: %s."),
198 if (
gdb_dlsym (so,
"plugin_is_GPL_compatible") == NULL)
199 error (
_(
"Reader not GPL compatible."));
203 error (
_(
"Reader version does not match GDB version."));
205 return new jit_reader (funcs, std::move (so));
214 error (
_(
"No reader name provided."));
218 error (
_(
"JIT reader already loaded. Run jit-reader-unload first."));
220 if (!IS_ABSOLUTE_PATH (file.get ()))
235 error (
_(
"No JIT reader loaded."));
294 if (objf_data == NULL)
312 objf_data->
addr = entry;
351 struct type *ptr_type;
366 "jit_read_descriptor, descriptor_addr = %s\n",
373 desc_size = 8 + 2 * ptr_size;
374 desc_buf = (
gdb_byte *) alloca (desc_size);
379 desc_buf, desc_size);
405 struct type *ptr_type;
419 off = (off + (align_bytes - 1)) & ~(align_bytes - 1);
421 entry_size = off + 8;
422 entry_buf = (
gdb_byte *) alloca (entry_size);
427 error (
_(
"Unable to read JIT code entry from remote memory!"));
534 ret->
next =
object->symtabs;
535 object->symtabs = ret;
552 if (old->
end > newobj->
end)
623 for (i = 0; i < nlines; i++)
648 struct gdb_block *gdb_block_iter, *gdb_block_iter_tmp;
649 struct block *block_iter;
650 int actual_nblocks, i;
651 size_t blockvector_size;
679 + (actual_nblocks - 1) *
sizeof (
struct block *));
694 for (i = (actual_nblocks - 1), gdb_block_iter = stab->
blocks;
696 i--, gdb_block_iter = gdb_block_iter->
next)
720 gdb_block_iter->
name,
721 strlen (gdb_block_iter->
name));
759 for (gdb_block_iter = stab->
blocks;
761 gdb_block_iter = gdb_block_iter->
next)
763 if (gdb_block_iter->
parent != NULL)
779 gdb_block_iter = stab->
blocks;
781 for (gdb_block_iter = stab->
blocks, gdb_block_iter_tmp = gdb_block_iter->
next;
783 gdb_block_iter = gdb_block_iter_tmp)
786 xfree (gdb_block_iter);
813 for (i = obj->
symtabs; i; i = j)
879 "Could not read symtab using the loaded JIT reader.\n");
892 struct bfd_section *sec;
896 const struct bfd_arch_info *b;
900 "jit_register_code, symfile_addr = %s, " 901 "symfile_size = %s\n",
916 if (!bfd_check_format (nbfd.
get (), bfd_object))
919 JITed symbol file is not an object file, ignoring it.\n"));
925 if (b->compatible (b, bfd_get_arch_info (nbfd.
get ())) != b)
926 warning (
_(
"JITed object file architecture %s is not compatible " 927 "with target architecture %s."),
928 bfd_get_arch_info (nbfd.
get ())->printable_name,
937 for (sec = nbfd->sections; sec != NULL; sec = sec->next)
938 if ((bfd_get_section_flags (nbfd.
get (), sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
942 sai->
other[i].
addr = bfd_get_section_vma (nbfd.
get (), sec);
943 sai->
other[i].
name = xstrdup (bfd_get_section_name (nbfd.
get (), sec));
951 bfd_get_filename (nbfd.
get ()), 0, sai,
971 "jit_register_code, symfile_addr = %s, " 972 "symfile_size = %s\n",
1004 if (objf_data != NULL && objf_data->
addr == entry_addr)
1021 for (iter = b->
loc; iter != NULL; iter = iter->
next)
1052 if (reg_symbol.
minsym == NULL
1058 if (desc_symbol.
minsym == NULL
1075 "jit_breakpoint_re_set_internal, " 1076 "breakpoint_addr = %s\n",
1123 _(
"Could not recognize DWARF regnum %d"),
1264 static struct value *
1357 "in descriptor (expected 1)\n"),
1365 cur_entry_addr != 0;
1420 if (objf_data != NULL && objf_data->
addr != 0)
1452 "entry at address: %s\n"),
1459 error (
_(
"Unknown action_flag value in JIT descriptor!"));
1509 _(
"Set JIT debugging."),
1510 _(
"Show JIT debugging."),
1511 _(
"When non-zero, JIT debugging is enabled."),
1523 register_program_space_data_with_cleanup (NULL,
1531 Load FILE as debug info reader and unwinder for JIT compiled code.\n\ 1532 Usage: jit-reader-load FILE\n\ 1533 Try to load file FILE as a debug info reader (and unwinder) for\n\ 1534 JIT compiled code. The file is loaded from " JIT_READER_DIR ",\n\ 1535 relocated relative to the GDB executable if required."));
1540 Unload the currently loaded JIT debug info reader.\n\ 1541 Usage: jit-reader-unload\n\n\ 1542 Do \"help jit-reader-load\" for info on loading debug info readers."));
struct gdbarch * target_gdbarch(void)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
struct linetable * linetable
struct breakpoint * create_jit_event_breakpoint(struct gdbarch *gdbarch, CORE_ADDR address)
struct gdb_reader_funcs * functions
static void free_objfile_data(struct objfile *objfile, void *data)
struct observer * observer_attach_breakpoint_deleted(observer_breakpoint_deleted_ftype *f)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
struct value * frame_unwind_got_bytes(struct frame_info *frame, int regnum, gdb_byte *buf)
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
#define GDB_READER_INTERFACE_VERSION
static file_ptr mem_bfd_iovec_pread(struct bfd *abfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset)
static struct jit_reader * jit_reader_load(const char *file_name)
void _initialize_jit(void)
void symbol_set_symtab(struct symbol *symbol, struct symtab *symtab)
struct linetable_entry item[1]
static int mem_bfd_iovec_stat(struct bfd *abfd, void *stream, struct stat *sb)
static void jit_reader_load_command(const char *args, int from_tty)
static struct gdb_reg_value * jit_unwind_reg_get_impl(struct gdb_unwind_callbacks *cb, int regnum)
static const char *const jit_break_name
static const char *const jit_descriptor_name
static int jit_read_descriptor(struct gdbarch *gdbarch, struct jit_descriptor *descriptor, struct jit_program_space_data *ps_data)
struct block * real_block
gdb_unwind_reg_get * reg_get
#define JIT_READER_DIR_RELOCATABLE
#define BMSYMBOL_VALUE_ADDRESS(symbol)
void warning(const char *fmt,...)
void jit_breakpoint_re_set(void)
struct program_space * pspace
static void jit_breakpoint_deleted(struct breakpoint *b)
struct dictionary * dict_create_linear(struct obstack *obstack, enum language language, const struct pending *symbol_list)
struct gdb_block * blocks
struct compunit_symtab * allocate_compunit_symtab(struct objfile *objfile, const char *name)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void * memset(T *s, int c, size_t n)=delete
static void jit_register_code(struct gdbarch *gdbarch, CORE_ADDR entry_addr, struct jit_code_entry *code_entry)
gdb_destroy_reader * destroy
gdb_target_read * target_read
jit_reader(struct gdb_reader_funcs *f, gdb_dlhandle_up &&h)
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
struct observer * observer_attach_inferior_exit(observer_inferior_exit_ftype *f)
#define BLOCKVECTOR_BLOCK(blocklist, n)
struct gdbarch_data * gdbarch_data_register_pre_init(gdbarch_data_pre_init_ftype *pre_init)
int gdbarch_num_regs(struct gdbarch *gdbarch)
static void show_jit_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void * jit_gdbarch_data_init(struct obstack *obstack)
#define COMPUNIT_DIRNAME(cust)
static struct objfile * jit_find_objf_with_entry_addr(CORE_ADDR entry_addr)
int is_dl_available(void)
static const char * reader_init_fn_sym
void frame_unwind_prepend_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
struct objfile_per_bfd_storage * per_bfd
int gdbarch_long_long_align_bit(struct gdbarch *gdbarch)
static void jit_reader_unload_command(const char *args, int from_tty)
static int mem_bfd_iovec_close(struct bfd *abfd, void *stream)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
static void jit_dealloc_cache(struct frame_info *this_frame, void *cache)
static int jit_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **cache)
#define BLOCK_FUNCTION(bl)
static void jit_frame_this_id(struct frame_info *this_frame, void **cache, struct frame_id *this_id)
static void jit_read_code_entry(struct gdbarch *gdbarch, CORE_ADDR code_addr, struct jit_code_entry *code_entry)
DISABLE_COPY_AND_ASSIGN(jit_reader)
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct observer * observer_attach_inferior_created(observer_inferior_created_ftype *f)
static void add_objfile_entry(struct objfile *objfile, CORE_ADDR entry)
gdb_get_frame_id * get_frame_id
struct objfile * symbol_file_add_from_bfd(bfd *abfd, const char *name, symfile_add_flags add_flags, struct section_addr_info *addrs, objfile_flags flags, struct objfile *parent)
#define SYMBOL_ACLASS_INDEX(symbol)
#define CATCH(EXCEPTION, MASK)
gdb_dlhandle_up gdb_dlopen(const char *filename)
void noop_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *prefix)
static void reg_value_free_impl(struct gdb_reg_value *value)
unsigned long GDB_CORE_ADDR
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
static struct gdb_symtab * jit_symtab_open_impl(struct gdb_symbol_callbacks *cb, struct gdb_object *object, const char *file_name)
#define SYMBOL_DOMAIN(symbol)
objfile(bfd *, const char *, objfile_flags)
static struct gdb_block * jit_block_open_impl(struct gdb_symbol_callbacks *cb, struct gdb_symtab *symtab, struct gdb_block *parent, GDB_CORE_ADDR begin, GDB_CORE_ADDR end, const char *name)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
CORE_ADDR cached_code_address
void jit_inferior_created_hook(void)
gdb_read_debug_info * read
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
struct bound_minimal_symbol lookup_minimal_symbol_and_objfile(const char *name)
static gdb_bfd_ref_ptr bfd_open_from_target_memory(CORE_ADDR addr, ULONGEST size, char *target)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct regcache * regcache
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
char * pulongest(ULONGEST u)
void add_compunit_symtab_to_objfile(struct compunit_symtab *cu)
gdb_unwind_reg_set * reg_set
static void jit_unwind_reg_set_impl(struct gdb_unwind_callbacks *cb, int dwarf_regnum, struct gdb_reg_value *value)
#define BLOCK_SUPERBLOCK(bl)
CORE_ADDR jit_dbg_reader_data
struct frame_info * this_frame
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
static void jit_symtab_close_impl(struct gdb_symbol_callbacks *cb, struct gdb_symtab *stab)
static enum gdb_status jit_target_read_impl(GDB_CORE_ADDR target_mem, void *gdb_buf, int len)
static void jit_bfd_try_read_symtab(struct jit_code_entry *code_entry, CORE_ADDR entry_addr, struct gdbarch *gdbarch)
static struct jit_program_space_data * get_jit_program_space_data(void)
struct block * allocate_block(struct obstack *obstack)
char * xstrprintf(const char *format,...)
static void * mem_bfd_iovec_open(struct bfd *abfd, void *open_closure)
void printf_unfiltered(const char *format,...)
struct cmd_list_element * setdebuglist
static void jit_inferior_exit_hook(struct inferior *inf)
struct value * gdbarch_pseudo_register_read_value(struct gdbarch *gdbarch, struct regcache *regcache, int cookednum)
static void jit_program_space_data_cleanup(struct program_space *ps, void *arg)
static const struct frame_unwind jit_frame_unwind
int gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, int dwarf2_regnr)
struct value * frame_unwind_got_optimized(struct frame_info *frame, int regnum)
#define COMPUNIT_BLOCKVECTOR(cust)
static struct gdbarch_data * jit_gdbarch_data
struct minimal_symbol * register_code
void regcache_raw_set_cached_value(struct regcache *regcache, int regnum, const gdb_byte *buf)
static void jit_prepend_unwinder(struct gdbarch *gdbarch)
void puts_unfiltered(const char *string)
struct symbol * allocate_symbol(struct objfile *objfile)
gdb_unwind_frame * unwind
static struct jit_objfile_data * get_jit_objfile_data(struct objfile *objf)
int deprecated_frame_register_read(struct frame_info *frame, int regnum, gdb_byte *myaddr)
#define SYMBOL_BLOCK_VALUE(symbol)
static unsigned int jit_debug
enum register_status regcache_raw_read(struct regcache *regcache, int regnum, gdb_byte *buf)
gdb_bfd_ref_ptr gdb_bfd_openr_iovec(const char *filename, const char *target, void *(*open_func)(struct bfd *nbfd, void *open_closure), void *open_closure, file_ptr(*pread_func)(struct bfd *nbfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset), int(*close_func)(struct bfd *nbfd, void *stream), int(*stat_func)(struct bfd *abfd, void *stream, struct stat *sb))
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
static void jit_symtab_line_mapping_add_impl(struct gdb_symbol_callbacks *cb, struct gdb_symtab *stab, int nlines, struct gdb_line_mapping *map)
struct type * builtin_data_ptr
struct minimal_symbol * minsym
static struct value * jit_frame_prev_register(struct frame_info *this_frame, void **cache, int reg)
static void jit_inferior_init(struct gdbarch *gdbarch)
struct symtab * allocate_symtab(struct compunit_symtab *cust, const char *filename)
struct general_symbol_info ginfo
enum language compunit_language(const struct compunit_symtab *cust)
struct minimal_symbol * descriptor
#define COMPUNIT_FILETABS(cust)
#define ALL_OBJFILES_SAFE(obj, nxt)
static void finalize_symtab(struct gdb_symtab *stab, struct objfile *objfile)
#define BLOCKVECTOR_NBLOCKS(blocklist)
struct other_sections other[1]
struct inferior * current_inferior(void)
void set_block_compunit_symtab(struct block *block, struct compunit_symtab *cu)
struct program_space * current_program_space
struct gdb_reader_funcs *() reader_init_fn_type(void)
unsigned long long ULONGEST
std::unique_ptr< void, dlclose_deleter > gdb_dlhandle_up
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
void * gdb_dlsym(const gdb_dlhandle_up &handle, const char *symbol)
int register_size(struct gdbarch *gdbarch, int regnum)
static int compare_block(const struct gdb_block *const old, const struct gdb_block *const newobj)
static void jit_inferior_created(struct target_ops *ops, int from_tty)
static void jit_object_close_impl(struct gdb_symbol_callbacks *cb, struct gdb_object *obj)
#define SYMBOL_TYPE(symbol)
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
char * relocate_gdb_directory(const char *initial, int flag)
struct cmd_list_element * showdebuglist
struct breakpoint * jit_breakpoint
static void jit_unregister_code(struct objfile *objfile)
#define BLOCKVECTOR_MAP(blocklist)
struct gdb_block * parent
#define TYPE_LENGTH(thistype)
static int jit_reader_try_read_symtab(struct jit_code_entry *code_entry, CORE_ADDR entry_addr)
static const struct objfile_data * jit_objfile_data
void reinit_frame_cache(void)
struct block * allocate_global_block(struct obstack *obstack)
struct cleanup * make_cleanup_free_section_addr_info(struct section_addr_info *addrs)
void terminate_minimal_symbol_table(struct objfile *objfile)
#define ALL_OBJFILES(obj)
struct gdb_symtab * symtabs
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
static struct gdb_object * jit_object_open_impl(struct gdb_symbol_callbacks *cb)
static const char * jit_reader_dir
#define SYMTAB_LINETABLE(symtab)
void delete_breakpoint(struct breakpoint *bpt)
void error(const char *fmt,...)
void jit_event_handler(struct gdbarch *gdbarch)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
static int jit_breakpoint_re_set_internal(struct gdbarch *gdbarch, struct jit_program_space_data *ps_data)
void do_cleanups(struct cleanup *old_chain)
#define MSYMBOL_VALUE_ADDRESS(objfile, symbol)
static struct jit_reader * loaded_jit_reader
struct type * lookup_function_type(struct type *type)
struct section_addr_info * alloc_section_addr_info(size_t num_sections)
static struct block * new_block(enum block_type, enum language)