This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Fix dwarf unwinder on arm


The patch below fixes a latent bug in the dwarf unwinder, as described in
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg01652.html

This triggers when the throwing frame saves the stack pointer, but the 
catching frame doesn't. I was initially concerned that this may cause 
problems as some targets seem to save the stack pointer, but then ignore it 
in the function prologue. It seems that this dead store isn't instrumented in 
the frame information, so it works ok.

Tested on i686-linux, powerpc-linux and ia64-hp-hpux11.22
Ok?

Paul

2004-08-09  Paul Brook  <paul@codesourcery.com>
	Richard Henderson  <rth@redhat.com>

	* unwind-dw2.c (uw_install_context_1): Update target saved stack
	pointer.

Index: unwind-dw2.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/unwind-dw2.c,v
retrieving revision 1.42
diff -u -p -r1.42 unwind-dw2.c
--- unwind-dw2.c	1 Jul 2004 04:09:01 -0000	1.42
+++ unwind-dw2.c	17 Jul 2004 01:39:52 -0000
@@ -1274,6 +1274,12 @@ uw_install_context_1 (struct _Unwind_Con
 		      struct _Unwind_Context *target)
 {
   long i;
+  _Unwind_SpTmp sp_slot;
+
+  /* If the target frame does not have a saved stack pointer,
+     then set up the target's CFA.  */
+  if (!_Unwind_GetGRPtr (target, __builtin_dwarf_sp_column ()))
+	_Unwind_SetSpColumn (target, target->cfa, &sp_slot);
 
   for (i = 0; i < DWARF_FRAME_REGISTERS; ++i)
     {
@@ -1284,25 +1290,22 @@ uw_install_context_1 (struct _Unwind_Con
 	memcpy (c, t, dwarf_reg_size_table[i]);
     }
 
-#ifdef EH_RETURN_STACKADJ_RTX
-  {
-    void *target_cfa;
+  /* If the current frame doesn't have a saved stack pointer, then we
+     need to rely on EH_RETURN_STACKADJ_RTX to get our target stack
+     pointer value reloaded.  */
+  if (!_Unwind_GetGRPtr (current, __builtin_dwarf_sp_column ()))
+    {
+      void *target_cfa;
 
-    /* If the last frame records a saved stack pointer, use it.  */
-    if (_Unwind_GetGRPtr (target, __builtin_dwarf_sp_column ()))
       target_cfa = _Unwind_GetPtr (target, __builtin_dwarf_sp_column ());
-    else
-      target_cfa = target->cfa;
 
-    /* We adjust SP by the difference between CURRENT and TARGET's CFA.  */
-    if (STACK_GROWS_DOWNWARD)
-      return target_cfa - current->cfa + target->args_size;
-    else
-      return current->cfa - target_cfa - target->args_size;
-  }
-#else
+      /* We adjust SP by the difference between CURRENT and TARGET's CFA.  */
+      if (STACK_GROWS_DOWNWARD)
+	return target_cfa - current->cfa + target->args_size;
+      else
+	return current->cfa - target_cfa - target->args_size;
+    }
   return 0;
-#endif
 }
 
 static inline _Unwind_Ptr


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