From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23817 invoked by alias); 18 Oct 2011 19:20:27 -0000 Received: (qmail 23805 invoked by uid 22791); 18 Oct 2011 19:20:26 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_RB X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Oct 2011 19:20:11 +0000 From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/50678] [4.7 Regression] FAIL: c52104y on x86_64-apple-darwin10 Date: Tue, 18 Oct 2011 19:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: iains at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg01860.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50678 --- Comment #50 from Iain Sandoe 2011-10-18 19:18:38 UTC --- well I've hit a few issues. 1. _Unwind_Find_FDE is not part of the public interface (nor are the types it needs). 2. if the vendor decides to 'fix' libunwind .. we won't detect this ... (although I still think this idea is worth pursuing, on the grounds that 'no fix' or a fix to Libc are more likely). 3. _Unwind_Find_FDE is returning NULL in the following proof-of-concept hack.. .. not having any joy debugging this from the c++ case (maybe have to try a newer debugger).. (have to do some other things for a while - but if you can spot my obvious mistake .. then let me know). #if defined (__x86_64__) /* Work around radar #10302855/pr50678, where the unwinders (libunwind or libgcc_s depending on the system revision) and the DWARF unwind data for the sigtramp have different ideas about register numbering (causing rbx and rdx to be transposed). */ #define DX86FIX_CHECKED 0x01 #define DX86FIX_DOFIXUP 0x02 struct dwarf_eh_bases { void *tbase; void *dbase; void *func; }; typedef int sword __attribute__ ((mode (SI))); typedef unsigned int uword __attribute__ ((mode (SI))); struct dwarf_fde { uword length; sword CIE_delta; unsigned char pc_begin[]; } __attribute__ ((packed, aligned (__alignof__ (void *)))); extern struct dwarf_fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *); static void __gnat_darwin_maybe_fixup_unwind_context (ucontext_t *uc, void *ad) { static unsigned need_fixup = 0; /* Look for the FDE for the sig tramp. */ if ((need_fixup & DX86FIX_CHECKED) == 0) { struct dwarf_eh_bases bases; const struct dwarf_fde *myfde = _Unwind_Find_FDE (ad, &bases); if (myfde == NULL) need_fixup |= DX86FIX_DOFIXUP; /* We're likely broken. */ else { unsigned MCONTEXT_SS_RBX, MCONTEXT_SS_RDX, ts; /* These are the offsets for the registers. */ ts = __builtin_offsetof (_STRUCT_MCONTEXT,__ss); MCONTEXT_SS_RBX = __builtin_offsetof (_STRUCT_X86_THREAD_STATE64,__rbx); MCONTEXT_SS_RBX += ts; MCONTEXT_SS_RDX = __builtin_offsetof (_STRUCT_X86_THREAD_STATE64,__rdx); MCONTEXT_SS_RDX += ts; // UNFINISHED } need_fixup |= DX86FIX_CHECKED; } if (need_fixup & DX86FIX_DOFIXUP) { unsigned long t = uc->uc_mcontext->__ss.__rbx; uc->uc_mcontext->__ss.__rbx = uc->uc_mcontext->__ss.__rdx; uc->uc_mcontext->__ss.__rdx = t; } } #endif static void __gnat_error_handler (int sig, siginfo_t *si, void *ucontext) { struct Exception_Data *exception; const char *msg; #if defined (__x86_64__) /* We pass the address from here so that we don't need to worry about inlining. */ __gnat_darwin_maybe_fixup_unwind_context ((ucontext_t *)ucontext, __builtin_return_address (0)); #endif