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]

[rfc] [1/8] Eliminate current_gdbarch from *-tdep.c: addr_bits_remove callbacks


Hello,

this patch changes the addr_bits_remove and smash_text_address gdbarch
routines to type 'm' so that they receive a gdbarch argument.  This allows
to get rid of a current_gdbarch reference in mips_addr_bits_remove.

(As addr_bits_remove and smash_text_address share some handlers, including
the default one, smash_text_address needs to be changed as well.)

The rest of the patch are straightforward adaptations of the other
implementations and some call sites.

Bye,
Ulrich


ChangeLog:

	* gdbarch.sh (addr_bits_remove): Change type to 'm'.
	(smash_text_address): Likewise.
	* gdbarch.c, gdbarch.h: Regenerate.

	* arch-utils.c (core_addr_identity): Add gdbarch parameter.
	* arch-utils.h (core_addr_identity): Likewise.
	* arm-tdep.c (arm_addr_bits_remove): Likewise.
	(arm_smash_text_address): Likewise.
	* hppa-tdep.c (hppa_smash_text_address): Likewise.
	* m88k-tdep.c (m88k_addr_bits_remove): Likewise.
	* s390-tdep.c (s390_addr_bits_remove): Likewise.

	* mips-tdep.c (mips_addr_bits_remove): Add gdbarch parameter.
	Use it instead of current_gdbarch.

	* arm-tdep.c (arm_prologue_prev_register, arm_unwind_pc,
	arm_dwarf2_prev_register): Update calls.
	* m88k-tdep.c (m88k_unwind_pc): Update call.


diff -urNp gdb-orig/gdb/arch-utils.c gdb-head/gdb/arch-utils.c
--- gdb-orig/gdb/arch-utils.c	2008-08-22 03:25:26.000000000 +0200
+++ gdb-head/gdb/arch-utils.c	2008-08-26 00:31:07.000000000 +0200
@@ -146,7 +146,7 @@ core_addr_greaterthan (CORE_ADDR lhs, CO
 /* Misc helper functions for targets. */
 
 CORE_ADDR
-core_addr_identity (CORE_ADDR addr)
+core_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   return addr;
 }
diff -urNp gdb-orig/gdb/arch-utils.h gdb-head/gdb/arch-utils.h
--- gdb-orig/gdb/arch-utils.h	2008-05-25 18:19:37.000000000 +0200
+++ gdb-head/gdb/arch-utils.h	2008-08-26 00:30:51.000000000 +0200
@@ -60,7 +60,7 @@ extern int core_addr_greaterthan (CORE_A
 
 /* Identity functions on a CORE_ADDR.  Just return the "addr".  */
 
-extern CORE_ADDR core_addr_identity (CORE_ADDR addr);
+extern CORE_ADDR core_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern gdbarch_convert_from_func_ptr_addr_ftype convert_from_func_ptr_addr_identity;
 
 /* No-op conversion of reg to regnum. */
diff -urNp gdb-orig/gdb/arm-tdep.c gdb-head/gdb/arm-tdep.c
--- gdb-orig/gdb/arm-tdep.c	2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/arm-tdep.c	2008-08-26 00:28:49.000000000 +0200
@@ -363,7 +363,7 @@ arm_pc_is_thumb (CORE_ADDR memaddr)
 
 /* Remove useless bits from addresses in a running program.  */
 static CORE_ADDR
-arm_addr_bits_remove (CORE_ADDR val)
+arm_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR val)
 {
   if (arm_apcs_32)
     return UNMAKE_THUMB_ADDR (val);
@@ -374,7 +374,7 @@ arm_addr_bits_remove (CORE_ADDR val)
 /* When reading symbols, we need to zap the low bit of the address,
    which may be set to 1 for Thumb functions.  */
 static CORE_ADDR
-arm_smash_text_address (CORE_ADDR val)
+arm_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR val)
 {
   return val & ~1;
 }
@@ -1096,6 +1096,7 @@ arm_prologue_prev_register (struct frame
 			    void **this_cache,
 			    int prev_regnum)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct arm_prologue_cache *cache;
 
   if (*this_cache == NULL)
@@ -1113,7 +1114,7 @@ arm_prologue_prev_register (struct frame
 
       lr = frame_unwind_register_unsigned (this_frame, ARM_LR_REGNUM);
       return frame_unwind_got_constant (this_frame, prev_regnum,
-					arm_addr_bits_remove (lr));
+					arm_addr_bits_remove (gdbarch, lr));
     }
 
   /* SP is generally not saved to the stack, but this frame is
@@ -1251,7 +1252,7 @@ arm_unwind_pc (struct gdbarch *gdbarch, 
 {
   CORE_ADDR pc;
   pc = frame_unwind_register_unsigned (this_frame, ARM_PC_REGNUM);
-  return arm_addr_bits_remove (pc);
+  return arm_addr_bits_remove (gdbarch, pc);
 }
 
 static CORE_ADDR
@@ -1264,6 +1265,7 @@ static struct value *
 arm_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache,
 			  int regnum)
 {
+  struct gdbarch * gdbarch = get_frame_arch (this_frame);
   CORE_ADDR lr, cpsr;
 
   switch (regnum)
@@ -1275,7 +1277,7 @@ arm_dwarf2_prev_register (struct frame_i
 	 part of the PC.  */
       lr = frame_unwind_register_unsigned (this_frame, ARM_LR_REGNUM);
       return frame_unwind_got_constant (this_frame, regnum,
-					arm_addr_bits_remove (lr));
+					arm_addr_bits_remove (gdbarch, lr));
 
     case ARM_PS_REGNUM:
       /* Reconstruct the T bit; see arm_prologue_prev_register for details.  */
diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c
--- gdb-orig/gdb/gdbarch.c	2008-08-25 22:55:59.000000000 +0200
+++ gdb-head/gdb/gdbarch.c	2008-08-26 00:29:40.000000000 +0200
@@ -335,8 +335,8 @@ struct gdbarch startup_gdbarch =
   default_stabs_argument_has_addr,  /* stabs_argument_has_addr */
   0,  /* frame_red_zone_size */
   convert_from_func_ptr_addr_identity,  /* convert_from_func_ptr_addr */
-  0,  /* addr_bits_remove */
-  0,  /* smash_text_address */
+  core_addr_identity,  /* addr_bits_remove */
+  core_addr_identity,  /* smash_text_address */
   0,  /* software_single_step */
   0,  /* single_step_through_delay */
   0,  /* print_insn */
@@ -2508,7 +2508,7 @@ gdbarch_addr_bits_remove (struct gdbarch
   gdb_assert (gdbarch->addr_bits_remove != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_addr_bits_remove called\n");
-  return gdbarch->addr_bits_remove (addr);
+  return gdbarch->addr_bits_remove (gdbarch, addr);
 }
 
 void
@@ -2525,7 +2525,7 @@ gdbarch_smash_text_address (struct gdbar
   gdb_assert (gdbarch->smash_text_address != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_smash_text_address called\n");
-  return gdbarch->smash_text_address (addr);
+  return gdbarch->smash_text_address (gdbarch, addr);
 }
 
 void
diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h
--- gdb-orig/gdb/gdbarch.h	2008-08-22 03:25:27.000000000 +0200
+++ gdb-head/gdb/gdbarch.h	2008-08-26 00:29:32.000000000 +0200
@@ -490,14 +490,14 @@ extern void set_gdbarch_convert_from_fun
    sort of generic thing to handle alignment or segmentation (it's
    possible it should be in TARGET_READ_PC instead). */
 
-typedef CORE_ADDR (gdbarch_addr_bits_remove_ftype) (CORE_ADDR addr);
+typedef CORE_ADDR (gdbarch_addr_bits_remove_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern CORE_ADDR gdbarch_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern void set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch, gdbarch_addr_bits_remove_ftype *addr_bits_remove);
 
 /* It is not at all clear why gdbarch_smash_text_address is not folded into
    gdbarch_addr_bits_remove. */
 
-typedef CORE_ADDR (gdbarch_smash_text_address_ftype) (CORE_ADDR addr);
+typedef CORE_ADDR (gdbarch_smash_text_address_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern CORE_ADDR gdbarch_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern void set_gdbarch_smash_text_address (struct gdbarch *gdbarch, gdbarch_smash_text_address_ftype *smash_text_address);
 
diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh
--- gdb-orig/gdb/gdbarch.sh	2008-08-25 22:55:59.000000000 +0200
+++ gdb-head/gdb/gdbarch.sh	2008-08-26 00:29:26.000000000 +0200
@@ -529,10 +529,10 @@ m:CORE_ADDR:convert_from_func_ptr_addr:C
 # being a few stray bits in the PC which would mislead us, not as some
 # sort of generic thing to handle alignment or segmentation (it's
 # possible it should be in TARGET_READ_PC instead).
-f:CORE_ADDR:addr_bits_remove:CORE_ADDR addr:addr::core_addr_identity::0
+m:CORE_ADDR:addr_bits_remove:CORE_ADDR addr:addr::core_addr_identity::0
 # It is not at all clear why gdbarch_smash_text_address is not folded into
 # gdbarch_addr_bits_remove.
-f:CORE_ADDR:smash_text_address:CORE_ADDR addr:addr::core_addr_identity::0
+m:CORE_ADDR:smash_text_address:CORE_ADDR addr:addr::core_addr_identity::0
 
 # FIXME/cagney/2001-01-18: This should be split in two.  A target method that
 # indicates if the target needs software single step.  An ISA method to
diff -urNp gdb-orig/gdb/hppa-tdep.c gdb-head/gdb/hppa-tdep.c
--- gdb-orig/gdb/hppa-tdep.c	2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/hppa-tdep.c	2008-08-26 00:29:20.000000000 +0200
@@ -2663,7 +2663,7 @@ hppa64_cannot_fetch_register (struct gdb
 }
 
 static CORE_ADDR
-hppa_smash_text_address (CORE_ADDR addr)
+hppa_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   /* The low two bits of the PC on the PA contain the privilege level.
      Some genius implementing a (non-GCC) compiler apparently decided
diff -urNp gdb-orig/gdb/m88k-tdep.c gdb-head/gdb/m88k-tdep.c
--- gdb-orig/gdb/m88k-tdep.c	2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/m88k-tdep.c	2008-08-26 00:18:49.000000000 +0200
@@ -86,7 +86,7 @@ m88k_register_type (struct gdbarch *gdba
 
 
 static CORE_ADDR
-m88k_addr_bits_remove (CORE_ADDR addr)
+m88k_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   /* All instructures are 4-byte aligned.  The lower 2 bits of SXIP,
      SNIP and SFIP are used for special purposes: bit 0 is the
@@ -116,7 +116,7 @@ m88k_unwind_pc (struct gdbarch *gdbarch,
   CORE_ADDR pc;
 
   pc = frame_unwind_register_unsigned (next_frame, M88K_SXIP_REGNUM);
-  return m88k_addr_bits_remove (pc);
+  return m88k_addr_bits_remove (gdbarch, pc);
 }
 
 static void
diff -urNp gdb-orig/gdb/mips-tdep.c gdb-head/gdb/mips-tdep.c
--- gdb-orig/gdb/mips-tdep.c	2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/mips-tdep.c	2008-08-26 00:27:56.000000000 +0200
@@ -2313,9 +2313,9 @@ mips_stub_frame_base_sniffer (struct fra
 /* mips_addr_bits_remove - remove useless address bits  */
 
 static CORE_ADDR
-mips_addr_bits_remove (CORE_ADDR addr)
+mips_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   if (mips_mask_address_p (tdep) && (((ULONGEST) addr) >> 32 == 0xffffffffUL))
     /* This hack is a work-around for existing boards using PMON, the
        simulator, and any other 64-bit targets that doesn't have true
diff -urNp gdb-orig/gdb/s390-tdep.c gdb-head/gdb/s390-tdep.c
--- gdb-orig/gdb/s390-tdep.c	2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/s390-tdep.c	2008-08-26 00:18:49.000000000 +0200
@@ -2269,7 +2269,7 @@ s390_breakpoint_from_pc (struct gdbarch 
 /* Address handling.  */
 
 static CORE_ADDR
-s390_addr_bits_remove (CORE_ADDR addr)
+s390_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   return addr & 0x7fffffff;
 }
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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