unwind.inc (_Unwind_Backtrace): New function.
authorUlrich Weigand <uweigand@de.ibm.com>
Tue, 15 Apr 2003 16:24:18 +0000 (16:24 +0000)
committerUlrich Weigand <uweigand@gcc.gnu.org>
Tue, 15 Apr 2003 16:24:18 +0000 (16:24 +0000)
* unwind.inc (_Unwind_Backtrace): New function.
* unwind.h (_Unwind_Backtrace): Declare it.
* libgcc-std.ver (_Unwind_Backtrace): Export it.

From-SVN: r65641

gcc/ChangeLog
gcc/libgcc-std.ver
gcc/unwind.h
gcc/unwind.inc

index e2750ace4e5e92ee714e750e6d21234264ff0251..44572507ddf6a9ee416de66afb56ce5935914ef5 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-15  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * unwind.inc (_Unwind_Backtrace): New function.
+       * unwind.h (_Unwind_Backtrace): Declare it.
+       * libgcc-std.ver (_Unwind_Backtrace): Export it.
+
 2003-04-14  Jason Merrill  <jason@redhat.com>
 
        PR middle-end/10336, c++/10401
index 00c72c0c4af5c5ab87a2c95947f50934a3438df0..c8a1a8b83c9a843f3d9fd90f66fd80fd1ff9c207 100644 (file)
@@ -180,6 +180,7 @@ GCC_3.0 {
 GCC_3.3 {
   _Unwind_FindEnclosingFunction
   _Unwind_GetCFA
+  _Unwind_Backtrace
 }
 
 %inherit GCC_3.4 GCC_3.3
index 084eebfa8750f7c00cb704d0bca82348ed02792c..8f7a499330e92c86f483675821dfb7d43512c760 100644 (file)
@@ -127,6 +127,14 @@ extern void _Unwind_DeleteException (struct _Unwind_Exception *);
    e.g. executing cleanup code, and not to implement rethrowing.  */
 extern void _Unwind_Resume (struct _Unwind_Exception *);
 
+/* @@@ 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)
+     (struct _Unwind_Context *, void *);
+
+extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
+
 /* These functions are used for communicating information about the unwind
    context (i.e. the unwind descriptors and the user register state) between
    the unwind library and the personality routine and landing pad.  Only
index 0422cb81a03fd96b0d99d57cefd58e1634e7eaf4..225b046d37f825173dce392ad94e6353eddea90b 100644 (file)
@@ -239,3 +239,39 @@ _Unwind_DeleteException (struct _Unwind_Exception *exc)
 {
   (*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc);
 }
+
+
+/* Perform stack backtrace through unwind data.  */
+
+_Unwind_Reason_Code
+_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument)
+{
+  struct _Unwind_Context context;
+  _Unwind_Reason_Code code;
+
+  uw_init_context (&context);
+
+  while (1)
+    {
+      _Unwind_FrameState fs;
+
+      /* Set up fs to describe the FDE for the caller of context.  */
+      code = uw_frame_state_for (&context, &fs);
+      if (code != _URC_NO_REASON && code != _URC_END_OF_STACK)
+       return _URC_FATAL_PHASE1_ERROR;
+
+      /* Call trace function.  */
+      if ((*trace) (&context, trace_argument) != _URC_NO_REASON)
+       return _URC_FATAL_PHASE1_ERROR;
+
+      /* We're done at end of stack.  */       
+      if (code == _URC_END_OF_STACK)
+       break;
+
+      /* Update context to describe the same frame as fs.  */
+      uw_update_context (&context, &fs);
+    }
+
+  return code;
+}
+