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]

[PR tdep/7438] Replace gdbarch 'smash_text_address' with 'addr_bits_remove'


Hi,
This patch is to remove gdbarch method 'smash_text_address', and replace
it with gdbarch method 'addr_bits_remove'.

In gdbarch.sh, there is a line of comment,

  # It is not at all clear why gdbarch_smash_text_address is not folded into
  # gdbarch_addr_bits_remove.
  m:CORE_ADDR:smash_text_address:CORE_ADDR addr:addr::core_addr_identity::0

which was added by this patch,

  RFC/PATCH multi-arch SMASH_TEXT_ADDRESS
  http://sourceware.org/ml/gdb-patches/2002-02/msg00028.html

The issue (why SMASH_TEXT_ADDRESS is not folded into ADDR_BITS_REMOVE) was
tracked by PR7438, but was  not investigated further.

AFAICS, macro SMASH_TEXT_ADDRESS was added for hppa by this change,

Fri Jan 28 10:40:34 1994  Jim Kingdon  (kingdon@lioth.cygnus.com)

        * config/pa/tm-hppa.h: Define macro SMASH_TEXT_ADDRESS.
        * elfread.c (record_minimal_symbol_and_info),
        dwarfread.c (process_dies), paread.c (pa_symtab_read): Use it.

However, the same function 'hppa_smash_text_address' is installed to both
gdbarch methods 'addr_bits_remove' and 'smash_text_address'.  Method
'smash_text_address' is set in arm-tdep.c as well, but as we can see,
'arm_addr_bits_remove' can cover 'arm_smash_text_address'.

Except arm and hppa, there is no port use 'smash_text_address', so
we can safely replace 'smash_text_address' with 'addr_bits_remove'.

Regression tested on arm-none-gnueabi.  Is it OK?

gdb:

2012-11-20  Yao Qi  <yao@codesourcery.com>

	PR tdep/7438
	* gdbarch.sh (smash_text_address): Remove.
	* gdbarch.c, gdbarch.h: Regenerate.
	* arm-tdep.c (arm_smash_text_address): Remove.
	(arm_gdbarch_init): Don't call set_gdbarch_smash_text_address.
	* hppa-tdep.c (hppa_smash_text_address): Remove.
	(hppa_addr_bits_remove): Rename from hppa_smash_text_address.
	(hppa_gdbarch_init): Don't call set_gdbarch_smash_text_address.
	Caller update.
	* coffread.c (coff_symtab_read): Caller update.
	* dbxread.c (process_one_symbol): Likewise.
	* elfread.c (record_minimal_symbol): Likewise.
	* somread.c (som_symtab_read): Likewise.
---
 gdb/arm-tdep.c  |    9 ---------
 gdb/coffread.c  |    2 +-
 gdb/dbxread.c   |    2 +-
 gdb/elfread.c   |    2 +-
 gdb/gdbarch.c   |   24 ------------------------
 gdb/gdbarch.h   |    7 -------
 gdb/gdbarch.sh  |    3 ---
 gdb/hppa-tdep.c |    5 ++---
 gdb/somread.c   |   14 +++++++-------
 9 files changed, 12 insertions(+), 56 deletions(-)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a221fd6..578552a 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -460,14 +460,6 @@ arm_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR val)
     return (val & 0x03fffffc);
 }
 
-/* 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 (struct gdbarch *gdbarch, CORE_ADDR val)
-{
-  return val & ~1;
-}
-
 /* Return 1 if PC is the start of a compiler helper function which
    can be safely ignored during prologue skipping.  IS_THUMB is true
    if the function is known to be a Thumb function due to the way it
@@ -10282,7 +10274,6 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   frame_base_set_default (gdbarch, &arm_normal_base);
 
   /* Address manipulation.  */
-  set_gdbarch_smash_text_address (gdbarch, arm_smash_text_address);
   set_gdbarch_addr_bits_remove (gdbarch, arm_addr_bits_remove);
 
   /* Advance PC across function entry code.  */
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 0c7e6d9..3789995 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -941,7 +941,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
 		      cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC
 		      || cs->c_sclass == C_THUMBEXT ?
 		      mst_text : mst_file_text;
-		    tmpaddr = gdbarch_smash_text_address (gdbarch, tmpaddr);
+		    tmpaddr = gdbarch_addr_bits_remove (gdbarch, tmpaddr);
 		  }
 		else if (bfd_section->flags & SEC_ALLOC
 			 && bfd_section->flags & SEC_LOAD)
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 2d47407..9d0e624 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2827,7 +2827,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 
       /* Relocate for dynamic loading.  */
       valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
-      valu = gdbarch_smash_text_address (gdbarch, valu);
+      valu = gdbarch_addr_bits_remove (gdbarch, valu);
       last_function_start = valu;
 
       goto define_a_symbol;
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 516cbd0..84efc59 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -205,7 +205,7 @@ record_minimal_symbol (const char *name, int name_len, int copy_name,
 
   if (ms_type == mst_text || ms_type == mst_file_text
       || ms_type == mst_text_gnu_ifunc)
-    address = gdbarch_smash_text_address (gdbarch, address);
+    address = gdbarch_addr_bits_remove (gdbarch, address);
 
   return prim_record_minimal_symbol_full (name, name_len, copy_name, address,
 					  ms_type, bfd_section->index,
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 09576b1..6ae453e 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -220,7 +220,6 @@ struct gdbarch
   int frame_red_zone_size;
   gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr;
   gdbarch_addr_bits_remove_ftype *addr_bits_remove;
-  gdbarch_smash_text_address_ftype *smash_text_address;
   gdbarch_software_single_step_ftype *software_single_step;
   gdbarch_single_step_through_delay_ftype *single_step_through_delay;
   gdbarch_print_insn_ftype *print_insn;
@@ -389,7 +388,6 @@ struct gdbarch startup_gdbarch =
   0,  /* frame_red_zone_size */
   convert_from_func_ptr_addr_identity,  /* convert_from_func_ptr_addr */
   core_addr_identity,  /* addr_bits_remove */
-  core_addr_identity,  /* smash_text_address */
   0,  /* software_single_step */
   0,  /* single_step_through_delay */
   0,  /* print_insn */
@@ -526,7 +524,6 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
   gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
   gdbarch->addr_bits_remove = core_addr_identity;
-  gdbarch->smash_text_address = core_addr_identity;
   gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
   gdbarch->skip_solib_resolver = generic_skip_solib_resolver;
   gdbarch->in_solib_return_trampoline = generic_in_solib_return_trampoline;
@@ -689,7 +686,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of stabs_argument_has_addr, invalid_p == 0 */
   /* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */
   /* Skip verify of addr_bits_remove, invalid_p == 0 */
-  /* Skip verify of smash_text_address, invalid_p == 0 */
   /* Skip verify of software_single_step, has predicate.  */
   /* Skip verify of single_step_through_delay, has predicate.  */
   if (gdbarch->print_insn == 0)
@@ -1286,9 +1282,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
                       "gdbarch_dump: skip_trampoline_code = <%s>\n",
                       host_address_to_string (gdbarch->skip_trampoline_code));
   fprintf_unfiltered (file,
-                      "gdbarch_dump: smash_text_address = <%s>\n",
-                      host_address_to_string (gdbarch->smash_text_address));
-  fprintf_unfiltered (file,
                       "gdbarch_dump: gdbarch_software_single_step_p() = %d\n",
                       gdbarch_software_single_step_p (gdbarch));
   fprintf_unfiltered (file,
@@ -2981,23 +2974,6 @@ set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch,
   gdbarch->addr_bits_remove = addr_bits_remove;
 }
 
-CORE_ADDR
-gdbarch_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr)
-{
-  gdb_assert (gdbarch != NULL);
-  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 (gdbarch, addr);
-}
-
-void
-set_gdbarch_smash_text_address (struct gdbarch *gdbarch,
-                                gdbarch_smash_text_address_ftype smash_text_address)
-{
-  gdbarch->smash_text_address = smash_text_address;
-}
-
 int
 gdbarch_software_single_step_p (struct gdbarch *gdbarch)
 {
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index df09553..3d9dc79 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -600,13 +600,6 @@ typedef CORE_ADDR (gdbarch_addr_bits_remove_ftype) (struct gdbarch *gdbarch, COR
 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) (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);
-
 /* 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
    implement it.
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 4b11f92..81a70b0 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -574,9 +574,6 @@ m:CORE_ADDR:convert_from_func_ptr_addr:CORE_ADDR addr, struct target_ops *targ:a
 # sort of generic thing to handle alignment or segmentation (it's
 # possible it should be in TARGET_READ_PC instead).
 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.
-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 --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 581ffc7..5ee758e 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -2640,7 +2640,7 @@ hppa64_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
 }
 
 static CORE_ADDR
-hppa_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr)
+hppa_addr_bits_remove (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
@@ -3058,8 +3058,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_inner_than (gdbarch, core_addr_greaterthan);
   set_gdbarch_sp_regnum (gdbarch, HPPA_SP_REGNUM);
   set_gdbarch_fp0_regnum (gdbarch, HPPA_FP0_REGNUM);
-  set_gdbarch_addr_bits_remove (gdbarch, hppa_smash_text_address);
-  set_gdbarch_smash_text_address (gdbarch, hppa_smash_text_address);
+  set_gdbarch_addr_bits_remove (gdbarch, hppa_addr_bits_remove);
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
   set_gdbarch_read_pc (gdbarch, hppa_read_pc);
   set_gdbarch_write_pc (gdbarch, hppa_write_pc);
diff --git a/gdb/somread.c b/gdb/somread.c
index 19a15e2..aeeb992 100644
--- a/gdb/somread.c
+++ b/gdb/somread.c
@@ -121,7 +121,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	      symname = bufp->name.n_strx + stringtab;
 	      ms_type = mst_text;
 	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_smash_text_address
+	      bufp->symbol_value = gdbarch_addr_bits_remove
 				     (gdbarch, bufp->symbol_value);
 	      break;
 
@@ -135,7 +135,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	      else
 		ms_type = mst_text;
 	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_smash_text_address
+	      bufp->symbol_value = gdbarch_addr_bits_remove
 				     (gdbarch, bufp->symbol_value);
 	      break;
 
@@ -143,7 +143,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	      symname = bufp->name.n_strx + stringtab;
 	      ms_type = mst_solib_trampoline;
 	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_smash_text_address
+	      bufp->symbol_value = gdbarch_addr_bits_remove
 				     (gdbarch, bufp->symbol_value);
 	      break;
 
@@ -172,7 +172,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	      symname = bufp->name.n_strx + stringtab;
 	      ms_type = mst_file_text;
 	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_smash_text_address
+	      bufp->symbol_value = gdbarch_addr_bits_remove
 				     (gdbarch, bufp->symbol_value);
 
 	    check_strange_names:
@@ -204,7 +204,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	      symname = bufp->name.n_strx + stringtab;
 	      ms_type = mst_file_text;
 	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_smash_text_address
+	      bufp->symbol_value = gdbarch_addr_bits_remove
 				     (gdbarch, bufp->symbol_value);
 	      break;
 
@@ -216,7 +216,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 		 we do for SS_UNIVERSAL and SS_EXTERNAL symbols above.  */
 	      ms_type = mst_file_text;
 	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_smash_text_address
+	      bufp->symbol_value = gdbarch_addr_bits_remove
 				     (gdbarch, bufp->symbol_value);
 	      break;
 
@@ -224,7 +224,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	      symname = bufp->name.n_strx + stringtab;
 	      ms_type = mst_solib_trampoline;
 	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_smash_text_address
+	      bufp->symbol_value = gdbarch_addr_bits_remove
 				     (gdbarch, bufp->symbol_value);
 	      break;
 
-- 
1.7.7.6


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