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]

[commit] Remove deprecated_reg_struct_has_addr


Hello,

this removes the deprecated_reg_struct_has_addr gdbarch routine.
The only remaining user was cris, and this use can be eliminated
by simply fixing the cris_push_dummy_call routine to properly
handle arguments passed by reference.  (The old implementation
seems to have been broken anyway, seeing the number of testsuite
FAILs ...)

Tested on cris-elf via simulator, fixes about 500 FAILs.
Committed to mainline.

Bye,
Ulrich


ChangeLog:

	* cris-tdep.c (cris_push_dummy_call): Support arguments passed by
	reference.  Fix endianness bugs.
	(cris_reg_struct_has_address): Remove.
	(cris_gdbarch_init): Remove set_gdbarch_deprecated_reg_struct_has_addr
	and set_gdbarch_deprecated_use_struct_convention calls.

	* gdbarch.sh (deprecated_reg_struct_has_addr): Remove.
	* gdbarch.c, gdbarch.h: Regenerate.
	* infcall.c (call_function_by_hand): Remove handling of
	deprecated_reg_struct_has_addr.

doc/ChangeLog:

	* gdbint.texi (Target Conditionals): Remove documentation of
	and references to DEPRECATED_REG_STRUCT_HAS_ADDR.

diff -urNp gdb-orig/gdb/cris-tdep.c gdb-head/gdb/cris-tdep.c
--- gdb-orig/gdb/cris-tdep.c	2007-10-11 22:25:51.000000000 +0200
+++ gdb-head/gdb/cris-tdep.c	2007-10-12 03:12:49.000000000 +0200
@@ -938,8 +938,7 @@ cris_push_dummy_call (struct gdbarch *gd
           /* Data passed by value.  Fits in available register(s).  */
           for (i = 0; i < reg_demand; i++)
             {
-              regcache_cooked_write_unsigned (regcache, argreg, 
-					      *(unsigned long *) val);
+              regcache_cooked_write (regcache, argreg, val);
               argreg++;
               val += 4;
             }
@@ -952,8 +951,7 @@ cris_push_dummy_call (struct gdbarch *gd
             {
               if (argreg <= ARG4_REGNUM)
                 {
-		  regcache_cooked_write_unsigned (regcache, argreg, 
-						  *(unsigned long *) val);
+		  regcache_cooked_write (regcache, argreg, val);
                   argreg++;
                   val += 4;
                 }
@@ -968,8 +966,22 @@ cris_push_dummy_call (struct gdbarch *gd
         }
       else if (len > (2 * 4))
         {
-	  /* FIXME */
-	  internal_error (__FILE__, __LINE__, _("We don't do this"));
+	  /* Data passed by reference.  Push copy of data onto stack
+	     and pass pointer to this copy as argument.  */
+	  sp = (sp - len) & ~3;
+	  write_memory (sp, val, len);
+
+	  if (argreg <= ARG4_REGNUM)
+	    {
+	      regcache_cooked_write_unsigned (regcache, argreg, sp);
+	      argreg++;
+	    }
+	  else
+	    {
+	      gdb_byte buf[4];
+	      store_unsigned_integer (buf, 4, sp);
+	      si = push_stack_item (si, buf, 4);
+	    }
         }
       else
         {
@@ -1931,18 +1943,6 @@ cris_return_value (struct gdbarch *gdbar
   return RETURN_VALUE_REGISTER_CONVENTION;
 }
 
-/* Returns 1 if the given type will be passed by pointer rather than 
-   directly.  */
-
-/* In the CRIS ABI, arguments shorter than or equal to 64 bits are passed
-   by value.  */
-
-static int 
-cris_reg_struct_has_addr (int gcc_p, struct type *type)
-{ 
-  return (TYPE_LENGTH (type) > 8);
-}
-
 /* Calculates a value that measures how good inst_args constraints an 
    instruction.  It stems from cris_constraint, found in cris-dis.c.  */
 
@@ -4120,9 +4120,6 @@ cris_gdbarch_init (struct gdbarch_info i
     }
 
   set_gdbarch_return_value (gdbarch, cris_return_value);
-  set_gdbarch_deprecated_reg_struct_has_addr (gdbarch, 
-					      cris_reg_struct_has_addr);
-  set_gdbarch_deprecated_use_struct_convention (gdbarch, always_use_struct_convention);
 
   set_gdbarch_sp_regnum (gdbarch, 14);
   
diff -urNp gdb-orig/gdb/doc/gdbint.texinfo gdb-head/gdb/doc/gdbint.texinfo
--- gdb-orig/gdb/doc/gdbint.texinfo	2007-10-11 22:27:06.000000000 +0200
+++ gdb-head/gdb/doc/gdbint.texinfo	2007-10-12 02:40:10.000000000 +0200
@@ -3889,14 +3889,10 @@ This should only need to be defined if @
 
 @item int gdbarch_stabs_argument_has_addr (@var{gdbarch}, @var{type})
 @findex gdbarch_stabs_argument_has_addr
-@findex DEPRECATED_REG_STRUCT_HAS_ADDR
 @anchor{gdbarch_stabs_argument_has_addr} Define this function to return
 nonzero if a function argument of type @var{type} is passed by reference
 instead of value.
 
-This method replaces @code{DEPRECATED_REG_STRUCT_HAS_ADDR}
-(@pxref{DEPRECATED_REG_STRUCT_HAS_ADDR}).
-
 @item PROCESS_LINENUMBER_HOOK
 @findex PROCESS_LINENUMBER_HOOK
 A hook defined for XCOFF reading.
@@ -3944,14 +3940,6 @@ This method replaces @w{@code{gdbarch_ca
 Return the name of register @var{regnr} as a string.  May return @code{NULL}
 to indicate that @var{regnr} is not a valid register.
 
-@item DEPRECATED_REG_STRUCT_HAS_ADDR (@var{gcc_p}, @var{type})
-@findex DEPRECATED_REG_STRUCT_HAS_ADDR
-@anchor{DEPRECATED_REG_STRUCT_HAS_ADDR}Define this to return 1 if the
-given type will be passed by pointer rather than directly.
-
-This method has been replaced by @code{gdbarch_stabs_argument_has_addr}
-(@pxref{gdbarch_stabs_argument_has_addr}).
-
 @item SAVE_DUMMY_FRAME_TOS (@var{sp})
 @findex SAVE_DUMMY_FRAME_TOS
 @anchor{SAVE_DUMMY_FRAME_TOS} Used in @samp{call_function_by_hand} to
diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c
--- gdb-orig/gdb/gdbarch.c	2007-10-11 22:27:06.000000000 +0200
+++ gdb-head/gdb/gdbarch.c	2007-10-12 02:35:58.000000000 +0200
@@ -200,7 +200,6 @@ struct gdbarch
   gdbarch_unwind_sp_ftype *unwind_sp;
   gdbarch_frame_num_args_ftype *frame_num_args;
   gdbarch_frame_align_ftype *frame_align;
-  gdbarch_deprecated_reg_struct_has_addr_ftype *deprecated_reg_struct_has_addr;
   gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr;
   int frame_red_zone_size;
   gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr;
@@ -323,7 +322,6 @@ struct gdbarch startup_gdbarch =
   0,  /* unwind_sp */
   0,  /* frame_num_args */
   0,  /* frame_align */
-  0,  /* deprecated_reg_struct_has_addr */
   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 */
@@ -571,7 +569,6 @@ verify_gdbarch (struct gdbarch *current_
   /* Skip verify of unwind_sp, has predicate */
   /* Skip verify of frame_num_args, has predicate */
   /* Skip verify of frame_align, has predicate */
-  /* Skip verify of deprecated_reg_struct_has_addr, has predicate */
   /* 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 */
@@ -738,12 +735,6 @@ gdbarch_dump (struct gdbarch *current_gd
                       "gdbarch_dump: deprecated_function_start_offset = 0x%s\n",
                       paddr_nz (current_gdbarch->deprecated_function_start_offset));
   fprintf_unfiltered (file,
-                      "gdbarch_dump: gdbarch_deprecated_reg_struct_has_addr_p() = %d\n",
-                      gdbarch_deprecated_reg_struct_has_addr_p (current_gdbarch));
-  fprintf_unfiltered (file,
-                      "gdbarch_dump: deprecated_reg_struct_has_addr = <0x%lx>\n",
-                      (long) current_gdbarch->deprecated_reg_struct_has_addr);
-  fprintf_unfiltered (file,
                       "gdbarch_dump: deprecated_use_struct_convention = <0x%lx>\n",
                       (long) current_gdbarch->deprecated_use_struct_convention);
   fprintf_unfiltered (file,
@@ -2425,30 +2416,6 @@ set_gdbarch_frame_align (struct gdbarch 
 }
 
 int
-gdbarch_deprecated_reg_struct_has_addr_p (struct gdbarch *gdbarch)
-{
-  gdb_assert (gdbarch != NULL);
-  return gdbarch->deprecated_reg_struct_has_addr != NULL;
-}
-
-int
-gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch, int gcc_p, struct type *type)
-{
-  gdb_assert (gdbarch != NULL);
-  gdb_assert (gdbarch->deprecated_reg_struct_has_addr != NULL);
-  if (gdbarch_debug >= 2)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_reg_struct_has_addr called\n");
-  return gdbarch->deprecated_reg_struct_has_addr (gcc_p, type);
-}
-
-void
-set_gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch,
-                                            gdbarch_deprecated_reg_struct_has_addr_ftype deprecated_reg_struct_has_addr)
-{
-  gdbarch->deprecated_reg_struct_has_addr = deprecated_reg_struct_has_addr;
-}
-
-int
 gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
 {
   gdb_assert (gdbarch != NULL);
diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h
--- gdb-orig/gdb/gdbarch.h	2007-10-11 22:27:06.000000000 +0200
+++ gdb-head/gdb/gdbarch.h	2007-10-12 02:35:48.000000000 +0200
@@ -469,15 +469,6 @@ typedef CORE_ADDR (gdbarch_frame_align_f
 extern CORE_ADDR gdbarch_frame_align (struct gdbarch *gdbarch, CORE_ADDR address);
 extern void set_gdbarch_frame_align (struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align);
 
-/* deprecated_reg_struct_has_addr has been replaced by
-   stabs_argument_has_addr. */
-
-extern int gdbarch_deprecated_reg_struct_has_addr_p (struct gdbarch *gdbarch);
-
-typedef int (gdbarch_deprecated_reg_struct_has_addr_ftype) (int gcc_p, struct type *type);
-extern int gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch, int gcc_p, struct type *type);
-extern void set_gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch, gdbarch_deprecated_reg_struct_has_addr_ftype *deprecated_reg_struct_has_addr);
-
 typedef int (gdbarch_stabs_argument_has_addr_ftype) (struct gdbarch *gdbarch, struct type *type);
 extern int gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type);
 extern void set_gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr);
diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh
--- gdb-orig/gdb/gdbarch.sh	2007-10-11 22:27:06.000000000 +0200
+++ gdb-head/gdb/gdbarch.sh	2007-10-12 02:35:38.000000000 +0200
@@ -546,9 +546,6 @@ M::CORE_ADDR:unwind_sp:struct frame_info
 F::int:frame_num_args:struct frame_info *frame:frame
 #
 M::CORE_ADDR:frame_align:CORE_ADDR address:address
-# deprecated_reg_struct_has_addr has been replaced by
-# stabs_argument_has_addr.
-F::int:deprecated_reg_struct_has_addr:int gcc_p, struct type *type:gcc_p, type
 m::int:stabs_argument_has_addr:struct type *type:type::default_stabs_argument_has_addr::0
 v::int:frame_red_zone_size
 #
diff -urNp gdb-orig/gdb/infcall.c gdb-head/gdb/infcall.c
--- gdb-orig/gdb/infcall.c	2007-10-02 19:08:03.000000000 +0200
+++ gdb-head/gdb/infcall.c	2007-10-12 02:37:04.000000000 +0200
@@ -624,61 +624,6 @@ You must use a pointer to function type 
       }
   }
 
-  if (gdbarch_deprecated_reg_struct_has_addr_p (current_gdbarch))
-    {
-      int i;
-      /* This is a machine like the sparc, where we may need to pass a
-	 pointer to the structure, not the structure itself.  */
-      for (i = nargs - 1; i >= 0; i--)
-	{
-	  struct type *arg_type = check_typedef (value_type (args[i]));
-	  if ((TYPE_CODE (arg_type) == TYPE_CODE_STRUCT
-	       || TYPE_CODE (arg_type) == TYPE_CODE_UNION
-	       || TYPE_CODE (arg_type) == TYPE_CODE_ARRAY
-	       || TYPE_CODE (arg_type) == TYPE_CODE_STRING
-	       || TYPE_CODE (arg_type) == TYPE_CODE_BITSTRING
-	       || TYPE_CODE (arg_type) == TYPE_CODE_SET
-	       || (TYPE_CODE (arg_type) == TYPE_CODE_FLT
-		   && TYPE_LENGTH (arg_type) > 8)
-	       )
-	      && gdbarch_deprecated_reg_struct_has_addr
-		   (current_gdbarch, using_gcc, arg_type))
-	    {
-	      CORE_ADDR addr;
-	      int len;		/*  = TYPE_LENGTH (arg_type); */
-	      int aligned_len;
-	      arg_type = check_typedef (value_enclosing_type (args[i]));
-	      len = TYPE_LENGTH (arg_type);
-
-	      aligned_len = len;
-	      if (gdbarch_inner_than (current_gdbarch, 1, 2))
-		{
-		  /* stack grows downward */
-		  sp -= aligned_len;
-		  /* ... so the address of the thing we push is the
-		     stack pointer after we push it.  */
-		  addr = sp;
-		}
-	      else
-		{
-		  /* The stack grows up, so the address of the thing
-		     we push is the stack pointer before we push it.  */
-		  addr = sp;
-		  sp += aligned_len;
-		}
-	      /* Push the structure.  */
-	      write_memory (addr, value_contents_all (args[i]), len);
-	      /* The value we're going to pass is the address of the
-		 thing we just pushed.  */
-	      /*args[i] = value_from_longest (lookup_pointer_type (values_type),
-		(LONGEST) addr); */
-	      args[i] = value_from_pointer (lookup_pointer_type (arg_type),
-					    addr);
-	    }
-	}
-    }
-
-
   /* Reserve space for the return structure to be written on the
      stack, if necessary.  Make certain that the value is correctly
      aligned. */
-- 
  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]