This is the mail archive of the gdb-patches@sources.redhat.com 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/RFA/RFC] Replecament for DEPRECATED_REG_STRUCT_HAS_ADDR


Here is the promised patch to replace DEPRECATED_REG_STRUCT_HAS_ADDR.
I've baptized the new method stabs_argument_has_addr since that better
describes what it does than the old REG_STRUCT_HAS_ADDR; it's also
used for non-register and non-struct arguments, at least on SPARC.  I
also dropped the gcc_p argument since none of the current
implementations of DEPRECATED_REG_STRUCT_HAS_ADDR actually use it.

Anyway, I moved the type checks that were done in stabsread.c into
default_stabs_argument_has_addr.  This means that
stabs_argument_has_addr has to do all type-checks.  On SPARC this is
needed to support quad-precision floating-point arguments.

Andrew, I made stabs_argument_has_addr a multi-arch function, and I
don't provide a macro for it.  Is that all-right?  I'm a bit confused
when to provide a macro and when not.  What are your current ideas
about that?  Personally I think we should get rid of the macros and
explicitly use current_gdbarch.

Eli, are the doc bits OK?

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* gdbarch.sh (DEPRECATED_REG_STRUCT_HAS_ADDR): Add comment.
	(stabs_argument_has_addr): New architecture method.
	* arch-utils.h (default_stabs_argument_has_addr): New prototype.
	* arch-utils.c: Include "buildsym.h".
	(default_stabs_argument_has_addr): New function.
	* stabsread.c (define_symbol): Use stabs_argument_has_addr
	instead of DEPRECATED_REG_STRUCT_HAS_ADDR.

Index: doc/ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* gdbint.texinfo (Target Architecture Definition): Document
	pass_argument_by_reference.

Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.92
diff -u -p -r1.92 arch-utils.c
--- arch-utils.c 4 Sep 2003 00:05:50 -0000 1.92
+++ arch-utils.c 14 Sep 2003 13:11:57 -0000
@@ -23,6 +23,7 @@
 #include "defs.h"
 
 #include "arch-utils.h"
+#include "buildsym.h"
 #include "gdbcmd.h"
 #include "inferior.h"		/* enum CALL_DUMMY_LOCATION et.al. */
 #include "gdb_string.h"
@@ -357,6 +358,23 @@ legacy_value_to_register (struct frame_i
   memcpy (from, from, TYPE_LENGTH (type));
   DEPRECATED_REGISTER_CONVERT_TO_RAW (type, regnum, from, to);
   put_frame_register (frame, regnum, to);
+}
+
+int
+default_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
+{
+  if (DEPRECATED_REG_STRUCT_HAS_ADDR_P ()
+      && DEPRECATED_REG_STRUCT_HAS_ADDR (processing_gcc_compilation, type))
+    {
+      CHECK_TYPEDEF (type);
+
+      return (TYPE_CODE (type) == TYPE_CODE_STRUCT
+	      || TYPE_CODE (type) == TYPE_CODE_UNION
+	      || TYPE_CODE (type) == TYPE_CODE_SET
+	      || TYPE_CODE (type) == TYPE_CODE_BITSTRING);
+    }
+
+  return 0;
 }
 
 
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.54
diff -u -p -r1.54 arch-utils.h
--- arch-utils.h 4 Sep 2003 00:05:51 -0000 1.54
+++ arch-utils.h 14 Sep 2003 13:11:57 -0000
@@ -138,6 +138,9 @@ extern void legacy_register_to_value (st
 extern void legacy_value_to_register (struct frame_info *frame, int regnum,
 				      struct type *type, const void *from);
 
+extern int default_stabs_argument_has_addr (struct gdbarch *gdbarch,
+					    struct type *type);
+
 /* For compatibility with older architectures, returns
    (LEGACY_SIM_REGNO_IGNORE) when the register doesn't have a valid
    name.  */
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.268
diff -u -p -r1.268 gdbarch.sh
--- gdbarch.sh 13 Sep 2003 14:12:40 -0000 1.268
+++ gdbarch.sh 14 Sep 2003 13:12:02 -0000
@@ -646,7 +646,10 @@ F:2:FRAME_NUM_ARGS:int:frame_num_args:st
 # alignment.
 F:2:DEPRECATED_STACK_ALIGN:CORE_ADDR:deprecated_stack_align:CORE_ADDR sp:sp
 M:::CORE_ADDR:frame_align:CORE_ADDR address:address
+# DEPRECATED_REG_STRUCT_HAS_ADDR has been replaced by
+# stabs_argument_has_addr.
 F:2:DEPRECATED_REG_STRUCT_HAS_ADDR: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
 v::FRAME_RED_ZONE_SIZE:int:frame_red_zone_size
 v:2:PARM_BOUNDARY:int:parm_boundary
 #
Index: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.60
diff -u -p -r1.60 stabsread.c
--- stabsread.c 13 Sep 2003 14:12:40 -0000 1.60
+++ stabsread.c 14 Sep 2003 13:12:05 -0000
@@ -1748,17 +1748,20 @@ define_symbol (CORE_ADDR valu, char *str
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       if (within_function)
 	{
-	  /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
-	     name to represent an argument passed in a register.
-	     GCC uses 'P' for the same case.  So if we find such a symbol pair
-	     we combine it into one 'P' symbol.  For Sun cc we need to do this
-	     regardless of DEPRECATED_REG_STRUCT_HAS_ADDR, because the compiler puts out
-	     the 'p' symbol even if it never saves the argument onto the stack.
-
-	     On most machines, we want to preserve both symbols, so that
-	     we can still get information about what is going on with the
-	     stack (VAX for computing args_printed, using stack slots instead
-	     of saved registers in backtraces, etc.).
+	  /* Sun cc uses a pair of symbols, one 'p' and one 'r', with
+	     the same name to represent an argument passed in a
+	     register.  GCC uses 'P' for the same case.  So if we find
+	     such a symbol pair we combine it into one 'P' symbol.
+	     For Sun cc we need to do this regardless of
+	     stabs_argument_has_addr, because the compiler puts out
+	     the 'p' symbol even if it never saves the argument onto
+	     the stack.
+
+	     On most machines, we want to preserve both symbols, so
+	     that we can still get information about what is going on
+	     with the stack (VAX for computing args_printed, using
+	     stack slots instead of saved registers in backtraces,
+	     etc.).
 
 	     Note that this code illegally combines
 	     main(argc) struct foo argc; { register struct foo argc; }
@@ -1768,13 +1771,8 @@ define_symbol (CORE_ADDR valu, char *str
 	  if (local_symbols
 	      && local_symbols->nsyms > 0
 #ifndef USE_REGISTER_NOT_ARG
-	      && DEPRECATED_REG_STRUCT_HAS_ADDR_P ()
-	      && DEPRECATED_REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
-				      SYMBOL_TYPE (sym))
-	      && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
-		  || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION
-		  || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET
-		  || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
+	      && gdbarch_stabs_argument_has_addr (current_gdbarch,
+						  SYMBOL_TYPE (sym))
 #endif
 	    )
 	    {
@@ -2047,29 +2045,21 @@ define_symbol (CORE_ADDR valu, char *str
       break;
     }
 
-  /* When passing structures to a function, some systems sometimes pass
-     the address in a register, not the structure itself. */
+  /* Some systems pass variables of certain types by reference instead
+     of by value, i.e. they will pass the address of a structure (in a
+     register or on the stack) instead of the structure itself.  */
 
-  if (DEPRECATED_REG_STRUCT_HAS_ADDR_P ()
-      && DEPRECATED_REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
+  if (gdbarch_stabs_argument_has_addr (current_gdbarch, SYMBOL_TYPE (sym))
       && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
     {
-      struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
-
-      if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
-	  || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
-	  || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
-	  || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
-	{
-	  /* If DEPRECATED_REG_STRUCT_HAS_ADDR yields non-zero we have to convert
-	     LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
-	  if (SYMBOL_CLASS (sym) == LOC_REGPARM)
-	    SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
-	  /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
-	     and subsequent arguments on the sparc, for example).  */
-	  else if (SYMBOL_CLASS (sym) == LOC_ARG)
-	    SYMBOL_CLASS (sym) = LOC_REF_ARG;
-	}
+      /* We have to convert LOC_REGPARM to LOC_REGPARM_ADDR (for
+         variables passed in a register).  */
+      if (SYMBOL_CLASS (sym) == LOC_REGPARM)
+	SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+      /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
+	 and subsequent arguments on SPARC, for example).  */
+      else if (SYMBOL_CLASS (sym) == LOC_ARG)
+	SYMBOL_CLASS (sym) = LOC_REF_ARG;
     }
 
   /* Is there more to parse?  For example LRS/alias information?  */
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.161
diff -u -p -r1.161 gdbint.texinfo
--- doc/gdbint.texinfo 13 Sep 2003 14:12:41 -0000 1.161
+++ doc/gdbint.texinfo 14 Sep 2003 13:12:12 -0000
@@ -3686,6 +3686,16 @@ The number of the ``next program counter
 If non-zero, round arguments to a boundary of this many bits before
 pushing them on the stack.
 
+@item stabs_argument_has_addr (@var{gdbarch}, @var{type})
+@findex stabs_argument_has_addr
+@findex DEPRECATED_REG_STRUCT_HAS_ADDR
+@anchor{stabs_argument_has_addr} Define this to return nonzero if a
+function argument of type @var{type} is passed by reference instead of
+value.
+
+This method replaces @code{DEPRECTAED_REG_STRUCT_HAS_ADDR}
+(@pxref{DEPRECATED_REG_STRUCT_ADDR}).
+
 @item PROCESS_LINENUMBER_HOOK
 @findex PROCESS_LINENUMBER_HOOK
 A hook defined for XCOFF reading.
@@ -3762,8 +3772,11 @@ Deprecated in favor of @code{REGISTER_NA
 
 @item DEPRECATED_REG_STRUCT_HAS_ADDR (@var{gcc_p}, @var{type})
 @findex DEPRECATED_REG_STRUCT_HAS_ADDR
-Define this to return 1 if the given type will be passed by pointer
-rather than directly.
+@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{stabs_argument_has_addr}
+(@pxref{stabs_argument_has_addr}).
 
 @item SAVE_DUMMY_FRAME_TOS (@var{sp})
 @findex SAVE_DUMMY_FRAME_TOS


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