This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
PATCH: S390 modernization patch 5/6
- From: Jim Blandy <jimb at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: 17 Feb 2004 23:23:31 -0500
- Subject: PATCH: S390 modernization patch 5/6
I've committed the following patch from Ulrich Weigand. It was posted
here previously; it was reviewed and approved; and the FSF has the
software letter on file.
ChangeLog:
* s390-nat.c (SUBOFF): New macro.
(supply_gregset, fill_gregset): Use it to handle debugging
of 32-bit exectuables running under a 64-bit kernel.
* s390-tdep.c: Include "solib-svr4.h".
(s390_svr4_fetch_link_map_offset): New function.
(s390x_svr_fetch_link_map_offset): Likewise.
(s390_gdbarch_init): Call set_solib_svr4_fetch_link_map_offsets.
* Makefile.in (s390-tdep.o): Update dependencies.
testsuite/ChangeLog:
* gdb.base/dump.exp: Handle negative offsets in decimal, not hex.
diff -c -p -r gdb-head/gdb/Makefile.in gdb-head-new/gdb/Makefile.in
*** gdb-head/gdb/Makefile.in Sun Jan 18 19:41:31 2004
--- gdb-head-new/gdb/Makefile.in Sun Jan 18 19:41:40 2004
*************** s390-tdep.o: s390-tdep.c $(defs_h) $(arc
*** 2254,2260 ****
$(objfiles_h) $(tm_h) $(__bfd_bfd_h) $(floatformat_h) $(regcache_h) \
$(trad_frame_h) $(frame_base_h) $(frame_unwind_h) $(dwarf2_frame_h) \
$(reggroups_h) $(regset_h) $(value_h) $(gdb_assert_h) $(dis_asm_h) \
! $(s390_tdep_h)
scm-exp.o: scm-exp.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
$(parser_defs_h) $(language_h) $(value_h) $(c_lang_h) $(scm_lang_h) \
$(scm_tags_h)
--- 2254,2260 ----
$(objfiles_h) $(tm_h) $(__bfd_bfd_h) $(floatformat_h) $(regcache_h) \
$(trad_frame_h) $(frame_base_h) $(frame_unwind_h) $(dwarf2_frame_h) \
$(reggroups_h) $(regset_h) $(value_h) $(gdb_assert_h) $(dis_asm_h) \
! $(solib_svr4_h) $(s390_tdep_h)
scm-exp.o: scm-exp.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
$(parser_defs_h) $(language_h) $(value_h) $(c_lang_h) $(scm_lang_h) \
$(scm_tags_h)
diff -c -p -r gdb-head/gdb/s390-nat.c gdb-head-new/gdb/s390-nat.c
*** gdb-head/gdb/s390-nat.c Sun Jan 18 17:52:10 2004
--- gdb-head-new/gdb/s390-nat.c Sun Jan 18 19:41:40 2004
***************
*** 47,52 ****
--- 47,64 ----
#define regmap_fpregset s390_regmap_fpregset
+ /* When debugging a 32-bit executable running under a 64-bit kernel,
+ we have to fix up the 64-bit registers we get from the kernel
+ to make them look like 32-bit registers. */
+ #ifdef __s390x__
+ #define SUBOFF(i) \
+ ((TARGET_PTR_BIT == 32 \
+ && ((i) == S390_PSWA_REGNUM \
+ || ((i) >= S390_R0_REGNUM && (i) <= S390_R15_REGNUM)))? 4 : 0)
+ #else
+ #define SUBOFF(i) 0
+ #endif
+
/* Fill GDB's register array with the general-purpose register values
in *REGP. */
*************** supply_gregset (gregset_t *regp)
*** 57,63 ****
for (i = 0; i < S390_NUM_REGS; i++)
if (regmap_gregset[i] != -1)
regcache_raw_supply (current_regcache, i,
! (char *)regp + regmap_gregset[i]);
}
/* Fill register REGNO (if it is a general-purpose register) in
--- 69,75 ----
for (i = 0; i < S390_NUM_REGS; i++)
if (regmap_gregset[i] != -1)
regcache_raw_supply (current_regcache, i,
! (char *)regp + regmap_gregset[i] + SUBOFF (i));
}
/* Fill register REGNO (if it is a general-purpose register) in
*************** fill_gregset (gregset_t *regp, int regno
*** 71,77 ****
if (regmap_gregset[i] != -1)
if (regno == -1 || regno == i)
regcache_raw_collect (current_regcache, i,
! (char *)regp + regmap_gregset[i]);
}
/* Fill GDB's register array with the floating-point register values
--- 83,89 ----
if (regmap_gregset[i] != -1)
if (regno == -1 || regno == i)
regcache_raw_collect (current_regcache, i,
! (char *)regp + regmap_gregset[i] + SUBOFF (i));
}
/* Fill GDB's register array with the floating-point register values
diff -c -p -r gdb-head/gdb/s390-tdep.c gdb-head-new/gdb/s390-tdep.c
*** gdb-head/gdb/s390-tdep.c Sun Jan 18 19:41:31 2004
--- gdb-head-new/gdb/s390-tdep.c Sun Jan 18 19:41:40 2004
***************
*** 45,50 ****
--- 45,51 ----
#include "value.h"
#include "gdb_assert.h"
#include "dis-asm.h"
+ #include "solib-svr4.h" /* For struct link_map_offsets. */
#include "s390-tdep.h"
*************** s390_address_class_name_to_type_flags (s
*** 2878,2883 ****
--- 2879,2953 ----
}
+ /* Link map offsets. */
+
+ static struct link_map_offsets *
+ s390_svr4_fetch_link_map_offsets (void)
+ {
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = NULL;
+
+ if (lmp == NULL)
+ {
+ lmp = &lmo;
+
+ lmo.r_debug_size = 8;
+
+ lmo.r_map_offset = 4;
+ lmo.r_map_size = 4;
+
+ lmo.link_map_size = 20;
+
+ lmo.l_addr_offset = 0;
+ lmo.l_addr_size = 4;
+
+ lmo.l_name_offset = 4;
+ lmo.l_name_size = 4;
+
+ lmo.l_next_offset = 12;
+ lmo.l_next_size = 4;
+
+ lmo.l_prev_offset = 16;
+ lmo.l_prev_size = 4;
+ }
+
+ return lmp;
+ }
+
+ static struct link_map_offsets *
+ s390x_svr4_fetch_link_map_offsets (void)
+ {
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = NULL;
+
+ if (lmp == NULL)
+ {
+ lmp = &lmo;
+
+ lmo.r_debug_size = 16; /* All we need. */
+
+ lmo.r_map_offset = 8;
+ lmo.r_map_size = 8;
+
+ lmo.link_map_size = 40; /* All we need. */
+
+ lmo.l_addr_offset = 0;
+ lmo.l_addr_size = 8;
+
+ lmo.l_name_offset = 8;
+ lmo.l_name_size = 8;
+
+ lmo.l_next_offset = 24;
+ lmo.l_next_size = 8;
+
+ lmo.l_prev_offset = 32;
+ lmo.l_prev_size = 8;
+ }
+
+ return lmp;
+ }
+
+
/* Set up gdbarch struct. */
static struct gdbarch *
*************** s390_gdbarch_init (struct gdbarch_info i
*** 2961,2966 ****
--- 3031,3039 ----
set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read);
set_gdbarch_pseudo_register_write (gdbarch, s390_pseudo_register_write);
+ set_solib_svr4_fetch_link_map_offsets (gdbarch,
+ s390_svr4_fetch_link_map_offsets);
+
break;
case bfd_mach_s390_64:
tdep->abi = ABI_LINUX_ZSERIES;
*************** s390_gdbarch_init (struct gdbarch_info i
*** 2975,2980 ****
--- 3048,3055 ----
set_gdbarch_ptr_bit (gdbarch, 64);
set_gdbarch_pseudo_register_read (gdbarch, s390x_pseudo_register_read);
set_gdbarch_pseudo_register_write (gdbarch, s390x_pseudo_register_write);
+ set_solib_svr4_fetch_link_map_offsets (gdbarch,
+ s390x_svr4_fetch_link_map_offsets);
set_gdbarch_address_class_type_flags (gdbarch,
s390_address_class_type_flags);
set_gdbarch_address_class_type_flags_to_name (gdbarch,
diff -c -p -r gdb-head/gdb/testsuite/gdb.base/dump.exp gdb-head-new/gdb/testsuite/gdb.base/dump.exp
*** gdb-head/gdb/testsuite/gdb.base/dump.exp Thu Aug 28 20:01:50 2003
--- gdb-head-new/gdb/testsuite/gdb.base/dump.exp Sun Jan 18 19:41:40 2004
*************** test_restore_saved_value "intstr2.bin bi
*** 353,361 ****
set array2_start [capture_value "/x &intarray2\[0\]"]
set struct2_start [capture_value "/x &intstruct2"]
set array2_offset \
! [capture_value "/x (char *) &intarray2 - (char *) &intarray"]
set struct2_offset \
! [capture_value "/x (char *) &intstruct2 - (char *) &intstruct"]
gdb_test "print zero_all ()" ""
--- 353,361 ----
set array2_start [capture_value "/x &intarray2\[0\]"]
set struct2_start [capture_value "/x &intstruct2"]
set array2_offset \
! [capture_value "(char *) &intarray2 - (char *) &intarray"]
set struct2_offset \
! [capture_value "(char *) &intstruct2 - (char *) &intstruct"]
gdb_test "print zero_all ()" ""