Mark Wielaard c728a3
--- valgrind/coregrind/m_stacktrace.c.jj	2012-08-05 18:04:16.000000000 +0200
Mark Wielaard c728a3
+++ valgrind/coregrind/m_stacktrace.c	2012-08-10 12:13:46.069797051 +0200
Jakub Jelinek 707b2a
@@ -149,11 +149,23 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId
Jakub Jelinek 707b2a
       /* Try to derive a new (ip,sp,fp) triple from the current
Jakub Jelinek 707b2a
          set. */
Jakub Jelinek 707b2a
 
Jakub Jelinek 707b2a
-      /* On x86, first try the old-fashioned method of following the
Jakub Jelinek 707b2a
-         %ebp-chain.  Code which doesn't use this (that is, compiled
Jakub Jelinek 707b2a
-         with -fomit-frame-pointer) is not ABI compliant and so
Jakub Jelinek 707b2a
-         relatively rare.  Besides, trying the CFI first almost always
Jakub Jelinek 707b2a
-         fails, and is expensive. */
Jakub Jelinek 707b2a
+      /* On x86 GCC 4.6 and later now defaults to -fomit-frame-pointer
Jakub Jelinek 707b2a
+         together with emitting unwind info (-fasynchronous-unwind-tables).
Jakub Jelinek 707b2a
+         So, try CF info first.  */
Jakub Jelinek 707b2a
+      if ( VG_(use_CF_info)( &uregs, fp_min, fp_max ) ) {
Jakub Jelinek 707b2a
+         if (0 == uregs.xip || 1 == uregs.xip) break;
Jakub Jelinek 707b2a
+         if (sps) sps[i] = uregs.xsp;
Jakub Jelinek 707b2a
+         if (fps) fps[i] = uregs.xbp;
Jakub Jelinek 707b2a
+         ips[i++] = uregs.xip - 1; /* -1: refer to calling insn, not the RA */
Jakub Jelinek 707b2a
+         if (debug)
Jakub Jelinek 707b2a
+            VG_(printf)("     ipsC[%d]=0x%08lx\n", i-1, ips[i-1]);
Jakub Jelinek 707b2a
+         uregs.xip = uregs.xip - 1;
Jakub Jelinek 707b2a
+            /* as per comment at the head of this loop */
Jakub Jelinek 707b2a
+         continue;
Jakub Jelinek 707b2a
+      }
Jakub Jelinek 707b2a
+
Jakub Jelinek 707b2a
+      /* And only then the old-fashioned method of following the
Jakub Jelinek 707b2a
+         %ebp-chain.  */
Jakub Jelinek 707b2a
       /* Deal with frames resulting from functions which begin "pushl%
Jakub Jelinek 707b2a
          ebp ; movl %esp, %ebp" which is the ABI-mandated preamble. */
Jakub Jelinek 707b2a
       if (fp_min <= uregs.xbp &&
Jakub Jelinek 707b2a
@@ -179,20 +191,6 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId
Jakub Jelinek 707b2a
          uregs.xip = uregs.xip - 1;
Jakub Jelinek 707b2a
             /* as per comment at the head of this loop */
Jakub Jelinek 707b2a
          continue;
Jakub Jelinek 707b2a
-      }
Jakub Jelinek 707b2a
-
Jakub Jelinek 707b2a
-      /* That didn't work out, so see if there is any CF info to hand
Jakub Jelinek 707b2a
-         which can be used. */
Jakub Jelinek 707b2a
-      if ( VG_(use_CF_info)( &uregs, fp_min, fp_max ) ) {
Jakub Jelinek 707b2a
-         if (0 == uregs.xip || 1 == uregs.xip) break;
Jakub Jelinek 707b2a
-         if (sps) sps[i] = uregs.xsp;
Jakub Jelinek 707b2a
-         if (fps) fps[i] = uregs.xbp;
Jakub Jelinek 707b2a
-         ips[i++] = uregs.xip - 1; /* -1: refer to calling insn, not the RA */
Jakub Jelinek 707b2a
-         if (debug)
Jakub Jelinek 707b2a
-            VG_(printf)("     ipsC[%d]=0x%08lx\n", i-1, ips[i-1]);
Jakub Jelinek 707b2a
-         uregs.xip = uregs.xip - 1;
Jakub Jelinek 707b2a
-            /* as per comment at the head of this loop */
Jakub Jelinek 707b2a
-         continue;
Jakub Jelinek 707b2a
       }
Jakub Jelinek 707b2a
 
Jakub Jelinek 707b2a
       /* And, similarly, try for MSVC FPO unwind info. */