This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC/gdbarch: Make OS ABI a real member of the gdbarch


I was working on a "set osabi" command again this morning.  I got just about
everything to work with just local changes to osabi.c, until I hit a real
stumbling block: there was absolutely no way to figure out what the
_current_ OS ABI was.  It was stored in the tdep struct of every
architecture that actually recognized the field.  That much code duplication
tipped me off that it would probably be easier to move the enum into the
gdbarch vector; in fact, to move it into the struct gdbarch_info used to
select.  Everything got much easier after that, although it was a bit
tedious - another one of those hundred-line changelogs.

Now the call to gdbarch_lookup_osabi happens in gdbarch_update_p, which
makes things much simpler for switching to the updated architecture; the
value gets stored in gdbarch_info and passed in to the architecture's init
method.  There's a visible hook in gdbarch_update_p explaining how "set
osabi" is going to work.

I'd like comments on this patch; especially from Andrew, since I'm mucking
around in gdbarch.sh.  Tested i386-linux and arm-elf (sim).  I'll post the
follow-up to actually implement "set osabi" later tonight on top of this
patch, assuming I get it to work to my satisfaction.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2002-12-27  Daniel Jacobowitz  <drow@mvista.com>

	* arch-utils.c (gdbarch_info_init): Set osabi to
	GDB_OSABI_UNINITIALIZED.
	* gdbarch.sh: Add osabi to struct gdbarch and to struct
	gdbarch_info.  Include "osabi_list.h" in gdbarch.h.  Include
	"osabi.h" in gdbarch.c.  Check osabi in gdbarch_list_lookup_by_info
	and in gdbarch_update_p.
	* gdbarch.c: Regenerated.
	* gdbarch.h: Regenerated.
	* osabi.c (gdbarch_lookup_osabi): Return GDB_OSABI_UNINITIALIZED if
	there's no BFD.
	(gdbarch_init_osabi): Remove osabi argument; use info.osabi.
	* osabi.h (enum gdb_osabi): Move to osabi_list.h.
	(gdbarch_init_osabi): Update prototype.
	* osabi_list.h: New file.

	* alpha-tdep.h: Don't include "osabi.h".
	(struct gdbarch_tdep): Remove osabi member.
	* alpha-tdep.c: Include "osabi.h".
	(alpha_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't
	iterate over arches.  Update call to gdbarch_init_osabi.
	(alpha_dump_tdep): Don't dump osabi.
	* alpha-linux-tdep.c: Include "osabi.h".
	* alpha-osf1-tdep.c: Include "osabi.h".
	* alphafbsd-tdep.c: Include "osabi.h".
	* alphanbsd-tdep.c: Include "osabi.h".

	* arm-tdep.h: Don't include "osabi.h".
	(struct gdbarch_tdep): Remove osabi member.
	* arm-tdep.c: Include "osabi.h".
	(arm_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't
	iterate over arches.  Update call to gdbarch_init_osabi.
	(arm_dump_tdep): Don't dump osabi.
	* arm-linux-tdep.c: Include "osabi.h".
	* armnbsd-tdep.c: Include "osabi.h".

	* hppa-tdep.c (hppa_gdbarch_init): Don't call gdbarch_lookup_osabi.
	Update call to gdbarch_init_osabi.

	* i386-tdep.h: Don't include "osabi.h".
	(struct gdbarch_tdep): Remove osabi member.
	* i386-tdep.c: Include "osabi.h".
	(i386_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't
	iterate over arches.  Update call to gdbarch_init_osabi.
	(i386_dump_tdep): Don't dump osabi.
	* i386-linux-tdep.c: Include "osabi.h".
	* i386-sol2-tdep.c: Include "osabi.h".
	* i386bsd-tdep.c: Include "osabi.h".
	* i386gnu-tdep.c: Include "osabi.h".
	* i386ly-tdep.c: Include "osabi.h".
	* i386nbsd-tdep.c: Include "osabi.h".
	* i386obsd-tdep.c: Include "osabi.h".

	* mips-tdep.c (struct gdbarch_tdep): Remove osabi member.
	(mips_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't
	check osabi when iterating over arches.  Update call to
	gdbarch_init_osabi.
	(mips_dump_tdep): Don't dump osabi.

	* ns32k-tdep.h: Don't include "osabi.h".
	(struct gdbarch_tdep): Remove.
	* ns32k-tdep.c (ns32k_gdbarch_init): Don't call
	gdbarch_lookup_osabi.  Don't iterate over arches.  Don't
	allocate tdep.  Update call to gdbarch_init_osabi.
	(ns32k_dump_tdep): Remove.
	(_initialize_ns32k_tdep): Update call to gdbarch_register.
	* ns32knbsd-tdep.c: Include "osabi.h".

	* ppc-tdep.h: Don't include "osabi.h".
	(struct gdbarch_tdep): Remove osabi member.
	* rs6000-tdep.c: Include "osabi.h".
	(rs6000_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't check
	osabi when iterating over arches.  Update call to
	gdbarch_init_osabi.
	(rs6000_dump_tdep): Don't dump osabi.
	* ppc-linux-tdep.c: Include "osabi.h".
	* ppcnbsd-tdep.c: Include "osabi.h".

	* sh-tdep.h: Don't include "osabi.h".
	(struct gdbarch_tdep): Remove osabi member.
	* sh-tdep.c: Include "osabi.h".
	(sh_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't
	iterate over arches.  Update call to gdbarch_init_osabi.
	(sh_dump_tdep): Don't dump osabi.
	* shnbsd-tdep.c: Include "osabi.h".

	* sparc-tdep.c: Include "osabi.h".
	(sparc_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't
	iterate over arches.  Update call to gdbarch_init_osabi.
	(sparc_dump_tdep): Don't dump osabi.  Do dump the rest of the
	tdep structure.

	* vax-tdep.h: Don't include "osabi.h".
	(struct gdbarch_tdep): Remove.
	* vax-tdep.c: Include "osabi.h".
	(vax_gdbarch_init): Don't call gdbarch_lookup_osabi.  Don't
	iterate over arches.  Don't allocate tdep.  Update call
	to gdbarch_init_osabi.
	(vax_dump_tdep): Remove.
	(_initialize_vax_tdep): Update call to gdbarch_register.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.299
diff -u -p -r1.299 Makefile.in
--- Makefile.in	26 Dec 2002 09:36:41 -0000	1.299
+++ Makefile.in	27 Dec 2002 23:22:44 -0000
@@ -612,11 +612,11 @@ nm_h =		@nm_h@
 
 acconfig_h = acconfig.h
 ada_lang_h = ada-lang.h $(value_h) $(gdbtypes_h)
-alpha_tdep_h = alpha-tdep.h $(osabi_h)
+alpha_tdep_h = alpha-tdep.h
 alphabsd_tdep_h = alphabsd-tdep.h
 annotate_h = annotate.h $(symtab_h) $(gdbtypes_h)
 arch_utils_h = arch-utils.h
-arm_tdep_h = arm-tdep.h $(osabi_h)
+arm_tdep_h = arm-tdep.h
 ax_gdb_h = ax-gdb.h
 ax_h = ax.h $(doublest_h)
 bcache_h = bcache.h
@@ -662,7 +662,7 @@ gdb_string_h = gdb_string.h
 gdb_thread_db_h = gdb_thread_db.h
 gdb_vfork_h = gdb_vfork.h
 gdb_wait_h = gdb_wait.h
-gdbarch_h = gdbarch.h $(dis_asm_h) $(value_h) $(inferior_h)
+gdbarch_h = gdbarch.h $(dis_asm_h) $(value_h) $(inferior_h) $(osabi_list_h)
 gdbcmd_h = gdbcmd.h $(command_h) $(ui_out_h)
 gdbcore_h = gdbcore.h $(bfd_h)
 gdbthread_h = gdbthread.h $(breakpoint_h) $(frame_h)
@@ -670,7 +670,7 @@ gdbtypes_h = gdbtypes.h
 gnu_nat_h = gnu-nat.h
 gregset_h = gregset.h
 i386_linux_tdep_h = i386-linux-tdep.h
-i386_tdep_h = i386-tdep.h $(osabi_h)
+i386_tdep_h = i386-tdep.h
 i387_tdep_h = i387-tdep.h
 inf_loop_h = inf-loop.h
 inferior_h = inferior.h $(breakpoint_h) $(target_h) $(frame_h)
@@ -690,15 +690,16 @@ mips_tdep_h = mips-tdep.h
 mipsnbsd_tdep_h = mipsnbsd-tdep.h
 monitor_h = monitor.h
 nbsd_tdep_h = nbsd-tdep.h
-ns32k_tdep_h = ns32k-tdep.h $(osabi_h)
+ns32k_tdep_h = ns32k-tdep.h
 objc_lang_h = objc-lang.h
 objfiles_h = objfiles.h $(gdb_obstack_h) $(symfile_h)
 ocd_h = ocd.h
 osabi_h = osabi.h
+osabi_list_h = osabi_list.h
 p_lang_h = p-lang.h
 pa64solib_h = pa64solib.h
 parser_defs_h = parser-defs.h $(doublest_h)
-ppc_tdep_h = ppc-tdep.h $(osabi_h)
+ppc_tdep_h = ppc-tdep.h
 ppcnbsd_tdep_h = ppcnbsd-tdep.h
 proc_utils_h = proc-utils.h
 regcache_h = regcache.h
@@ -709,7 +710,7 @@ scm_lang_h = scm-lang.h $(scm_tags_h)
 scm_tags_h = scm-tags.h
 ser_unix_h = ser-unix.h
 serial_h = serial.h
-sh_tdep_h = sh-tdep.h $(osabi_h)
+sh_tdep_h = sh-tdep.h
 shnbsd_tdep_h = shnbsd-tdep.h
 sim_regno_h = sim-regno.h
 solib_svr4_h = solib-svr4.h
@@ -732,7 +733,7 @@ ui_out_h = ui-out.h
 valprint_h = valprint.h
 value_h = value.h $(doublest_h) $(symtab_h) $(gdbtypes_h) $(expression_h)
 varobj_h = varobj.h $(symtab_h) $(gdbtypes_h)
-vax_tdep_h = vax-tdep.h $(osabi_h)
+vax_tdep_h = vax-tdep.h
 version_h = version.h
 wince_stub_h = wince-stub.h
 wrapper_h = wrapper.h $(gdb_h)
@@ -1520,23 +1521,25 @@ aix-thread.o: aix-thread.c $(defs_h) $(g
 	$(target_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) $(language_h) \
 	$(ppc_tdep_h)
 alpha-linux-tdep.o: alpha-linux-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
-	$(value_h) $(alpha_tdep_h)
+	$(value_h) $(alpha_tdep_h) $(osabi_h)
 alpha-nat.o: alpha-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) $(target_h) \
 	$(regcache_h) $(alpha_tdep_h) $(gregset_h) $(gdb_string_h)
 alpha-osf1-tdep.o: alpha-osf1-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
-	$(value_h) $(alpha_tdep_h)
+	$(value_h) $(alpha_tdep_h) $(osabi_h)
 alpha-tdep.o: alpha-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
 	$(value_h) $(gdbcmd_h) $(gdbcore_h) $(dis_asm_h) $(symfile_h) \
 	$(objfiles_h) $(gdb_string_h) $(linespec_h) $(regcache_h) \
-	$(doublest_h) $(arch_utils_h) $(elf_bfd_h) $(alpha_tdep_h)
+	$(doublest_h) $(arch_utils_h) $(elf_bfd_h) $(alpha_tdep_h) \
+	$(osabi_h)
 alphabsd-nat.o: alphabsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
 	$(alpha_tdep_h) $(alphabsd_tdep_h) $(gregset_h)
 alphabsd-tdep.o: alphabsd-tdep.c $(defs_h) $(regcache_h) $(alpha_tdep_h) \
 	$(alphabsd_tdep_h)
-alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) $(alpha_tdep_h)
+alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) $(alpha_tdep_h) \
+	$(osabi_h)
 alphanbsd-tdep.o: alphanbsd-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
 	$(regcache_h) $(value_h) $(solib_svr4_h) $(alpha_tdep_h) \
-	$(alphabsd_tdep_h) $(nbsd_tdep_h)
+	$(alphabsd_tdep_h) $(nbsd_tdep_h) $(osabi_h)
 annotate.o: annotate.c $(defs_h) $(annotate_h) $(value_h) $(target_h) \
 	$(gdbtypes_h) $(breakpoint_h)
 # OBSOLETE arc-tdep.o: arc-tdep.c
@@ -1549,16 +1552,17 @@ arm-linux-nat.o: arm-linux-nat.c $(defs_
 	$(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h)
 arm-linux-tdep.o: arm-linux-tdep.c $(defs_h) $(target_h) $(value_h) \
 	$(gdbtypes_h) $(floatformat_h) $(gdbcore_h) $(frame_h) $(regcache_h) \
-	$(doublest_h) $(arm_tdep_h) $(symtab_h) $(symfile_h) $(objfiles_h)
+	$(doublest_h) $(arm_tdep_h) $(symtab_h) $(symfile_h) $(objfiles_h) \
+	$(osabi_h)
 arm-tdep.o: arm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(gdbcmd_h) \
 	$(gdbcore_h) $(symfile_h) $(gdb_string_h) $(dis_asm_h) $(regcache_h) \
 	$(doublest_h) $(value_h) $(arch_utils_h) $(solib_svr4_h) \
 	$(arm_tdep_h) $(gdb_sim_arm_h) $(elf_bfd_h) $(coff_internal_h) \
-	$(elf_arm_h) $(gdb_assert_h) $(bfd_in2_h) $(libcoff_h)
+	$(elf_arm_h) $(gdb_assert_h) $(bfd_in2_h) $(libcoff_h) $(osabi_h)
 armnbsd-nat.o: armnbsd-nat.c $(defs_h) $(arm_tdep_h) $(inferior_h) \
 	$(regcache_h) $(gdbcore_h)
 armnbsd-tdep.o: armnbsd-tdep.c $(defs_h) $(arm_tdep_h) $(nbsd_tdep_h) \
-	$(solib_svr4_h)
+	$(solib_svr4_h) $(osabi_h)
 avr-tdep.o: avr-tdep.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) $(inferior_h) \
 	$(symfile_h) $(arch_utils_h) $(regcache_h) $(gdb_string_h)
 ax-gdb.o: ax-gdb.c $(defs_h) $(symtab_h) $(symfile_h) $(gdbtypes_h) \
@@ -1729,7 +1733,8 @@ gdbarch.o: gdbarch.c $(defs_h) $(arch_ut
 	$(gdb_string_h) $(symtab_h) $(frame_h) $(inferior_h) $(breakpoint_h) \
 	$(gdb_wait_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(gdbthread_h) \
 	$(annotate_h) $(symfile_h) $(value_h) $(symcat_h) $(floatformat_h) \
-	$(gdb_assert_h) $(gdb_string_h) $(gdb_events_h) $(reggroups_h)
+	$(gdb_assert_h) $(gdb_string_h) $(gdb_events_h) $(reggroups_h) \
+	$(osabi_h)
 gdbtypes.o: gdbtypes.c $(defs_h) $(gdb_string_h) $(bfd_h) $(symtab_h) \
 	$(symfile_h) $(objfiles_h) $(gdbtypes_h) $(expression_h) \
 	$(language_h) $(target_h) $(value_h) $(demangle_h) $(complaints_h) \
@@ -1778,36 +1783,39 @@ i386-linux-nat.o: i386-linux-nat.c $(def
 	$(i387_tdep_h) $(i386_tdep_h) $(i386_linux_tdep_h)
 i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
 	$(value_h) $(regcache_h) $(inferior_h) $(symtab_h) $(symfile_h) \
-	$(objfiles_h) $(solib_svr4_h) $(i386_tdep_h) $(i386_linux_tdep_h)
+	$(objfiles_h) $(solib_svr4_h) $(i386_tdep_h) $(i386_linux_tdep_h) \
+	$(osabi_h)
 i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
-i386-sol2-tdep.o: i386-sol2-tdep.c $(defs_h) $(value_h) $(i386_tdep_h)
+i386-sol2-tdep.o: i386-sol2-tdep.c $(defs_h) $(value_h) $(i386_tdep_h) \
+	$(osabi_h)
 i386-stub.o: i386-stub.c
 i386-tdep.o: i386-tdep.c $(defs_h) $(gdb_string_h) $(frame_h) $(inferior_h) \
 	$(gdbcore_h) $(objfiles_h) $(target_h) $(floatformat_h) $(symfile_h) \
 	$(symtab_h) $(gdbcmd_h) $(command_h) $(arch_utils_h) $(regcache_h) \
 	$(doublest_h) $(value_h) $(gdb_assert_h) $(i386_tdep_h) \
-	$(i387_tdep_h)
+	$(i387_tdep_h) $(osabi_h)
 # OBSOLETE i386aix-nat.o: i386aix-nat.c
 i386b-nat.o: i386b-nat.c $(defs_h)
 i386bsd-nat.o: i386bsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
 	$(gdb_assert_h) $(gregset_h) $(i386_tdep_h) $(i387_tdep_h)
 i386bsd-tdep.o: i386bsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
-	$(gdbcore_h) $(regcache_h) $(gdb_string_h) $(i386_tdep_h)
+	$(gdbcore_h) $(regcache_h) $(gdb_string_h) $(i386_tdep_h) \
+	$(osabi_h)
 i386fbsd-nat.o: i386fbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h)
 i386gnu-nat.o: i386gnu-nat.c $(defs_h) $(inferior_h) $(floatformat_h) \
 	$(regcache_h) $(gdb_assert_h) $(i386_tdep_h) $(gnu_nat_h) \
 	$(i387_tdep_h)
-i386gnu-tdep.o: i386gnu-tdep.c $(defs_h) $(i386_tdep_h)
+i386gnu-tdep.o: i386gnu-tdep.c $(defs_h) $(i386_tdep_h) $(osabi_h)
 i386ly-tdep.o: i386ly-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
-	$(regcache_h) $(target_h) $(i386_tdep_h)
+	$(regcache_h) $(target_h) $(i386_tdep_h) $(osabi_h)
 # OBSOLETE i386m3-nat.o: i386m3-nat.c
 # OBSOLETE i386mach-nat.o: i386mach-nat.c
 i386nbsd-tdep.o: i386nbsd-tdep.c $(defs_h) $(gdbtypes_h) $(gdbcore_h) \
 	$(regcache_h) $(arch_utils_h) $(i386_tdep_h) $(i387_tdep_h) \
-	$(nbsd_tdep_h) $(solib_svr4_h)
+	$(nbsd_tdep_h) $(solib_svr4_h) $(osabi_h)
 i386obsd-nat.o: i386obsd-nat.c $(defs_h)
 i386obsd-tdep.o: i386obsd-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \
-	$(regcache_h) $(i386_tdep_h) $(i387_tdep_h)
+	$(regcache_h) $(i386_tdep_h) $(i387_tdep_h) $(osabi_h)
 i386v-nat.o: i386v-nat.c $(defs_h) $(frame_h) $(inferior_h) $(language_h) \
 	$(gdbcore_h) $(gdb_stat_h) $(floatformat_h) $(target_h) $(i386_tdep_h)
 i386v4-nat.o: i386v4-nat.c $(defs_h) $(value_h) $(inferior_h) $(regcache_h) \
@@ -1985,10 +1993,11 @@ nlmread.o: nlmread.c $(defs_h) $(bfd_h) 
 	$(objfiles_h) $(buildsym_h) $(stabsread_h)
 ns32k-tdep.o: ns32k-tdep.c $(defs_h) $(frame_h) $(gdbtypes_h) $(gdbcore_h) \
 	$(inferior_h) $(regcache_h) $(target_h) $(arch_utils_h) \
-	$(ns32k_tdep_h) $(gdb_string_h)
+	$(ns32k_tdep_h) $(gdb_string_h) $(osabi_h)
 ns32knbsd-nat.o: ns32knbsd-nat.c $(defs_h) $(inferior_h) $(target_h) \
 	$(gdbcore_h) $(regcache_h)
-ns32knbsd-tdep.o: ns32knbsd-tdep.c $(defs_h) $(ns32k_tdep_h) $(gdb_string_h)
+ns32knbsd-tdep.o: ns32knbsd-tdep.c $(defs_h) $(ns32k_tdep_h) $(gdb_string_h) \
+	$(osabi_h)
 objc-lang.o: objc-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
 	$(parser_defs_h) $(language_h) $(c_lang_h) $(objc_lang_h) \
 	$(complaints_h) $(value_h) $(symfile_h) $(objfiles_h) \
@@ -2030,7 +2039,8 @@ ppc-linux-nat.o: ppc-linux-nat.c $(defs_
 	$(gdbcore_h) $(regcache_h) $(gregset_h) $(ppc_tdep_h) $(gdb_string_h)
 ppc-linux-tdep.o: ppc-linux-tdep.c $(defs_h) $(frame_h) $(inferior_h) \
 	$(symtab_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(symfile_h) \
-	$(objfiles_h) $(regcache_h) $(value_h) $(solib_svr4_h) $(ppc_tdep_h)
+	$(objfiles_h) $(regcache_h) $(value_h) $(solib_svr4_h) $(ppc_tdep_h) \
+	$(osabi_h)
 ppc-sysv-tdep.o: ppc-sysv-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
 	$(regcache_h) $(value_h) $(gdb_string_h) $(ppc_tdep_h)
 ppcbug-rom.o: ppcbug-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
@@ -2039,7 +2049,7 @@ ppcnbsd-nat.o: ppcnbsd-nat.c $(defs_h) $
 	$(ppcnbsd_tdep_h)
 ppcnbsd-tdep.o: ppcnbsd-tdep.c $(defs_h) $(gdbcore_h) $(regcache_h) \
 	$(target_h) $(breakpoint_h) $(value_h) $(ppc_tdep_h) \
-	$(ppcnbsd_tdep_h) $(nbsd_tdep_h) $(solib_svr4_h)
+	$(ppcnbsd_tdep_h) $(nbsd_tdep_h) $(solib_svr4_h) $(osabi_h)
 printcmd.o: printcmd.c $(defs_h) $(gdb_string_h) $(frame_h) $(symtab_h) \
 	$(gdbtypes_h) $(value_h) $(language_h) $(expression_h) $(gdbcore_h) \
 	$(gdbcmd_h) $(target_h) $(breakpoint_h) $(demangle_h) $(valprint_h) \
@@ -2139,7 +2149,7 @@ rs6000-tdep.o: rs6000-tdep.c $(defs_h) $
 	$(arch_utils_h) $(regcache_h) $(doublest_h) $(value_h) \
 	$(parser_defs_h) $(libbfd_h) $(coff_internal_h) $(libcoff_h) \
 	$(coff_xcoff_h) $(libxcoff_h) $(elf_bfd_h) $(solib_svr4_h) \
-	$(ppc_tdep_h)
+	$(ppc_tdep_h) $(osabi_h)
 s390-nat.o: s390-nat.c $(defs_h) $(tm_h) $(regcache_h)
 s390-tdep.o: s390-tdep.c $(arch_utils_h) $(frame_h) $(inferior_h) \
 	$(symtab_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(symfile_h) \
@@ -2167,13 +2177,13 @@ sh-tdep.o: sh-tdep.c $(defs_h) $(frame_h
 	$(gdbtypes_h) $(gdbcmd_h) $(gdbcore_h) $(value_h) $(dis_asm_h) \
 	$(inferior_h) $(gdb_string_h) $(arch_utils_h) $(floatformat_h) \
 	$(regcache_h) $(doublest_h) $(sh_tdep_h) $(elf_bfd_h) \
-	$(solib_svr4_h) $(elf_sh_h) $(gdb_sim_sh_h)
+	$(solib_svr4_h) $(elf_sh_h) $(gdb_sim_sh_h) $(osabi_h)
 sh3-rom.o: sh3-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
 	$(serial_h) $(srec_h) $(arch_utils_h) $(regcache_h) $(gdb_string_h) \
 	$(sh_tdep_h)
 shnbsd-nat.o: shnbsd-nat.c $(defs_h) $(inferior_h) $(shnbsd_tdep_h)
 shnbsd-tdep.o: shnbsd-tdep.c $(defs_h) $(gdbcore_h) $(regcache_h) $(value_h) \
-	$(solib_svr4_h) $(nbsd_tdep_h) $(sh_tdep_h) $(shnbsd_tdep_h)
+	$(solib_svr4_h) $(nbsd_tdep_h) $(sh_tdep_h) $(shnbsd_tdep_h) $(osabi_h)
 sol-thread.o: sol-thread.c $(defs_h) $(gdbthread_h) $(target_h) \
 	$(inferior_h) $(gdbcmd_h) $(gdbcore_h) $(regcache_h) $(symfile_h) \
 	$(gregset_h)
@@ -2321,7 +2331,7 @@ varobj.o: varobj.c $(defs_h) $(value_h) 
 	$(language_h) $(wrapper_h) $(gdbcmd_h) $(gdb_string_h) $(varobj_h)
 vax-tdep.o: vax-tdep.c $(defs_h) $(symtab_h) $(opcode_vax_h) $(gdbcore_h) \
 	$(inferior_h) $(regcache_h) $(frame_h) $(value_h) $(arch_utils_h) \
-	$(gdb_string_h) $(vax_tdep_h)
+	$(gdb_string_h) $(vax_tdep_h) $(osabi_h)
 w89k-rom.o: w89k-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
 	$(serial_h) $(xmodem_h) $(regcache_h)
 win32-nat.o: win32-nat.c $(defs_h) $(tm_h) $(frame_h) $(inferior_h) \
Index: alpha-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-linux-tdep.c,v
retrieving revision 1.7
diff -u -p -r1.7 alpha-linux-tdep.c
--- alpha-linux-tdep.c	21 Dec 2002 19:58:07 -0000	1.7
+++ alpha-linux-tdep.c	27 Dec 2002 23:22:44 -0000
@@ -22,6 +22,7 @@
 #include "frame.h"
 #include "gdbcore.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "alpha-tdep.h"
 
Index: alpha-osf1-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-osf1-tdep.c,v
retrieving revision 1.7
diff -u -p -r1.7 alpha-osf1-tdep.c
--- alpha-osf1-tdep.c	21 Dec 2002 19:58:07 -0000	1.7
+++ alpha-osf1-tdep.c	27 Dec 2002 23:22:44 -0000
@@ -22,6 +22,7 @@
 #include "frame.h"
 #include "gdbcore.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "alpha-tdep.h"
 
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.48
diff -u -p -r1.48 alpha-tdep.c
--- alpha-tdep.c	11 Dec 2002 02:26:34 -0000	1.48
+++ alpha-tdep.c	27 Dec 2002 23:22:44 -0000
@@ -34,6 +34,7 @@
 #include "regcache.h"
 #include "doublest.h"
 #include "arch-utils.h"
+#include "osabi.h"
 
 #include "elf-bfd.h"
 
@@ -1768,37 +1769,23 @@ alpha_gdbarch_init (struct gdbarch_info 
 {
   struct gdbarch_tdep *tdep;
   struct gdbarch *gdbarch;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
   /* Try to determine the ABI of the object we are loading.  */
-
-  if (info.abfd != NULL)
+  if (info.abfd != NULL && info.osabi == GDB_OSABI_UNKNOWN)
     {
-      osabi = gdbarch_lookup_osabi (info.abfd);
-      if (osabi == GDB_OSABI_UNKNOWN)
-	{
-	  /* If it's an ECOFF file, assume it's OSF/1.  */
-	  if (bfd_get_flavour (info.abfd) == bfd_target_ecoff_flavour)
-	    osabi = GDB_OSABI_OSF1;
-	}
+      /* If it's an ECOFF file, assume it's OSF/1.  */
+      if (bfd_get_flavour (info.abfd) == bfd_target_ecoff_flavour)
+	osabi = GDB_OSABI_OSF1;
     }
 
   /* Find a candidate among extant architectures.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-	return arches->gdbarch;
-    }
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
   tdep = xmalloc (sizeof (struct gdbarch_tdep));
   gdbarch = gdbarch_alloc (&info, tdep);
 
-  tdep->osabi = osabi;
-
   /* Lowest text address.  This is used by heuristic_proc_start() to
      decide when to stop looking.  */
   tdep->vm_min_address = (CORE_ADDR) 0x120000000;
@@ -1912,7 +1899,7 @@ alpha_gdbarch_init (struct gdbarch_info 
   set_gdbarch_frame_args_skip (gdbarch, 0);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   /* Now that we have tuned the configuration, set a few final things
      based on what the OS ABI has told us.  */
@@ -1930,9 +1917,6 @@ alpha_dump_tdep (struct gdbarch *current
 
   if (tdep == NULL)
     return;
-
-  fprintf_unfiltered (file, "alpha_dump_tdep: OS ABI = %s\n",
-		      gdbarch_osabi_name (tdep->osabi));
 
   fprintf_unfiltered (file,
                       "alpha_dump_tdep: vm_min_address = 0x%lx\n",
Index: alpha-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.h,v
retrieving revision 1.8
diff -u -p -r1.8 alpha-tdep.h
--- alpha-tdep.h	21 May 2002 15:36:02 -0000	1.8
+++ alpha-tdep.h	27 Dec 2002 23:22:44 -0000
@@ -22,8 +22,6 @@
 #ifndef ALPHA_TDEP_H
 #define ALPHA_TDEP_H
 
-#include "osabi.h"
-
 /* Say how long (ordinary) registers are.  This is a piece of bogosity
    used in push_word and a few other places;  REGISTER_RAW_SIZE is the
    real way to know how big a register is.  */
@@ -81,8 +79,6 @@
 /* Target-dependent structure in gdbarch.  */
 struct gdbarch_tdep
 {
-  enum gdb_osabi osabi;		/* OS/ABI of inferior.  */
-
   CORE_ADDR vm_min_address;	/* used by heuristic_proc_start */
 
   /* If PC is inside a dynamically-generated signal trampoline function
Index: alphafbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alphafbsd-tdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 alphafbsd-tdep.c
--- alphafbsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.6
+++ alphafbsd-tdep.c	27 Dec 2002 23:22:44 -0000
@@ -20,6 +20,7 @@
 
 #include "defs.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "alpha-tdep.h"
 
Index: alphanbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alphanbsd-tdep.c,v
retrieving revision 1.11
diff -u -p -r1.11 alphanbsd-tdep.c
--- alphanbsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.11
+++ alphanbsd-tdep.c	27 Dec 2002 23:22:44 -0000
@@ -24,6 +24,7 @@
 #include "frame.h"
 #include "regcache.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "solib-svr4.h"
 
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.73
diff -u -p -r1.73 arch-utils.c
--- arch-utils.c	9 Dec 2002 02:04:15 -0000	1.73
+++ arch-utils.c	27 Dec 2002 23:22:44 -0000
@@ -911,6 +911,7 @@ gdbarch_info_init (struct gdbarch_info *
 {
   memset (info, 0, sizeof (struct gdbarch_info));
   info->byte_order = BFD_ENDIAN_UNKNOWN;
+  info->osabi = GDB_OSABI_UNINITIALIZED;
 }
 
 /* */
Index: arm-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-linux-tdep.c,v
retrieving revision 1.24
diff -u -p -r1.24 arm-linux-tdep.c
--- arm-linux-tdep.c	21 Dec 2002 19:58:07 -0000	1.24
+++ arm-linux-tdep.c	27 Dec 2002 23:22:44 -0000
@@ -27,6 +27,7 @@
 #include "frame.h"
 #include "regcache.h"
 #include "doublest.h"
+#include "osabi.h"
 
 #include "arm-tdep.h"
 
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.84
diff -u -p -r1.84 arm-tdep.c
--- arm-tdep.c	21 Dec 2002 19:58:07 -0000	1.84
+++ arm-tdep.c	27 Dec 2002 23:22:45 -0000
@@ -34,6 +34,7 @@
 #include "value.h"
 #include "arch-utils.h"
 #include "solib-svr4.h"
+#include "osabi.h"
 
 #include "arm-tdep.h"
 #include "gdb/sim-arm.h"
@@ -2815,44 +2816,33 @@ arm_gdbarch_init (struct gdbarch_info in
 {
   struct gdbarch_tdep *tdep;
   struct gdbarch *gdbarch;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
   /* Try to deterimine the ABI of the object we are loading.  */
 
-  if (info.abfd != NULL)
+  if (info.abfd != NULL && info.osabi == GDB_OSABI_UNKNOWN)
     {
-      osabi = gdbarch_lookup_osabi (info.abfd);
-      if (osabi == GDB_OSABI_UNKNOWN)
+      switch (bfd_get_flavour (info.abfd))
 	{
-	  switch (bfd_get_flavour (info.abfd))
-	    {
-	    case bfd_target_aout_flavour:
-	      /* Assume it's an old APCS-style ABI.  */
-	      osabi = GDB_OSABI_ARM_APCS;
-	      break;
+	case bfd_target_aout_flavour:
+	  /* Assume it's an old APCS-style ABI.  */
+	  info.osabi = GDB_OSABI_ARM_APCS;
+	  break;
 
-	    case bfd_target_coff_flavour:
-	      /* Assume it's an old APCS-style ABI.  */
-	      /* XXX WinCE?  */
-	      osabi = GDB_OSABI_ARM_APCS;
-	      break;
+	case bfd_target_coff_flavour:
+	  /* Assume it's an old APCS-style ABI.  */
+	  /* XXX WinCE?  */
+	  info.osabi = GDB_OSABI_ARM_APCS;
+	  break;
 
-	    default:
-	      /* Leave it as "unknown".  */
-	    }
+	default:
+	  /* Leave it as "unknown".  */
 	}
     }
 
-  /* Find a candidate among extant architectures.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-	return arches->gdbarch;
-    }
+  /* If there is already a candidate, use it.  */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
   tdep = xmalloc (sizeof (struct gdbarch_tdep));
   gdbarch = gdbarch_alloc (&info, tdep);
@@ -2861,8 +2851,6 @@ arm_gdbarch_init (struct gdbarch_info in
      ready to unwind the PC first (see frame.c:get_prev_frame()).  */
   set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
 
-  tdep->osabi = osabi;
-
   /* This is the way it has always defaulted.  */
   tdep->fp_model = ARM_FLOAT_FPA;
 
@@ -2995,7 +2983,7 @@ arm_gdbarch_init (struct gdbarch_info in
 					 arm_coff_make_msymbol_special);
 
   /* Hook in the ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   /* Now we have tuned the configuration, set a few final things,
      based on what the OS ABI has told us.  */
@@ -3060,9 +3048,6 @@ arm_dump_tdep (struct gdbarch *current_g
 
   if (tdep == NULL)
     return;
-
-  fprintf_unfiltered (file, "arm_dump_tdep: OS ABI = %s\n",
-		      gdbarch_osabi_name (tdep->osabi));
 
   fprintf_unfiltered (file, "arm_dump_tdep: Lowest pc = 0x%lx",
 		      (unsigned long) tdep->lowest_pc);
Index: arm-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.h,v
retrieving revision 1.9
diff -u -p -r1.9 arm-tdep.h
--- arm-tdep.h	21 May 2002 15:36:03 -0000	1.9
+++ arm-tdep.h	27 Dec 2002 23:22:45 -0000
@@ -18,8 +18,6 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include "osabi.h"
-
 /* Register numbers of various important registers.  Note that some of
    these values are "real" register numbers, and correspond to the
    general registers of the machine, and some are "phony" register
@@ -124,8 +122,6 @@ enum arm_float_model
 /* Target-dependent structure in gdbarch.  */
 struct gdbarch_tdep
 {
-  enum gdb_osabi osabi;		/* OS/ABI of inferior.  */
-
   enum arm_float_model fp_model; /* Floating point calling conventions.  */
 
   CORE_ADDR lowest_pc;		/* Lowest address at which instructions 
Index: armnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/armnbsd-tdep.c,v
retrieving revision 1.8
diff -u -p -r1.8 armnbsd-tdep.c
--- armnbsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.8
+++ armnbsd-tdep.c	27 Dec 2002 23:22:45 -0000
@@ -19,6 +19,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "osabi.h"
 
 #include "arm-tdep.h"
 #include "nbsd-tdep.h"
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.173
diff -u -p -r1.173 gdbarch.c
--- gdbarch.c	11 Dec 2002 20:19:39 -0000	1.173
+++ gdbarch.c	27 Dec 2002 23:22:46 -0000
@@ -65,6 +65,7 @@
 #include "gdb_string.h"
 #include "gdb-events.h"
 #include "reggroups.h"
+#include "osabi.h"
 
 /* Static function declarations */
 
@@ -93,6 +94,7 @@ struct gdbarch
   /* basic architectural information */
   const struct bfd_arch_info * bfd_arch_info;
   int byte_order;
+  enum gdb_osabi osabi;
 
   /* target specific vector. */
   struct gdbarch_tdep *tdep;
@@ -290,6 +292,7 @@ struct gdbarch startup_gdbarch =
   /* basic architecture information */
   &bfd_default_arch_struct,
   BFD_ENDIAN_BIG,
+  GDB_OSABI_UNKNOWN,
   /* target specific vector and its dump routine */
   NULL, NULL,
   /*per-architecture data-pointers and swap regions */
@@ -480,6 +483,7 @@ gdbarch_alloc (const struct gdbarch_info
 
   current_gdbarch->bfd_arch_info = info->bfd_arch_info;
   current_gdbarch->byte_order = info->byte_order;
+  current_gdbarch->osabi = info->osabi;
 
   /* Force the explicit initialization of these. */
   current_gdbarch->short_bit = 2*TARGET_CHAR_BIT;
@@ -2395,6 +2399,14 @@ gdbarch_dump (struct gdbarch *gdbarch, s
                       "gdbarch_dump: TARGET_LONG_LONG_BIT = %d\n",
                       TARGET_LONG_LONG_BIT);
 #endif
+#ifdef TARGET_OSABI
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: TARGET_OSABI # %s\n",
+                      XSTRING (TARGET_OSABI));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: TARGET_OSABI = %ld\n",
+                      (long) TARGET_OSABI);
+#endif
 #ifdef TARGET_PRINT_INSN
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
@@ -2553,6 +2565,15 @@ gdbarch_byte_order (struct gdbarch *gdba
   return gdbarch->byte_order;
 }
 
+enum gdb_osabi
+gdbarch_osabi (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_osabi called\n");
+  return gdbarch->osabi;
+}
+
 int
 gdbarch_short_bit (struct gdbarch *gdbarch)
 {
@@ -5779,6 +5800,8 @@ gdbarch_list_lookup_by_info (struct gdba
 	continue;
       if (info->byte_order != arches->gdbarch->byte_order)
 	continue;
+      if (info->osabi != arches->gdbarch->osabi)
+	continue;
       return arches;
     }
   return NULL;
@@ -5824,6 +5847,12 @@ gdbarch_update_p (struct gdbarch_info in
   if (info.byte_order == BFD_ENDIAN_UNKNOWN)
     info.byte_order = TARGET_BYTE_ORDER;
 
+  /* ``(gdb) set osabi ...'' is handled by gdbarch_lookup_osabi.  */
+  if (info.osabi == GDB_OSABI_UNINITIALIZED)
+    info.osabi = gdbarch_lookup_osabi (info.abfd);
+  if (info.osabi == GDB_OSABI_UNINITIALIZED)
+    info.osabi = current_gdbarch->osabi;
+
   /* Must have found some sort of architecture. */
   gdb_assert (info.bfd_arch_info != NULL);
 
@@ -5840,6 +5869,9 @@ gdbarch_update_p (struct gdbarch_info in
 			  (info.byte_order == BFD_ENDIAN_BIG ? "big"
 			   : info.byte_order == BFD_ENDIAN_LITTLE ? "little"
 			   : "default"));
+      fprintf_unfiltered (gdb_stdlog,
+			  "gdbarch_update: info.osabi %d (%s)\n",
+			  info.osabi, gdbarch_osabi_name (info.osabi));
       fprintf_unfiltered (gdb_stdlog,
 			  "gdbarch_update: info.abfd 0x%lx\n",
 			  (long) info.abfd);
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.134
diff -u -p -r1.134 gdbarch.h
--- gdbarch.h	11 Dec 2002 20:19:39 -0000	1.134
+++ gdbarch.h	27 Dec 2002 23:22:46 -0000
@@ -36,6 +36,7 @@
 #define GDBARCH_H
 
 #include "dis-asm.h" /* Get defs for disassemble_info, which unfortunately is a typedef. */
+#include "osabi_list.h" /* Get def for enum gdb_osabi.  */
 #if !GDB_MULTI_ARCH
 /* Pull in function declarations refered to, indirectly, via macros.  */
 #include "value.h" /* For default_coerce_float_to_double which is referenced by a macro.  */
@@ -96,6 +97,17 @@ extern int gdbarch_byte_order (struct gd
 #endif
 #endif
 
+extern enum gdb_osabi gdbarch_osabi (struct gdbarch *gdbarch);
+/* set_gdbarch_osabi() - not applicable - pre-initialized. */
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_OSABI)
+#error "Non multi-arch definition of TARGET_OSABI"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_OSABI)
+#define TARGET_OSABI (gdbarch_osabi (current_gdbarch))
+#endif
+#endif
+
 
 /* The following are initialized by the target dependent code. */
 
@@ -2859,6 +2871,9 @@ struct gdbarch_info
 
   /* Use default: NULL (ZERO). */
   struct gdbarch_tdep_info *tdep_info;
+
+  /* Use default: GDB_OSABI_UNINITIALIZED (-1).  */
+  enum gdb_osabi osabi;
 };
 
 typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct gdbarch_list *arches);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.185
diff -u -p -r1.185 gdbarch.sh
--- gdbarch.sh	11 Dec 2002 20:19:39 -0000	1.185
+++ gdbarch.sh	27 Dec 2002 23:22:47 -0000
@@ -387,6 +387,8 @@ function_list ()
 i:2:TARGET_ARCHITECTURE:const struct bfd_arch_info *:bfd_arch_info::::&bfd_default_arch_struct::::%s:TARGET_ARCHITECTURE->printable_name:TARGET_ARCHITECTURE != NULL
 #
 i:2:TARGET_BYTE_ORDER:int:byte_order::::BFD_ENDIAN_BIG
+#
+i:2:TARGET_OSABI:enum gdb_osabi:osabi::::GDB_OSABI_UNKNOWN
 # Number of bits in a char or unsigned char for the target machine.
 # Just like CHAR_BIT in <limits.h> but describes the target machine.
 # v::TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
@@ -777,6 +779,7 @@ cat <<EOF
 #define GDBARCH_H
 
 #include "dis-asm.h" /* Get defs for disassemble_info, which unfortunately is a typedef. */
+#include "osabi_list.h" /* Get def for enum gdb_osabi.  */
 #if !GDB_MULTI_ARCH
 /* Pull in function declarations refered to, indirectly, via macros.  */
 #include "value.h" /* For default_coerce_float_to_double which is referenced by a macro.  */
@@ -1045,6 +1048,9 @@ struct gdbarch_info
 
   /* Use default: NULL (ZERO). */
   struct gdbarch_tdep_info *tdep_info;
+
+  /* Use default: GDB_OSABI_UNINITIALIZED (-1).  */
+  enum gdb_osabi osabi;
 };
 
 typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct gdbarch_list *arches);
@@ -1265,6 +1271,7 @@ cat <<EOF
 #include "gdb_string.h"
 #include "gdb-events.h"
 #include "reggroups.h"
+#include "osabi.h"
 
 /* Static function declarations */
 
@@ -2135,6 +2142,8 @@ gdbarch_list_lookup_by_info (struct gdba
 	continue;
       if (info->byte_order != arches->gdbarch->byte_order)
 	continue;
+      if (info->osabi != arches->gdbarch->osabi)
+	continue;
       return arches;
     }
   return NULL;
@@ -2180,6 +2189,12 @@ gdbarch_update_p (struct gdbarch_info in
   if (info.byte_order == BFD_ENDIAN_UNKNOWN)
     info.byte_order = TARGET_BYTE_ORDER;
 
+  /* \`\`(gdb) set osabi ...'' is handled by gdbarch_lookup_osabi.  */
+  if (info.osabi == GDB_OSABI_UNINITIALIZED)
+    info.osabi = gdbarch_lookup_osabi (info.abfd);
+  if (info.osabi == GDB_OSABI_UNINITIALIZED)
+    info.osabi = current_gdbarch->osabi;
+
   /* Must have found some sort of architecture. */
   gdb_assert (info.bfd_arch_info != NULL);
 
@@ -2196,6 +2211,9 @@ gdbarch_update_p (struct gdbarch_info in
 			  (info.byte_order == BFD_ENDIAN_BIG ? "big"
 			   : info.byte_order == BFD_ENDIAN_LITTLE ? "little"
 			   : "default"));
+      fprintf_unfiltered (gdb_stdlog,
+			  "gdbarch_update: info.osabi %d (%s)\n",
+			  info.osabi, gdbarch_osabi_name (info.osabi));
       fprintf_unfiltered (gdb_stdlog,
 			  "gdbarch_update: info.abfd 0x%lx\n",
 			  (long) info.abfd);
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.43
diff -u -p -r1.43 hppa-tdep.c
--- hppa-tdep.c	26 Dec 2002 20:10:13 -0000	1.43
+++ hppa-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -4959,19 +4959,13 @@ static struct gdbarch *
 hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
   struct gdbarch *gdbarch;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
   
   /* Try to determine the ABI of the object we are loading.  */
-
-  if (info.abfd != NULL)
+  if (info.abfd != NULL && info.osabi == GDB_OSABI_UNKNOWN)
     {
-      osabi = gdbarch_lookup_osabi (info.abfd);
-      if (osabi == GDB_OSABI_UNKNOWN)
-	{
-	  /* If it's a SOM file, assume it's HP/UX SOM.  */
-	  if (bfd_get_flavour (info.abfd) == bfd_target_som_flavour)
-	    osabi = GDB_OSABI_HPUX_SOM;
-	}
+      /* If it's a SOM file, assume it's HP/UX SOM.  */
+      if (bfd_get_flavour (info.abfd) == bfd_target_som_flavour)
+	info.osabi = GDB_OSABI_HPUX_SOM;
     }
 
   /* find a candidate among the list of pre-declared architectures.  */
@@ -4983,7 +4977,7 @@ hppa_gdbarch_init (struct gdbarch_info i
   gdbarch = gdbarch_alloc (&info, NULL);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   set_gdbarch_reg_struct_has_addr (gdbarch, hppa_reg_struct_has_addr);
   set_gdbarch_function_start_offset (gdbarch, 0);
Index: i386-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-tdep.c,v
retrieving revision 1.20
diff -u -p -r1.20 i386-linux-tdep.c
--- i386-linux-tdep.c	21 Dec 2002 19:58:07 -0000	1.20
+++ i386-linux-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -34,6 +34,8 @@
 
 #include "solib-svr4.h"		/* For struct link_map_offsets.  */
 
+#include "osabi.h"
+
 #include "i386-tdep.h"
 #include "i386-linux-tdep.h"
 
Index: i386-sol2-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-sol2-tdep.c,v
retrieving revision 1.8
diff -u -p -r1.8 i386-sol2-tdep.c
--- i386-sol2-tdep.c	21 Dec 2002 19:58:07 -0000	1.8
+++ i386-sol2-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -20,6 +20,7 @@
 
 #include "defs.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "i386-tdep.h"
 
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.104
diff -u -p -r1.104 i386-tdep.c
--- i386-tdep.c	21 Dec 2002 19:58:07 -0000	1.104
+++ i386-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -39,6 +39,7 @@
 #include "gdb_assert.h"
 #include "reggroups.h"
 #include "dummy-frame.h"
+#include "osabi.h"
 
 #include "i386-tdep.h"
 #include "i387-tdep.h"
@@ -1499,22 +1500,11 @@ i386_gdbarch_init (struct gdbarch_info i
 {
   struct gdbarch_tdep *tdep;
   struct gdbarch *gdbarch;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
-  /* Try to determine the OS ABI of the object we're loading.  */
-  if (info.abfd != NULL)
-    osabi = gdbarch_lookup_osabi (info.abfd);
-
-  /* Find a candidate among extant architectures.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the OS ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-        return arches->gdbarch;
-    }
+  /* If there is already a candidate, use it.  */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
   /* Allocate space for the new architecture.  */
   tdep = XMALLOC (struct gdbarch_tdep);
@@ -1524,8 +1514,6 @@ i386_gdbarch_init (struct gdbarch_info i
      ready to unwind the PC first (see frame.c:get_prev_frame()).  */
   set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
 
-  tdep->osabi = osabi;
-
   /* The i386 default settings don't include the SSE registers.
      FIXME: kettenis/20020614: They do include the FPU registers for
      now, which probably is not quite right.  */
@@ -1652,7 +1640,7 @@ i386_gdbarch_init (struct gdbarch_info i
   set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   return gdbarch;
 }
Index: i386-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.h,v
retrieving revision 1.19
diff -u -p -r1.19 i386-tdep.h
--- i386-tdep.h	8 Nov 2002 23:59:58 -0000	1.19
+++ i386-tdep.h	27 Dec 2002 23:22:48 -0000
@@ -22,8 +22,6 @@
 #ifndef I386_TDEP_H
 #define I386_TDEP_H
 
-#include "osabi.h"
-
 /* GDB's i386 target supports both the 32-bit Intel Architecture
    (IA-32) and the 64-bit AMD x86-64 architecture.  Internally it uses
    a similar register layout for both.
@@ -53,9 +51,6 @@ enum struct_return
 /* i386 architecture specific information.  */
 struct gdbarch_tdep
 {
-  /* ABI.  */
-  enum gdb_osabi osabi;
-
   /* Number of SSE registers.  */
   int num_xmm_regs;
 
Index: i386bsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386bsd-tdep.c,v
retrieving revision 1.11
diff -u -p -r1.11 i386bsd-tdep.c
--- i386bsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.11
+++ i386bsd-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -23,6 +23,7 @@
 #include "frame.h"
 #include "gdbcore.h"
 #include "regcache.h"
+#include "osabi.h"
 
 #include "gdb_string.h"
 
Index: i386gnu-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386gnu-tdep.c,v
retrieving revision 1.2
diff -u -p -r1.2 i386gnu-tdep.c
--- i386gnu-tdep.c	21 Dec 2002 19:58:07 -0000	1.2
+++ i386gnu-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -19,6 +19,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "osabi.h"
 
 #include "i386-tdep.h"
 
Index: i386ly-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386ly-tdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386ly-tdep.c
--- i386ly-tdep.c	21 Dec 2002 19:58:07 -0000	1.6
+++ i386ly-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -23,6 +23,7 @@
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
+#include "osabi.h"
 
 #include "i386-tdep.h"
 
Index: i386nbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-tdep.c,v
retrieving revision 1.12
diff -u -p -r1.12 i386nbsd-tdep.c
--- i386nbsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.12
+++ i386nbsd-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -24,6 +24,7 @@
 #include "gdbcore.h"
 #include "regcache.h"
 #include "arch-utils.h"
+#include "osabi.h"
 
 #include "i386-tdep.h"
 #include "i387-tdep.h"
Index: i386obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386obsd-tdep.c,v
retrieving revision 1.2
diff -u -p -r1.2 i386obsd-tdep.c
--- i386obsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.2
+++ i386obsd-tdep.c	27 Dec 2002 23:22:48 -0000
@@ -23,6 +23,7 @@
 #include "arch-utils.h"
 #include "gdbcore.h"
 #include "regcache.h"
+#include "osabi.h"
 
 #include "i386-tdep.h"
 #include "i387-tdep.h"
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.148
diff -u -p -r1.148 mips-tdep.c
--- mips-tdep.c	21 Dec 2002 06:36:02 -0000	1.148
+++ mips-tdep.c	27 Dec 2002 23:22:50 -0000
@@ -129,8 +129,6 @@ struct gdbarch_tdep
     int mips_default_stack_argsize;
     int gdb_target_is_mips64;
     int default_mask_address_p;
-
-    enum gdb_osabi osabi;
   };
 
 #define MIPS_EABI (gdbarch_tdep (current_gdbarch)->mips_abi == MIPS_ABI_EABI32 \
@@ -5625,7 +5623,6 @@ mips_gdbarch_init (struct gdbarch_info i
   struct gdbarch_tdep *tdep;
   int elf_flags;
   enum mips_abi mips_abi, found_abi, wanted_abi;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
   /* Reset the disassembly info, in case it was set to something
      non-default.  */
@@ -5640,10 +5637,6 @@ mips_gdbarch_init (struct gdbarch_info i
       /* First of all, extract the elf_flags, if available.  */
       if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
 	elf_flags = elf_elfheader (info.abfd)->e_flags;
-
-      /* Try to determine the OS ABI of the object we are loading.  If
-	 we end up with `unknown', just leave it that way.  */
-      osabi = gdbarch_lookup_osabi (info.abfd);
     }
 
   /* Check ELF_FLAGS to see if it specifies the ABI being used.  */
@@ -5740,15 +5733,13 @@ mips_gdbarch_init (struct gdbarch_info i
 	continue;
       if (gdbarch_tdep (arches->gdbarch)->mips_abi != mips_abi)
 	continue;
-      if (gdbarch_tdep (arches->gdbarch)->osabi == osabi)
-        return arches->gdbarch;
+      return arches->gdbarch;
     }
 
   /* Need a new architecture.  Fill in a target specific vector.  */
   tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
-  tdep->osabi = osabi;
 
   /* Initially set everything according to the default ABI/ISA.  */
   set_gdbarch_short_bit (gdbarch, 16);
@@ -5765,7 +5756,7 @@ mips_gdbarch_init (struct gdbarch_info i
   set_gdbarch_elf_make_msymbol_special (gdbarch, 
 					mips_elf_make_msymbol_special);
 
-  if (osabi == GDB_OSABI_IRIX)
+  if (info.osabi == GDB_OSABI_IRIX)
     set_gdbarch_num_regs (gdbarch, 71);
   else
     set_gdbarch_num_regs (gdbarch, 90);
@@ -6047,7 +6038,7 @@ mips_gdbarch_init (struct gdbarch_info i
   set_gdbarch_pc_in_sigtramp (gdbarch, mips_pc_in_sigtramp);
 
   /* Hook in OS ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   set_gdbarch_store_struct_return (gdbarch, mips_store_struct_return);
   set_gdbarch_extract_struct_value_address (gdbarch, 
@@ -6452,10 +6443,6 @@ mips_dump_tdep (struct gdbarch *current_
   fprintf_unfiltered (file,
 		      "mips_dump_tdep: _PROC_MAGIC_ = %d\n",
 		      _PROC_MAGIC_);
-
-  fprintf_unfiltered (file,
-		      "mips_dump_tdep: OS ABI = %s\n",
-		      gdbarch_osabi_name (tdep->osabi));
 }
 
 void
Index: ns32k-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ns32k-tdep.c,v
retrieving revision 1.25
diff -u -p -r1.25 ns32k-tdep.c
--- ns32k-tdep.c	11 Dec 2002 02:26:36 -0000	1.25
+++ ns32k-tdep.c	27 Dec 2002 23:22:50 -0000
@@ -26,8 +26,8 @@
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
-
 #include "arch-utils.h"
+#include "osabi.h"
 
 #include "ns32k-tdep.h"
 #include "gdb_string.h"
@@ -536,36 +536,19 @@ ns32k_gdbarch_init_32382 (struct gdbarch
 static struct gdbarch *
 ns32k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
-  struct gdbarch_tdep *tdep;
   struct gdbarch *gdbarch;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
-  /* Try to determine the OS ABI of the object we are loading.  */
-  if (info.abfd != NULL)
-    {
-      osabi = gdbarch_lookup_osabi (info.abfd);
-    }
+  /* If there is already a candidate, use it.  */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
-  /* Find a candidate among extant architectures.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the OS ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-	return arches->gdbarch;
-    }
-
-  tdep = xmalloc (sizeof (struct gdbarch_tdep));
-  gdbarch = gdbarch_alloc (&info, tdep);
+  gdbarch = gdbarch_alloc (&info, NULL);
 
   /* NOTE: cagney/2002-12-06: This can be deleted when this arch is
      ready to unwind the PC first (see frame.c:get_prev_frame()).  */
   set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
 
-  tdep->osabi = osabi;
-
   /* Register info */
   ns32k_gdbarch_init_32082 (gdbarch);
   set_gdbarch_num_regs (gdbarch, NS32K_SP_REGNUM);
@@ -631,27 +614,15 @@ ns32k_gdbarch_init (struct gdbarch_info 
   set_gdbarch_function_start_offset (gdbarch, 0);
 
   /* Hook in OS ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   return (gdbarch);
 }
 
-static void
-ns32k_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
-{
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
-  if (tdep == NULL)
-    return;
-
-  fprintf_unfiltered (file, "ns32k_dump_tdep: OS ABI = %s\n",
-		      gdbarch_osabi_name (tdep->osabi));
-}
-
 void
 _initialize_ns32k_tdep (void)
 {
-  gdbarch_register (bfd_arch_ns32k, ns32k_gdbarch_init, ns32k_dump_tdep);
+  gdbarch_register (bfd_arch_ns32k, ns32k_gdbarch_init, NULL);
 
   tm_print_insn = print_insn_ns32k;
 }
Index: ns32k-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ns32k-tdep.h,v
retrieving revision 1.1
diff -u -p -r1.1 ns32k-tdep.h
--- ns32k-tdep.h	27 May 2002 01:05:16 -0000	1.1
+++ ns32k-tdep.h	27 Dec 2002 23:22:50 -0000
@@ -22,8 +22,6 @@
 #ifndef NS32K_TDEP_H
 #define NS32K_TDEP_H
 
-#include "osabi.h"
-
 /* Register numbers of various important registers.
    Note that some of these values are "real" register numbers,
    and correspond to the general registers of the machine,
@@ -54,11 +52,6 @@
 #define NS32K_REGISTER_SIZE             4
 #define NS32K_MAX_REGISTER_RAW_SIZE     8
 #define NS32K_MAX_REGISTER_VIRTUAL_SIZE 8
-
-struct gdbarch_tdep
-{
-  enum gdb_osabi osabi;
-};
 
 void ns32k_gdbarch_init_32082 (struct gdbarch *);
 void ns32k_gdbarch_init_32382 (struct gdbarch *);
Index: ns32knbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ns32knbsd-tdep.c,v
retrieving revision 1.3
diff -u -p -r1.3 ns32knbsd-tdep.c
--- ns32knbsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.3
+++ ns32knbsd-tdep.c	27 Dec 2002 23:22:50 -0000
@@ -20,6 +20,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "osabi.h"
 
 #include "ns32k-tdep.h"
 #include "gdb_string.h"
Index: osabi.c
===================================================================
RCS file: /cvs/src/src/gdb/osabi.c,v
retrieving revision 1.10
diff -u -p -r1.10 osabi.c
--- osabi.c	21 Dec 2002 19:58:07 -0000	1.10
+++ osabi.c	27 Dec 2002 23:22:50 -0000
@@ -171,6 +171,9 @@ gdbarch_lookup_osabi (bfd *abfd)
   enum gdb_osabi osabi, match;
   int match_specific;
 
+  if (abfd == NULL)
+    return GDB_OSABI_UNINITIALIZED;
+
   match = GDB_OSABI_UNKNOWN;
   match_specific = 0;
 
@@ -234,14 +237,13 @@ gdbarch_lookup_osabi (bfd *abfd)
 }
 
 void
-gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch,
-                    enum gdb_osabi osabi)
+gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
   const struct bfd_arch_info *compatible;
   struct gdb_osabi_handler *handler;
 
-  if (osabi == GDB_OSABI_UNKNOWN)
+  if (info.osabi == GDB_OSABI_UNKNOWN)
     {
       /* Don't complain about an unknown OSABI.  Assume the user knows
          what they are doing.  */
@@ -251,7 +253,7 @@ gdbarch_init_osabi (struct gdbarch_info 
   for (handler = gdb_osabi_handler_list; handler != NULL;
        handler = handler->next)
     {
-      if (handler->osabi != osabi)
+      if (handler->osabi != info.osabi)
 	continue;
 
       /* Check whether the machine type and architecture of the
@@ -279,7 +281,7 @@ gdbarch_init_osabi (struct gdbarch_info 
        "A handler for the OS ABI \"%s\" is not built into this "
        "configuration of GDB.  "
        "Attempting to continue with the default %s settings",
-       gdbarch_osabi_name (osabi),
+       gdbarch_osabi_name (info.osabi),
        bfd_printable_arch_mach (arch_info->arch, arch_info->mach));
 }
 
Index: osabi.h
===================================================================
RCS file: /cvs/src/src/gdb/osabi.h,v
retrieving revision 1.7
diff -u -p -r1.7 osabi.h
--- osabi.h	21 Dec 2002 19:58:07 -0000	1.7
+++ osabi.h	27 Dec 2002 23:22:50 -0000
@@ -21,37 +21,6 @@
 #ifndef OSABI_H
 #define OSABI_H
 
-/* List of known OS ABIs.  If you change this, make sure to update the
-   table in osabi.c.  */
-enum gdb_osabi
-{
-  GDB_OSABI_UNKNOWN = 0,	/* keep this first */
-
-  GDB_OSABI_SVR4,
-  GDB_OSABI_HURD,
-  GDB_OSABI_SOLARIS,
-  GDB_OSABI_OSF1,
-  GDB_OSABI_LINUX,
-  GDB_OSABI_FREEBSD_AOUT,
-  GDB_OSABI_FREEBSD_ELF,
-  GDB_OSABI_NETBSD_AOUT,
-  GDB_OSABI_NETBSD_ELF,
-  GDB_OSABI_WINCE,
-  GDB_OSABI_GO32,
-  GDB_OSABI_NETWARE,
-  GDB_OSABI_IRIX,
-  GDB_OSABI_LYNXOS,
-  GDB_OSABI_INTERIX,
-  GDB_OSABI_HPUX_ELF,
-  GDB_OSABI_HPUX_SOM,
-
-  GDB_OSABI_ARM_EABI_V1,
-  GDB_OSABI_ARM_EABI_V2,
-  GDB_OSABI_ARM_APCS,
-
-  GDB_OSABI_INVALID		/* keep this last */
-};
-
 /* Register an OS ABI sniffer.  Each arch/flavour may have more than
    one sniffer.  This is used to e.g. differentiate one OS's a.out from
    another.  The first sniffer to return something other than
@@ -73,8 +42,7 @@ void gdbarch_register_osabi (enum bfd_ar
 enum gdb_osabi gdbarch_lookup_osabi (bfd *);
 
 /* Initialize the gdbarch for the specified OS ABI variant.  */
-void gdbarch_init_osabi (struct gdbarch_info, struct gdbarch *,
-                         enum gdb_osabi);
+void gdbarch_init_osabi (struct gdbarch_info, struct gdbarch *);
 
 /* Return the name of the specified OS ABI.  */
 const char *gdbarch_osabi_name (enum gdb_osabi);
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.21
diff -u -p -r1.21 ppc-linux-tdep.c
--- ppc-linux-tdep.c	21 Dec 2002 19:58:07 -0000	1.21
+++ ppc-linux-tdep.c	27 Dec 2002 23:22:50 -0000
@@ -31,6 +31,7 @@
 #include "objfiles.h"
 #include "regcache.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "solib-svr4.h"
 #include "ppc-tdep.h"
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.13
diff -u -p -r1.13 ppc-tdep.h
--- ppc-tdep.h	20 Aug 2002 22:24:29 -0000	1.13
+++ ppc-tdep.h	27 Dec 2002 23:22:50 -0000
@@ -22,8 +22,6 @@
 #ifndef PPC_TDEP_H
 #define PPC_TDEP_H
 
-#include "osabi.h"
-
 struct frame_info;
 struct value;
 
@@ -56,7 +54,6 @@ int altivec_register_p (int regno);
 struct gdbarch_tdep
   {
     int wordsize;              /* size in bytes of fixed-point word */
-    enum gdb_osabi osabi;      /* OS / ABI from ELF header */
     int *regoff;               /* byte offsets in register arrays */
     const struct reg *regs;    /* from current variant */
     int ppc_gp0_regnum;		/* GPR register 0 */
Index: ppcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 ppcnbsd-tdep.c
--- ppcnbsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.5
+++ ppcnbsd-tdep.c	27 Dec 2002 23:22:50 -0000
@@ -25,6 +25,7 @@
 #include "target.h"
 #include "breakpoint.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "ppc-tdep.h"
 #include "ppcnbsd-tdep.h"
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.100
diff -u -p -r1.100 rs6000-tdep.c
--- rs6000-tdep.c	18 Dec 2002 15:23:22 -0000	1.100
+++ rs6000-tdep.c	27 Dec 2002 23:22:51 -0000
@@ -34,6 +34,7 @@
 #include "doublest.h"
 #include "value.h"
 #include "parser-defs.h"
+#include "osabi.h"
 
 #include "libbfd.h"		/* for bfd_default_set_arch_mach */
 #include "coff/internal.h"	/* for libcoff.h */
@@ -2668,7 +2669,6 @@ rs6000_gdbarch_init (struct gdbarch_info
   unsigned long mach;
   bfd abfd;
   int sysv_abi;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
   asection *sect;
 
   from_xcoff_exec = info.abfd && info.abfd->format == bfd_object &&
@@ -2679,9 +2679,6 @@ rs6000_gdbarch_init (struct gdbarch_info
 
   sysv_abi = info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour;
 
-  if (info.abfd)
-    osabi = gdbarch_lookup_osabi (info.abfd);
-
   /* Check word size.  If INFO is from a binary file, infer it from
      that, else choose a likely default.  */
   if (from_xcoff_exec)
@@ -2716,7 +2713,7 @@ rs6000_gdbarch_init (struct gdbarch_info
          meaningful, because 64-bit CPUs can run in 32-bit mode.  So, perform
          separate word size check.  */
       tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->wordsize == wordsize && tdep->osabi == osabi)
+      if (tdep && tdep->wordsize == wordsize)
 	return arches->gdbarch;
     }
 
@@ -2742,7 +2739,6 @@ rs6000_gdbarch_init (struct gdbarch_info
     }
   tdep = xmalloc (sizeof (struct gdbarch_tdep));
   tdep->wordsize = wordsize;
-  tdep->osabi = osabi;
 
   /* For e500 executables, the apuinfo section is of help here.  Such
      section contains the identifier and revision number of each
@@ -2970,7 +2966,7 @@ rs6000_gdbarch_init (struct gdbarch_info
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   return gdbarch;
 }
@@ -2983,8 +2979,7 @@ rs6000_dump_tdep (struct gdbarch *curren
   if (tdep == NULL)
     return;
 
-  fprintf_unfiltered (file, "rs6000_dump_tdep: OS ABI = %s\n",
-		      gdbarch_osabi_name (tdep->osabi));
+  /* FIXME: Dump gdbarch_tdep.  */
 }
 
 static struct cmd_list_element *info_powerpc_cmdlist = NULL;
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.82
diff -u -p -r1.82 sh-tdep.c
--- sh-tdep.c	11 Dec 2002 02:26:36 -0000	1.82
+++ sh-tdep.c	27 Dec 2002 23:22:51 -0000
@@ -39,6 +39,7 @@
 #include "floatformat.h"
 #include "regcache.h"
 #include "doublest.h"
+#include "osabi.h"
 
 #include "sh-tdep.h"
 
@@ -4216,26 +4217,11 @@ sh_gdbarch_init (struct gdbarch_info inf
   gdbarch_register_name_ftype *sh_register_name;
   gdbarch_deprecated_store_return_value_ftype *sh_store_return_value;
   gdbarch_register_virtual_type_ftype *sh_register_virtual_type;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
-  /* Try to determine the ABI of the object we are loading.  */
-
-  if (info.abfd != NULL)
-    {
-      osabi = gdbarch_lookup_osabi (info.abfd);
-      /* If we get "unknown" back, just leave it that way.  */
-    }
-
-  /* Find a candidate among the list of pre-declared architectures. */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-	return arches->gdbarch;
-    }
+  /* If there is already a candidate, use it.  */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
   /* None found, create a new architecture from the information
      provided. */
@@ -4246,8 +4232,6 @@ sh_gdbarch_init (struct gdbarch_info inf
      ready to unwind the PC first (see frame.c:get_prev_frame()).  */
   set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
 
-  tdep->osabi = osabi;
-
   /* Initialize the register numbers that are not common to all the
      variants to -1, if necessary thse will be overwritten in the case
      statement below. */
@@ -4595,11 +4579,8 @@ sh_gdbarch_init (struct gdbarch_info inf
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
 
-  /* Hook in ABI-specific overrides, if they have been registered.
-
-     FIXME: if the ABI is unknown, this is probably an embedded target,
-     so we should not warn about this situation.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  /* Hook in ABI-specific overrides, if they have been registered.  */
+  gdbarch_init_osabi (info, gdbarch);
 
   return gdbarch;
 }
@@ -4612,8 +4593,7 @@ sh_dump_tdep (struct gdbarch *current_gd
   if (tdep == NULL)
     return;
 
-  fprintf_unfiltered (file, "sh_dump_tdep: OS ABI = %s\n",
-                      gdbarch_osabi_name (tdep->osabi));
+  /* FIXME: dump the rest of gdbarch_tdep.  */
 }
 
 void
Index: sh-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.h,v
retrieving revision 1.2
diff -u -p -r1.2 sh-tdep.h
--- sh-tdep.h	21 May 2002 15:36:02 -0000	1.2
+++ sh-tdep.h	27 Dec 2002 23:22:51 -0000
@@ -22,8 +22,6 @@
 #ifndef SH_TDEP_H
 #define SH_TDEP_H
 
-#include "osabi.h"
-
 /* Contributed by Steve Chamberlain sac@cygnus.com */
 
 /* Information that is dependent on the processor variant. */
@@ -89,7 +87,6 @@ struct gdbarch_tdep
     int ARGLAST_REGNUM;
     int FLOAT_ARGLAST_REGNUM;
     int RETURN_REGNUM;
-    enum gdb_osabi osabi;	/* OS/ABI of the inferior */
     enum sh_abi sh_abi;
   };
 
Index: shnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/shnbsd-tdep.c,v
retrieving revision 1.8
diff -u -p -r1.8 shnbsd-tdep.c
--- shnbsd-tdep.c	21 Dec 2002 19:58:07 -0000	1.8
+++ shnbsd-tdep.c	27 Dec 2002 23:22:52 -0000
@@ -23,6 +23,7 @@
 #include "gdbcore.h"
 #include "regcache.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "solib-svr4.h"
 
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.53
diff -u -p -r1.53 sparc-tdep.c
--- sparc-tdep.c	11 Dec 2002 20:35:43 -0000	1.53
+++ sparc-tdep.c	27 Dec 2002 23:22:52 -0000
@@ -111,8 +111,6 @@ struct gdbarch_tdep
     int reg_save_offset;
     int call_dummy_call_offset;
     int print_insn_mach;
-
-    enum gdb_osabi osabi;
   };
 
 /* Now make GDB_TARGET_IS_SPARC64 a runtime test.  */
@@ -3077,7 +3075,6 @@ sparc_gdbarch_init (struct gdbarch_info 
 {
   struct gdbarch *gdbarch;
   struct gdbarch_tdep *tdep;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
   static LONGEST call_dummy_32[] = 
     { 0xbc100001, 0x9de38000, 0xbc100002, 0xbe100003,
@@ -3103,27 +3100,18 @@ sparc_gdbarch_init (struct gdbarch_info 
 
   /* Try to determine the OS ABI of the object we are loading.  */
 
-  if (info.abfd != NULL)
+  if (info.abfd != NULL
+      && info.osabi == GDB_OSABI_UNKNOWN)
     {
-      osabi = gdbarch_lookup_osabi (info.abfd);
-      if (osabi == GDB_OSABI_UNKNOWN)
-	{
-	  /* If it's an ELF file, assume it's Solaris.  */
-	  if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
-	    osabi = GDB_OSABI_SOLARIS;
-	}
+      /* If it's an ELF file, assume it's Solaris.  */
+      if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
+	info.osabi = GDB_OSABI_SOLARIS;
     }
 
   /* First see if there is already a gdbarch that can satisfy the request.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-	return arches->gdbarch;
-    }
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
   /* None found: is the request for a sparc architecture? */
   if (info.bfd_arch_info->arch != bfd_arch_sparc)
@@ -3133,8 +3121,6 @@ sparc_gdbarch_init (struct gdbarch_info 
   tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
   gdbarch = gdbarch_alloc (&info, tdep);
 
-  tdep->osabi = osabi;
-
   /* First set settings that are common for all sparc architectures.  */
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
   set_gdbarch_breakpoint_from_pc (gdbarch, memory_breakpoint_from_pc);
@@ -3445,7 +3431,7 @@ sparc_gdbarch_init (struct gdbarch_info 
     }
 
   /* Hook in OS ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   return gdbarch;
 }
@@ -3458,6 +3444,20 @@ sparc_dump_tdep (struct gdbarch *current
   if (tdep == NULL)
     return;
 
-  fprintf_unfiltered (file, "sparc_dump_tdep: OS ABI = %s\n",
-		      gdbarch_osabi_name (tdep->osabi));
+  fprintf_unfiltered (file, "sparc_dump_tdep: has_fpu = %d\n",
+		      tdep->has_fpu);
+  fprintf_unfiltered (file, "sparc_dump_tdep: fp_register_bytes = %d\n",
+		      tdep->fp_register_bytes);
+  fprintf_unfiltered (file, "sparc_dump_tdep: y_regnum = %d\n",
+		      tdep->y_regnum);
+  fprintf_unfiltered (file, "sparc_dump_tdep: fp_max_regnum = %d\n",
+		      tdep->fp_max_regnum);
+  fprintf_unfiltered (file, "sparc_dump_tdep: intreg_size = %d\n",
+		      tdep->intreg_size);
+  fprintf_unfiltered (file, "sparc_dump_tdep: reg_save_offset = %d\n",
+		      tdep->reg_save_offset);
+  fprintf_unfiltered (file, "sparc_dump_tdep: call_dummy_call_offset = %d\n",
+		      tdep->call_dummy_call_offset);
+  fprintf_unfiltered (file, "sparc_dump_tdep: print_insn_match = %d\n",
+		      tdep->print_insn_match);
 }
Index: vax-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/vax-tdep.c,v
retrieving revision 1.26
diff -u -p -r1.26 vax-tdep.c
--- vax-tdep.c	11 Dec 2002 02:26:36 -0000	1.26
+++ vax-tdep.c	27 Dec 2002 23:22:52 -0000
@@ -29,6 +29,7 @@
 #include "value.h"
 #include "arch-utils.h"
 #include "gdb_string.h"
+#include "osabi.h"
 
 #include "vax-tdep.h"
 
@@ -609,35 +610,19 @@ print_insn_arg (char *d, register char *
 static struct gdbarch *
 vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
-  struct gdbarch_tdep *tdep;
   struct gdbarch *gdbarch;
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
-  /* Try to determine the ABI of the object we are loading.  */
+  /* If there is already a candidate, use it.  */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
 
-  if (info.abfd != NULL)
-    osabi = gdbarch_lookup_osabi (info.abfd);
-
-  /* Find a candidate among extant architectures.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      /* Make sure the ABI selection matches.  */
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (tdep && tdep->osabi == osabi)
-	return arches->gdbarch;
-    }
-
-  tdep = xmalloc (sizeof (struct gdbarch_tdep));
-  gdbarch = gdbarch_alloc (&info, tdep);
+  gdbarch = gdbarch_alloc (&info, NULL);
 
   /* NOTE: cagney/2002-12-06: This can be deleted when this arch is
      ready to unwind the PC first (see frame.c:get_prev_frame()).  */
   set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
 
-  tdep->osabi = osabi;
-
   /* Register info */
   set_gdbarch_num_regs (gdbarch, VAX_NUM_REGS);
   set_gdbarch_sp_regnum (gdbarch, VAX_SP_REGNUM);
@@ -707,27 +692,15 @@ vax_gdbarch_init (struct gdbarch_info in
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
-  gdbarch_init_osabi (info, gdbarch, osabi);
+  gdbarch_init_osabi (info, gdbarch);
 
   return (gdbarch);
 }
 
-static void
-vax_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
-{
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
-  if (tdep == NULL)
-    return;
-
-  fprintf_unfiltered (file, "vax_dump_tdep: OS ABI = %s\n",
-		      gdbarch_osabi_name (tdep->osabi));
-}
-
 void
 _initialize_vax_tdep (void)
 {
-  gdbarch_register (bfd_arch_vax, vax_gdbarch_init, vax_dump_tdep);
+  gdbarch_register (bfd_arch_vax, vax_gdbarch_init, NULL);
 
   tm_print_insn = vax_print_insn;
 }
Index: vax-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/vax-tdep.h,v
retrieving revision 1.2
diff -u -p -r1.2 vax-tdep.h
--- vax-tdep.h	26 Jun 2002 16:07:16 -0000	1.2
+++ vax-tdep.h	27 Dec 2002 23:22:52 -0000
@@ -21,8 +21,6 @@
 #ifndef VAX_TDEP_H
 #define VAX_TDEP_H
 
-#include "osabi.h"
-
 /* Say how long (ordinary) registers are.  This is a piece of bogosity
    used in push_word and a few other places;  REGISTER_RAW_SIZE is the
    real way to know how big a register is.  */
@@ -53,11 +51,5 @@
 #define VAX_SP_REGNUM     14  /* Contains address of top of stack */
 #define VAX_PC_REGNUM     15  /* Contains program counter */
 #define VAX_PS_REGNUM     16  /* Contains processor status */
-
-/* Target-dependent structure in gdbarch.  */ 
-struct gdbarch_tdep
-{  
-  enum gdb_osabi osabi;		/* OS/ABI of inferior.  */
-};
 
 #endif /* VAX_TDEP_H */
--- /dev/null	1969-12-31 19:00:00.000000000 -0500
+++ osabi_list.h	2002-12-27 16:20:39.000000000 -0500
@@ -0,0 +1,57 @@
+/* OS ABI variants supported by GDB.
+   Copyright 2001, 2002 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 2 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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef OSABI_LIST_H
+#define OSABI_LIST_H
+
+/* List of known OS ABIs.  If you change this, make sure to update the
+   table in osabi.c.  */
+enum gdb_osabi
+{
+  GDB_OSABI_UNINITIALIZED = -1, /* For struct gdbarch_info.  */
+
+  GDB_OSABI_UNKNOWN = 0,	/* keep this zero */
+
+  GDB_OSABI_SVR4,
+  GDB_OSABI_HURD,
+  GDB_OSABI_SOLARIS,
+  GDB_OSABI_OSF1,
+  GDB_OSABI_LINUX,
+  GDB_OSABI_FREEBSD_AOUT,
+  GDB_OSABI_FREEBSD_ELF,
+  GDB_OSABI_NETBSD_AOUT,
+  GDB_OSABI_NETBSD_ELF,
+  GDB_OSABI_WINCE,
+  GDB_OSABI_GO32,
+  GDB_OSABI_NETWARE,
+  GDB_OSABI_IRIX,
+  GDB_OSABI_LYNXOS,
+  GDB_OSABI_INTERIX,
+  GDB_OSABI_HPUX_ELF,
+  GDB_OSABI_HPUX_SOM,
+
+  GDB_OSABI_ARM_EABI_V1,
+  GDB_OSABI_ARM_EABI_V2,
+  GDB_OSABI_ARM_APCS,
+
+  GDB_OSABI_INVALID		/* keep this last */
+};
+
+#endif /* OSABI_LIST_H */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]