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]

[committed] MIPS: Unify cooked accesses to the PC


Hi,

 I have applied the change below that makes mips_read_pc and mips_write_pc 
use cooked accesses to the PC and adjusted mips_unwind_pc for consistency.  

 Since gdbarch_pc_regnum has been used in several places already and there 
are even more with this change in place I have removed a misleading 
comment about this function too -- clearly both gdbarch_pc_regnum and 
gdbarch_read_pc have their purposes.

 Regression-tested with mips-sde-elf and mips-linux-gnu, o32/MIPS, 
o32/MIPS16, o32/microMIPS and n64 multilibs.

2012-05-18  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/
	* mips-tdep.c (mips_read_pc): Use gdbarch_pc_regnum instead of
	mips_regnum->pc.
	(mips_unwind_pc, mips_write_pc): Likewise.
	(mips_gdbarch_init): Remove a comment on gdbarch_pc_regnum and 
	gdbarch_read_pc.

  Maciej

gdb-mips-gdbarch-pc.diff
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c	2012-05-18 12:10:15.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c	2012-05-18 12:15:49.115560140 +0100
@@ -1080,8 +1080,9 @@ mips_in_frame_stub (CORE_ADDR pc)
 static CORE_ADDR
 mips_read_pc (struct regcache *regcache)
 {
+  int regnum = gdbarch_pc_regnum (get_regcache_arch (regcache));
   ULONGEST pc;
-  int regnum = mips_regnum (get_regcache_arch (regcache))->pc;
+
   regcache_cooked_read_signed (regcache, regnum, &pc);
   if (is_mips16_addr (pc))
     pc = unmake_mips16_addr (pc);
@@ -1093,8 +1094,7 @@ mips_unwind_pc (struct gdbarch *gdbarch,
 {
   CORE_ADDR pc;
 
-  pc = frame_unwind_register_signed
-	 (next_frame, gdbarch_num_regs (gdbarch) + mips_regnum (gdbarch)->pc);
+  pc = frame_unwind_register_signed (next_frame, gdbarch_pc_regnum (gdbarch));
   if (is_mips16_addr (pc))
     pc = unmake_mips16_addr (pc);
   /* macro/2012-04-20: This hack skips over MIPS16 call thunks as
@@ -1144,7 +1144,8 @@ mips_dummy_id (struct gdbarch *gdbarch, 
 static void
 mips_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
-  int regnum = mips_regnum (get_regcache_arch (regcache))->pc;
+  int regnum = gdbarch_pc_regnum (get_regcache_arch (regcache));
+
   if (mips_pc_is_mips16 (pc))
     regcache_cooked_write_unsigned (regcache, regnum, make_mips16_addr (pc));
   else
@@ -7106,8 +7107,6 @@ mips_gdbarch_init (struct gdbarch_info i
 
   /* The hook may have adjusted num_regs, fetch the final value and
      set pc_regnum and sp_regnum now that it has been fixed.  */
-  /* FIXME: cagney/2003-11-15: For MIPS, hasn't gdbarch_pc_regnum been
-     replaced by gdbarch_read_pc?  */
   num_regs = gdbarch_num_regs (gdbarch);
   set_gdbarch_pc_regnum (gdbarch, regnum->pc + num_regs);
   set_gdbarch_sp_regnum (gdbarch, MIPS_SP_REGNUM + num_regs);


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