[PATCH] Integrate x86-64 and i386 targets
Mark Kettenis
kettenis@chello.nl
Sat Dec 21 14:59:00 GMT 2002
This patch integrates the x86-64 and i386 targets. With this patch,
GDB configured for the x86_64-*-linux-gnu will be able to debug i386
stuff too. Right now only the generic i386 targets in i386-tdep.c are
supported. I should probably add i386-linux.o to TDEPFILES such that
one can also debug i?86-*-linux-gnu targets. I'll add that later.
I checked that I could build an i386-freebsd4.6 x x86_64-linux-gnu
cross debugger, and checked that it correctly selects the right target
for a x86-64 binary. Therefore I checked it in. Michal, could you check whether GDB still functions correctly on x86-64?
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* x86-64-tdep.h (x86_64_init_abi): New prototype.
* x86-64-tdep.c (i386_fp_regnum_p): Remove function.
(x86_64_init_abi): Make non-static. Set number of pseudo
registers to 0.
(x86_64_gdbarch_init): Remove function.
(_initialize_x86_64_tdep): Renove register_gdbarch_init call.
Remove code dealing with dissambly.
* x86-64-linux-tdep.c (x86_64_linux_init_abi): New function.
(_initialize_x86_64_linux_tdep): New function.
* config/i386/x86-64linux.mt (TDEPFILES): Add i386-tdep.o and
i386-tdep.o.
Index: x86-64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-tdep.c,v
retrieving revision 1.10
diff -u -p -r1.10 x86-64-linux-tdep.c
--- x86-64-linux-tdep.c 9 Dec 2002 02:04:16 -0000 1.10
+++ x86-64-linux-tdep.c 21 Dec 2002 20:59:35 -0000
@@ -189,3 +189,20 @@ x86_64_init_frame_pc (int fromleaf, stru
else
return cfi_init_frame_pc (fromleaf, fi);
}
+
+
+static void
+x86_64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+ x86_64_init_abi (info, gdbarch);
+}
+
+/* Provide a prototype to silence -Wmissing-prototypes. */
+extern void _initialize_x86_64_linux_tdep (void);
+
+void
+_initialize_x86_64_linux_tdep (void)
+{
+ gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_LINUX,
+ x86_64_linux_init_abi);
+}
Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.43
diff -u -p -r1.43 x86-64-tdep.c
--- x86-64-tdep.c 11 Dec 2002 02:26:36 -0000 1.43
+++ x86-64-tdep.c 21 Dec 2002 20:59:35 -0000
@@ -175,15 +175,6 @@ x86_64_register_virtual_type (int regno)
return *x86_64_register_info_table[regno].type;
}
-/* FIXME: cagney/2002-11-11: Once the i386 and x86-64 targets are
- merged, this function can go away. */
-int
-i386_fp_regnum_p (int regnum)
-{
- return (regnum < NUM_REGS
- && (FP0_REGNUM && FP0_REGNUM <= (regnum) && (regnum) < FPC_REGNUM));
-}
-
/* x86_64_register_convertible is true if register N's virtual format is
different from its raw format. Note that this definition assumes
that the host supports IEEE 32-bit floats, since it doesn't say
@@ -921,7 +912,7 @@ x86_64_breakpoint_from_pc (CORE_ADDR *pc
return breakpoint;
}
-static void
+void
x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -1025,6 +1016,8 @@ x86_64_init_abi (struct gdbarch_info inf
/* FIXME: kettenis/20021026: This one is GNU/Linux-specific too. */
set_gdbarch_pc_in_sigtramp (gdbarch, x86_64_linux_in_sigtramp);
+ set_gdbarch_num_pseudo_regs (gdbarch, 0);
+
/* Build call frame information (CFI) from DWARF2 frame debug info. */
set_gdbarch_dwarf2_build_frame_info (gdbarch, dwarf2_build_frame_info);
@@ -1043,81 +1036,9 @@ x86_64_init_abi (struct gdbarch_info inf
set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
}
-static struct gdbarch *
-x86_64_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'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;
- }
-
- /* Allocate space for the new architecture. */
- tdep = XMALLOC (struct gdbarch_tdep);
- gdbarch = gdbarch_alloc (&info, tdep);
-
- tdep->osabi = osabi;
-
- /* FIXME: kettenis/20021025: The following calls are going to
- disappear when we integrate the x86_64 target into the i386
- target. */
-
- set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
-
- set_gdbarch_max_register_raw_size (gdbarch, 16);
- set_gdbarch_max_register_virtual_size (gdbarch, 16);
-
- set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
-
- set_gdbarch_breakpoint_from_pc (gdbarch, x86_64_breakpoint_from_pc);
- set_gdbarch_decr_pc_after_break (gdbarch, 1);
- set_gdbarch_function_start_offset (gdbarch, 0);
-
- set_gdbarch_frame_args_skip (gdbarch, 8);
-
- set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
- set_gdbarch_call_dummy_start_offset (gdbarch, 0);
- set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
- set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
- set_gdbarch_call_dummy_length (gdbarch, 0);
- set_gdbarch_call_dummy_p (gdbarch, 1);
- set_gdbarch_call_dummy_words (gdbarch, NULL);
- set_gdbarch_sizeof_call_dummy_words (gdbarch, 0);
- set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
- set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
-
- set_gdbarch_deprecated_pc_in_call_dummy (gdbarch, deprecated_pc_in_call_dummy_at_entry_point);
-
- set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
-
- /* FIXME: kettenis/20021025: These already are the default. */
-
- set_gdbarch_register_virtual_size (gdbarch, generic_register_size);
- set_gdbarch_deprecated_extract_struct_value_address (gdbarch, 0);
-
- x86_64_init_abi (info, gdbarch);
-
- return gdbarch;
-}
-
void
_initialize_x86_64_tdep (void)
{
- register_gdbarch_init (bfd_arch_i386, x86_64_gdbarch_init);
-
/* Initialize the table saying where each register starts in the
register file. */
{
@@ -1129,19 +1050,5 @@ _initialize_x86_64_tdep (void)
x86_64_register_byte_table[i] = offset;
offset += x86_64_register_info_table[i].size;
}
- }
-
- tm_print_insn = gdb_print_insn_x86_64;
- tm_print_insn_info.mach = bfd_mach_x86_64;
-
- /* Add the variable that controls the disassembly flavour. */
- {
- struct cmd_list_element *new_cmd;
-
- new_cmd = add_set_enum_cmd ("disassembly-flavour", no_class,
- valid_flavours, &disassembly_flavour, "\
-Set the disassembly flavour, the valid values are \"att\" and \"intel\", \
-and the default value is \"att\".", &setlist);
- add_show_from_set (new_cmd, &showlist);
}
}
Index: x86-64-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.h,v
retrieving revision 1.9
diff -u -p -r1.9 x86-64-tdep.h
--- x86-64-tdep.h 9 Dec 2002 02:04:16 -0000 1.9
+++ x86-64-tdep.h 21 Dec 2002 20:59:35 -0000
@@ -37,5 +37,6 @@ gdbarch_pc_in_sigtramp_ftype x86_64_linu
CORE_ADDR x86_64_linux_frame_chain (struct frame_info *fi);
CORE_ADDR x86_64_init_frame_pc (int fromleaf, struct frame_info *fi);
+void x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
#endif
Index: config/i386/x86-64linux.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/x86-64linux.mt,v
retrieving revision 1.5
diff -u -p -r1.5 x86-64linux.mt
--- config/i386/x86-64linux.mt 1 Jul 2002 22:09:52 -0000 1.5
+++ config/i386/x86-64linux.mt 21 Dec 2002 20:59:35 -0000
@@ -1,5 +1,6 @@
# Target: AMD x86-64 running GNU/Linux
TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o dwarf2cfi.o \
+ i386-tdep.o i387-tdep.o \
solib.o solib-svr4.o solib-legacy.o
GDB_MULTI_ARCH=GDB_MULTI_ARCH_TM
More information about the Gdb-patches
mailing list