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]

[commit] Move DUMMY_WORD code to where it is used


Hello,

This moves all the DUMMY_WORD stuff, found in call_function_by_hand, to the one place that it is actually used.

committed,
Andrew
2003-04-23  Andrew Cagney  <cagney at redhat dot com>

	* infcall.c (call_function_by_hand): Move variables "start_sp",
	"dummy", "sizeof_dummy1" and "dummy1" and corresponding dummy call
	code to ON_STACK switch branch.
	
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.4
diff -u -r1.4 infcall.c
--- infcall.c	23 Apr 2003 20:31:57 -0000	1.4
+++ infcall.c	23 Apr 2003 21:11:45 -0000
@@ -238,24 +238,6 @@
 {
   register CORE_ADDR sp;
   int rc;
-  CORE_ADDR start_sp;
-  /* CALL_DUMMY is an array of words (REGISTER_SIZE), but each word
-     is in host byte order.  Before calling FIX_CALL_DUMMY, we byteswap it
-     and remove any extra bytes which might exist because ULONGEST is
-     bigger than REGISTER_SIZE.
-
-     NOTE: This is pretty wierd, as the call dummy is actually a
-     sequence of instructions.  But CISC machines will have
-     to pack the instructions into REGISTER_SIZE units (and
-     so will RISC machines for which INSTRUCTION_SIZE is not
-     REGISTER_SIZE).
-
-     NOTE: This is pretty stupid.  CALL_DUMMY should be in strict
-     target byte order. */
-
-  static ULONGEST *dummy;
-  int sizeof_dummy1;
-  char *dummy1;
   CORE_ADDR dummy_addr;
   struct type *value_type;
   unsigned char struct_return;
@@ -270,11 +252,6 @@
   struct type *ftype = check_typedef (SYMBOL_TYPE (function));
   CORE_ADDR bp_addr;
 
-  dummy = alloca (SIZEOF_CALL_DUMMY_WORDS);
-  sizeof_dummy1 = REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS / sizeof (ULONGEST);
-  dummy1 = alloca (sizeof_dummy1);
-  memcpy (dummy, CALL_DUMMY_WORDS, SIZEOF_CALL_DUMMY_WORDS);
-
   if (!target_has_execution)
     noprocess ();
 
@@ -371,24 +348,6 @@
       sp = old_sp;
   }
 
-  if (INNER_THAN (1, 2))
-    {
-      /* Stack grows down */
-      sp -= sizeof_dummy1;
-      start_sp = sp;
-    }
-  else
-    {
-      /* Stack grows up */
-      start_sp = sp;
-      sp += sizeof_dummy1;
-    }
-
-  /* NOTE: cagney/2002-09-10: Don't bother re-adjusting the stack
-     after allocating space for the call dummy.  A target can specify
-     a SIZEOF_DUMMY1 (via SIZEOF_CALL_DUMMY_WORDS) such that all local
-     alignment requirements are met.  */
-
   funaddr = find_function_addr (function, &value_type);
   CHECK_TYPEDEF (value_type);
 
@@ -404,47 +363,82 @@
   struct_return = using_struct_return (function, funaddr, value_type,
 				       using_gcc);
 
-  /* Create a call sequence customized for this function
-     and the number of arguments for it.  */
-  {
-    int i;
-    for (i = 0; i < (int) (SIZEOF_CALL_DUMMY_WORDS / sizeof (dummy[0])); i++)
-      store_unsigned_integer (&dummy1[i * REGISTER_SIZE],
-			      REGISTER_SIZE,
-			      (ULONGEST) dummy[i]);
-  }
-
   switch (CALL_DUMMY_LOCATION)
     {
     case ON_STACK:
-      /* NOTE: cagney/2003-04-22: This computation of REAL_PC, BP_ADDR
-         and DUMMY_ADDR is pretty messed up.  It comes from constant
-         tinkering with the values.  Instead a FIX_CALL_DUMMY
-         replacement (PUSH_DUMMY_BREAKPOINT?) should just do
-         everything.  */
-#ifdef GDB_TARGET_IS_HPPA
-      real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
-				value_type, using_gcc);
-#else
-      if (FIX_CALL_DUMMY_P ())
+      {
+	/* CALL_DUMMY is an array of words (REGISTER_SIZE), but each
+	   word is in host byte order.  Before calling FIX_CALL_DUMMY,
+	   we byteswap it and remove any extra bytes which might exist
+	   because ULONGEST is bigger than REGISTER_SIZE.  */
+	/* NOTE: This is pretty wierd, as the call dummy is actually a
+	   sequence of instructions.  But CISC machines will have to
+	   pack the instructions into REGISTER_SIZE units (and so will
+	   RISC machines for which INSTRUCTION_SIZE is not
+	   REGISTER_SIZE).  */
+	/* NOTE: This is pretty stupid.  CALL_DUMMY should be in
+	   strict target byte order. */
+	CORE_ADDR start_sp;
+	ULONGEST *dummy = alloca (SIZEOF_CALL_DUMMY_WORDS);
+	int sizeof_dummy1 = (REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS
+			     / sizeof (ULONGEST));
+	char *dummy1 = alloca (sizeof_dummy1);
+	memcpy (dummy, CALL_DUMMY_WORDS, SIZEOF_CALL_DUMMY_WORDS);
+	if (INNER_THAN (1, 2))
+	  {
+	    /* Stack grows down */
+	    sp -= sizeof_dummy1;
+	    start_sp = sp;
+	  }
+	else
+	  {
+	    /* Stack grows up */
+	    start_sp = sp;
+	    sp += sizeof_dummy1;
+	  }
+	/* NOTE: cagney/2002-09-10: Don't bother re-adjusting the
+	   stack after allocating space for the call dummy.  A target
+	   can specify a SIZEOF_DUMMY1 (via SIZEOF_CALL_DUMMY_WORDS)
+	   such that all local alignment requirements are met.  */
+	/* Create a call sequence customized for this function and the
+	   number of arguments for it.  */
 	{
-	  /* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true?  */
-	  FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type,
-			  using_gcc);
+	  int i;
+	  for (i = 0; i < (int) (SIZEOF_CALL_DUMMY_WORDS / sizeof (dummy[0]));
+	       i++)
+	    store_unsigned_integer (&dummy1[i * REGISTER_SIZE],
+				    REGISTER_SIZE,
+				    (ULONGEST) dummy[i]);
 	}
-      real_pc = start_sp;
+	/* NOTE: cagney/2003-04-22: This computation of REAL_PC,
+	   BP_ADDR and DUMMY_ADDR is pretty messed up.  It comes from
+	   constant tinkering with the values.  Instead a
+	   FIX_CALL_DUMMY replacement (PUSH_DUMMY_BREAKPOINT?) should
+	   just do everything.  */
+#ifdef GDB_TARGET_IS_HPPA
+	real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
+				  value_type, using_gcc);
+#else
+	if (FIX_CALL_DUMMY_P ())
+	  {
+	    /* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true?  */
+	    FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type,
+			    using_gcc);
+	  }
+	real_pc = start_sp;
 #endif
-      dummy_addr = start_sp;
-      /* Yes, the offset is applied to the real_pc and not the dummy
-         addr.  Ulgh!  Blame the HP/UX target.  */
-      bp_addr = real_pc + CALL_DUMMY_BREAKPOINT_OFFSET;
-      /* Yes, the offset is applied to the real_pc and not the
-         dummy_addr.  Ulgh!  Blame the HP/UX target.  */
-      real_pc += CALL_DUMMY_START_OFFSET;
-      write_memory (start_sp, (char *) dummy1, sizeof_dummy1);
-      if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
-	generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1);
-      break;
+	dummy_addr = start_sp;
+	/* Yes, the offset is applied to the real_pc and not the dummy
+	   addr.  Ulgh!  Blame the HP/UX target.  */
+	bp_addr = real_pc + CALL_DUMMY_BREAKPOINT_OFFSET;
+	/* Yes, the offset is applied to the real_pc and not the
+	   dummy_addr.  Ulgh!  Blame the HP/UX target.  */
+	real_pc += CALL_DUMMY_START_OFFSET;
+	write_memory (start_sp, (char *) dummy1, sizeof_dummy1);
+	if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
+	  generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1);
+	break;
+      }
     case AT_ENTRY_POINT:
       real_pc = funaddr;
       dummy_addr = CALL_DUMMY_ADDRESS ();

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