summaryrefslogtreecommitdiff
path: root/gcc/unwind.inc
diff options
context:
space:
mode:
authoruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-15 16:24:18 +0000
committeruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-15 16:24:18 +0000
commit4f0ee6868cc65119671fbc281ba17f85d61c0f51 (patch)
tree90eeed59b90dd08a506965db65e9397ff6d450d4 /gcc/unwind.inc
parent5d0c931c899a823fcfcbcb70ae7ab1fead6c3691 (diff)
downloadgcc-4f0ee6868cc65119671fbc281ba17f85d61c0f51.tar.gz
* unwind.inc (_Unwind_Backtrace): New function.
* unwind.h (_Unwind_Backtrace): Declare it. * libgcc-std.ver (_Unwind_Backtrace): Export it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65641 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/unwind.inc')
-rw-r--r--gcc/unwind.inc36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/unwind.inc b/gcc/unwind.inc
index 0422cb81a03..225b046d37f 100644
--- a/gcc/unwind.inc
+++ b/gcc/unwind.inc
@@ -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;
+}
+