From 9cbd5950d6314c1447900d98b6f1d157c1e33942 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 18 Feb 2004 04:17:35 +0000 Subject: [PATCH] 2004-02-17 Ulrich Weigand Committed by Jim Blandy . * 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. --- gdb/ChangeLog | 9 ++++++ gdb/Makefile.in | 2 +- gdb/s390-nat.c | 16 +++++++++-- gdb/s390-tdep.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d4e53c1b53c..aef385d7adf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -2,6 +2,15 @@ Committed by Jim Blandy . + * 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. + * s390-tdep.c: Include "trad-frame.h", "frame-base.h", and "frame-unwind.h". (s390_readinstruction): Reformat. Use read_memory_nobpt. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index b26c3f3fb9b..3f0d3b8363c 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -2183,7 +2183,7 @@ s390-tdep.o: s390-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) $(inferior_h) \ $(objfiles_h) $(tm_h) $(__bfd_bfd_h) $(floatformat_h) $(regcache_h) \ $(trad_frame_h) $(frame_base_h) $(frame_unwind_h) \ $(reggroups_h) $(regset_h) $(value_h) $(gdb_assert_h) $(dis_asm_h) \ - $(s390_tdep_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 --git a/gdb/s390-nat.c b/gdb/s390-nat.c index a2a7759b822..b8da548f05a 100644 --- a/gdb/s390-nat.c +++ b/gdb/s390-nat.c @@ -47,6 +47,18 @@ #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. */ @@ -57,7 +69,7 @@ supply_gregset (gregset_t *regp) for (i = 0; i < S390_NUM_REGS; i++) if (regmap_gregset[i] != -1) regcache_raw_supply (current_regcache, i, - (char *)regp + regmap_gregset[i]); + (char *)regp + regmap_gregset[i] + SUBOFF (i)); } /* Fill register REGNO (if it is a general-purpose register) in @@ -71,7 +83,7 @@ fill_gregset (gregset_t *regp, int regno) if (regmap_gregset[i] != -1) if (regno == -1 || regno == i) regcache_raw_collect (current_regcache, i, - (char *)regp + regmap_gregset[i]); + (char *)regp + regmap_gregset[i] + SUBOFF (i)); } /* Fill GDB's register array with the floating-point register values diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 227213f2a51..2499c3c4455 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -43,6 +43,7 @@ #include "value.h" #include "gdb_assert.h" #include "dis-asm.h" +#include "solib-svr4.h" /* For struct link_map_offsets. */ #include "s390-tdep.h" @@ -2848,6 +2849,75 @@ s390_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char *name } +/* 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 * @@ -2927,6 +2997,9 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 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; @@ -2941,6 +3014,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 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, -- 2.30.2