From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30549 invoked by alias); 21 Aug 2007 19:09:36 -0000 Received: (qmail 30429 invoked by uid 22791); 21 Aug 2007 19:09:35 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 21 Aug 2007 19:09:28 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.1/8.13.1) with ESMTP id l7LJ9Nhh031295 for ; Tue, 21 Aug 2007 15:09:26 -0400 Received: from zebedee.littlepinkcloud.COM (vpn-14-63.rdu.redhat.com [10.11.14.63]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l7LJ9MsG027945 for ; Tue, 21 Aug 2007 15:09:22 -0400 Received: from littlepinkcloud.COM (localhost.localdomain [127.0.0.1]) by zebedee.littlepinkcloud.COM (8.13.8/8.13.5) with ESMTP id l7LJ9K0R027305 for ; Tue, 21 Aug 2007 20:09:21 +0100 Received: (from aph@localhost) by littlepinkcloud.COM (8.13.8/8.13.5/Submit) id l7LJ9KHj027302; Tue, 21 Aug 2007 20:09:20 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18123.14432.577930.350445@zebedee.pink> Date: Tue, 21 Aug 2007 19:12:00 -0000 From: Andrew Haley To: gcc-patches@gcc.gnu.org Subject: RFA: Unwind_Backtrace for ARM EABI X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-08/txt/msg01389.txt.bz2 As discussed, this implements the missing Unwind_Backtrace for ARM EABI. OK for trunk? Andrew. 2007-08-17 Andrew Haley * 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