This is the mail archive of the gdb-patches@sourceware.org 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]

[PATCH 2/8] gdb/s390: Fill supply_pseudo_pc hook.


gdb/ChangeLog:

	* s390-linux-tdep.c (s390_supply_pseudo_pc): New function.
	(s390_gdbarch_init): Fill supply_pseudo_pc hook.
---
Likewise, changed name and added comment.

 gdb/ChangeLog         |  5 +++++
 gdb/s390-linux-tdep.c | 23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e0bfd21..d24cccd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2016-02-07  Marcin KoÅcielnicki  <koriakin@0x04.net>
 
+	* s390-linux-tdep.c (s390_supply_pseudo_pc): New function.
+	(s390_gdbarch_init): Fill supply_pseudo_pc hook.
+
+2016-02-07  Marcin KoÅcielnicki  <koriakin@0x04.net>
+
 	* gdbarch.c: Regenerate.
 	* gdbarch.h: Regenerate.
 	* gdbarch.sh: Add supply_pseudo_pc hook.
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index e827684..144365c 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -167,6 +167,28 @@ s390_write_pc (struct regcache *regcache, CORE_ADDR pc)
     regcache_cooked_write_unsigned (regcache, S390_SYSTEM_CALL_REGNUM, 0);
 }
 
+/* The "supply_pseudo_pc" gdbarch method.  For s390, we have to supply
+   the PSWA register.  For 64-bit inferior, PC maps straight to PSWA.
+   For 31-bit, we additionally set the high bit to 1, since we have
+   to supply the whole register, and it's very unlikely the program
+   is in 24-bit addressing mode.  */
+
+static void
+s390_supply_pseudo_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int sz = register_size (gdbarch, S390_PSWA_REGNUM);
+  gdb_byte *reg = (gdb_byte *) alloca (sz);
+
+  /* 31-bit PSWA needs high bit set.  */
+  if (tdep->abi == ABI_LINUX_S390)
+    pc |= 0x80000000;
+
+  store_unsigned_integer (reg, sz, gdbarch_byte_order (gdbarch), pc);
+  regcache_raw_supply (regcache, S390_PSWA_REGNUM, reg);
+}
+
 
 /* DWARF Register Mapping.  */
 
@@ -7857,6 +7879,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 					    s390_iterate_over_regset_sections);
   set_gdbarch_cannot_store_register (gdbarch, s390_cannot_store_register);
   set_gdbarch_write_pc (gdbarch, s390_write_pc);
+  set_gdbarch_supply_pseudo_pc (gdbarch, s390_supply_pseudo_pc);
   set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read);
   set_gdbarch_pseudo_register_write (gdbarch, s390_pseudo_register_write);
   set_tdesc_pseudo_register_name (gdbarch, s390_pseudo_register_name);
-- 
2.7.0


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