public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: RFA: Unwind_Backtrace for ARM EABI
@ 2007-08-29  8:58 Nick Clifton
  2007-08-29 10:04 ` Andrew Haley
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2007-08-29  8:58 UTC (permalink / raw)
  To: gcc-patches, aph

Hi Andrew,

> As discussed, this implements the missing Unwind_Backtrace for ARM
> EABI.

Was the code tested ?  If so, how ?

> OK for trunk?

Approved, but I would recommend one small change:  You could replace
the "goto finish" statements with "break" and then drop the finish
label altogether.  Gotos being considered dangerous and all that...

Cheers
  Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: Unwind_Backtrace for ARM EABI
  2007-08-29  8:58 RFA: Unwind_Backtrace for ARM EABI Nick Clifton
@ 2007-08-29 10:04 ` Andrew Haley
  2007-08-29 17:26   ` Andrew Haley
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Haley @ 2007-08-29 10:04 UTC (permalink / raw)
  To: Nick Clifton; +Cc: gcc-patches

Nick Clifton writes:
 > Hi Andrew,
 > 
 > > As discussed, this implements the missing Unwind_Backtrace for ARM
 > > EABI.
 > 
 > Was the code tested ?  If so, how ?

Extensively with the libgcj testsuite.  Java uses backtraces a lot, so
this gives Unwind_Backtrace a thorough workout.

 > > OK for trunk?
 > 
 > Approved, but I would recommend one small change:  You could replace
 > the "goto finish" statements with "break" and then drop the finish
 > label altogether.  Gotos being considered dangerous and all that...

Heh.  Nanny!  OK.  ;-)

Andrew.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: Unwind_Backtrace for ARM EABI
  2007-08-29 10:04 ` Andrew Haley
@ 2007-08-29 17:26   ` Andrew Haley
  2007-08-30 12:26     ` Nick Clifton
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Haley @ 2007-08-29 17:26 UTC (permalink / raw)
  To: Nick Clifton, gcc-patches

Jakub pointer out that we wer missing version info for
_Unwind_Backtrace.  After relinking the tests still work, so is this
OK for trunk?

Andrew.


2007-08-29  Andrew Haley  <aph@redhat.com>

        * config/arm/libgcc-bpabi.ver: Add _Unwind_Backtrace as GCC_4.3.0.

Index: config/arm/libgcc-bpabi.ver
===================================================================
--- config/arm/libgcc-bpabi.ver (revision 126985)
+++ config/arm/libgcc-bpabi.ver (working copy)
@@ -81,3 +81,10 @@
   # GNU-specific entry point.
   __gnu_unwind_frame
 }
+
+%exclude {
+  _Unwind_Backtrace
+}
+GCC_4.3.0 {
+  _Unwind_Backtrace
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: Unwind_Backtrace for ARM EABI
  2007-08-29 17:26   ` Andrew Haley
@ 2007-08-30 12:26     ` Nick Clifton
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2007-08-30 12:26 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-patches

Hi Andrew,

> 2007-08-29  Andrew Haley  <aph@redhat.com>
> 
>         * config/arm/libgcc-bpabi.ver: Add _Unwind_Backtrace as GCC_4.3.0.

Approved.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RFA: Unwind_Backtrace for ARM EABI
@ 2007-08-21 19:12 Andrew Haley
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Haley @ 2007-08-21 19:12 UTC (permalink / raw)
  To: gcc-patches

As discussed, this implements the missing Unwind_Backtrace for ARM
EABI.

OK for trunk?

Andrew.


2007-08-17  Andrew Haley  <aph@redhat.com>

        * config/arm/libunwind.S (UNWIND_WRAPPER _Unwind_Backtrace): New.
        * config/arm/unwind-arm.h (__gnu_Unwind_Backtrace): New.
        * config/arm/unwind-arm.c (__gnu_Unwind_Backtrace): New.

Index: config/arm/libunwind.S
===================================================================
--- config/arm/libunwind.S	(revision 126979)
+++ config/arm/libunwind.S	(working copy)
@@ -237,5 +237,6 @@
 UNWIND_WRAPPER _Unwind_Resume 1
 UNWIND_WRAPPER _Unwind_Resume_or_Rethrow 1
 UNWIND_WRAPPER _Unwind_ForcedUnwind 3
+UNWIND_WRAPPER _Unwind_Backtrace 2
 
-#endif  /* __symbian__ */
+#endif  /* ndef __symbian__ */
Index: config/arm/unwind-arm.c
===================================================================
--- config/arm/unwind-arm.c	(revision 126979)
+++ config/arm/unwind-arm.c	(working copy)
@@ -950,6 +950,66 @@
 }
 
 
+/* Perform stack backtrace through unwind data.  */
+_Unwind_Reason_Code
+__gnu_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument,
+		       phase2_vrs * entry_vrs);
+_Unwind_Reason_Code
+__gnu_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument,
+		       phase2_vrs * entry_vrs)
+{
+  phase1_vrs saved_vrs;
+  _Unwind_Reason_Code code;
+
+  _Unwind_Control_Block ucb;
+  _Unwind_Control_Block *ucbp = &ucb;
+
+  /* Set the pc to the call site.  */
+  entry_vrs->core.r[R_PC] = entry_vrs->core.r[R_LR];
+
+  /* Save the core registers.  */
+  saved_vrs.core = entry_vrs->core;
+  /* Set demand-save flags.  */
+  saved_vrs.demand_save_flags = ~(_uw) 0;
+  
+  do
+    {
+      /* Find the entry for this routine.  */
+      if (get_eit_entry (ucbp, saved_vrs.core.r[R_PC]) != _URC_OK)
+	{
+	  code = _URC_FAILURE;
+	  goto finish;
+	}
+
+      /* The dwarf unwinder assumes the context structure holds things
+	 like the function and LSDA pointers.  The ARM implementation
+	 caches these in the exception header (UCB).  To avoid
+	 rewriting everything we make the virtual IP register point at
+	 the UCB.  */
+      _Unwind_SetGR((_Unwind_Context *)&saved_vrs, 12, (_Unwind_Ptr) ucbp);
+
+      /* Call trace function.  */
+      if ((*trace) ((_Unwind_Context *) &saved_vrs, trace_argument) 
+	  != _URC_NO_REASON)
+	{
+	  code = _URC_FAILURE;
+	  goto finish;
+	}
+
+      /* Call the pr to decide what to do.  */
+      code = ((personality_routine) UCB_PR_ADDR (ucbp))
+	(_US_VIRTUAL_UNWIND_FRAME | _US_FORCE_UNWIND, 
+	 ucbp, (void *) &saved_vrs);
+    }
+  while (code != _URC_END_OF_STACK
+	 && code != _URC_FAILURE);
+
+ finish:
+  restore_non_core_regs (&saved_vrs);
+  return code;
+}
+
+
 /* Common implementation for ARM ABI defined personality routines.
    ID is the index of the personality routine, other arguments are as defined
    by __aeabi_unwind_cpp_pr{0,1,2}.  */
Index: config/arm/unwind-arm.h
===================================================================
--- config/arm/unwind-arm.h	(revision 126979)
+++ config/arm/unwind-arm.h	(working copy)
@@ -205,6 +205,13 @@
 	_Unwind_Control_Block *, struct _Unwind_Context *, void *);
   _Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
 					    _Unwind_Stop_Fn, void *);
+  /* @@@ Use unwind data to perform a stack backtrace.  The trace callback
+     is called for every stack frame in the call chain, but no cleanup
+     actions are performed.  */
+  typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (_Unwind_Context *, void *);
+  _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn,
+					void*);
+
   _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
   void _Unwind_Complete(_Unwind_Control_Block *ucbp);
   void _Unwind_DeleteException (_Unwind_Exception *);

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-30 12:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-29  8:58 RFA: Unwind_Backtrace for ARM EABI Nick Clifton
2007-08-29 10:04 ` Andrew Haley
2007-08-29 17:26   ` Andrew Haley
2007-08-30 12:26     ` Nick Clifton
  -- strict thread matches above, loose matches on Subject: below --
2007-08-21 19:12 Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).