struct gdbarch * gdbarch_from_bfd (bfd *abfd) { struct gdbarch_info info; gdbarch_info_init (&info); info.abfd = abfd; return gdbarch_find_by_info (info); }
/* Find gdbarch for SPU context SPUFS_FD. */ static struct gdbarch * spu_gdbarch (int spufs_fd) { struct gdbarch_info info; gdbarch_info_init (&info); info.bfd_arch_info = bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu); info.byte_order = BFD_ENDIAN_BIG; info.osabi = GDB_OSABI_LINUX; info.tdep_info = (struct gdbarch_tdep_info *)&spufs_fd; return gdbarch_find_by_info (info); }
void set_gdbarch_from_file (bfd *abfd) { struct gdbarch_info info; struct gdbarch *gdbarch; gdbarch_info_init (&info); info.abfd = abfd; info.target_desc = target_current_description (); gdbarch = gdbarch_find_by_info (info); if (gdbarch == NULL) error (_("Architecture of file not recognized.")); set_target_gdbarch (gdbarch); }
/* Try to select a global architecture that matches "info". Return non-zero if the attempt succeeds. */ int gdbarch_update_p (struct gdbarch_info info) { struct gdbarch *new_gdbarch; /* Check for the current file. */ if (info.abfd == NULL) info.abfd = exec_bfd; if (info.abfd == NULL) info.abfd = core_bfd; /* Check for the current target description. */ if (info.target_desc == NULL) info.target_desc = target_current_description (); new_gdbarch = gdbarch_find_by_info (info); /* If there no architecture by that name, reject the request. */ if (new_gdbarch == NULL) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " "Architecture not found\n"); return 0; } /* If it is the same old architecture, accept the request (but don't swap anything). */ if (new_gdbarch == target_gdbarch ()) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " "Architecture %s (%s) unchanged\n", host_address_to_string (new_gdbarch), gdbarch_bfd_arch_info (new_gdbarch)->printable_name); return 1; } /* It's a new architecture, swap it in. */ if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " "New architecture %s (%s) selected\n", host_address_to_string (new_gdbarch), gdbarch_bfd_arch_info (new_gdbarch)->printable_name); set_target_gdbarch (new_gdbarch); return 1; }