Blame SOURCES/valgrind-3.10.1-cfi-redzone.patch

2601b6
commit 41d3053e27e5be8f5d3f7e6f2880e046b43387be
2601b6
Author: philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9>
2601b6
Date:   Thu Jun 4 19:44:47 2015 +0000
2601b6
2601b6
    On platforms that have an accessible redzone below the SP, the unwind logic
2601b6
    should be able to access the redzone.
2601b6
    So, when computing fp_min, substract the redzone.
2601b6
    Currently, only amd64 and ppc64 have a non 0 redzone.
2601b6
    
2601b6
    Regtested on amd64 and ppc64le, no regression.
2601b6
    
2601b6
    
2601b6
    
2601b6
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15309 a5019735-40e9-0310-863c-91ae7b9d1cf9
2601b6
2601b6
--- valgrind-3.10.1/coregrind/m_stacktrace.c.orig	2014-11-25 20:41:21.000000000 +0100
2601b6
+++ valgrind-3.10.1/coregrind/m_stacktrace.c	2015-06-07 16:20:31.962739322 +0200
2601b6
@@ -76,7 +76,20 @@
2601b6
    }                                                            \
2601b6
 }
2601b6
 
2601b6
-
2601b6
+/* Note about calculation of fp_min : fp_min is the lowest address
2601b6
+   which can be accessed during unwinding. This is SP - VG_STACK_REDZONE_SZB.
2601b6
+   On most platforms, this will be equal to SP (as VG_STACK_REDZONE_SZB
2601b6
+   is 0). However, on some platforms (e.g. amd64), there is an accessible
2601b6
+   redzone below the SP. Some CFI unwind info are generated, taking this
2601b6
+   into account. As an example, the following is a CFI unwind info on
2601b6
+   amd64 found for a 'retq' instruction:
2601b6
+[0x400f7e .. 0x400f7e]: let cfa=oldSP+8 in RA=*(cfa+-8) SP=cfa+0 BP=*(cfa+-16)
2601b6
+  0x400f7e: retq
2601b6
+  As you can see, the previous BP is found 16 bytes below the cfa, which
2601b6
+  is the oldSP+8. So, effectively, the BP is found 8 bytes below the SP.
2601b6
+  The fp_min must take this into account, otherwise, VG_(use_CF_info) will
2601b6
+  not unwind the BP. */
2601b6
+   
2601b6
 /* ------------------------ x86 ------------------------- */
2601b6
 
2601b6
 #if defined(VGP_x86_linux) || defined(VGP_x86_darwin)
2601b6
@@ -192,7 +205,7 @@
2601b6
    uregs.xip = (Addr)startRegs->r_pc;
2601b6
    uregs.xsp = (Addr)startRegs->r_sp;
2601b6
    uregs.xbp = startRegs->misc.X86.r_ebp;
2601b6
-   Addr fp_min = uregs.xsp;
2601b6
+   Addr fp_min = uregs.xsp - VG_STACK_REDZONE_SZB;
2601b6
 
2601b6
    /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
2601b6
       stopping when the trail goes cold, which we guess to be
2601b6
@@ -473,7 +486,7 @@
2601b6
    uregs.xip = startRegs->r_pc;
2601b6
    uregs.xsp = startRegs->r_sp;
2601b6
    uregs.xbp = startRegs->misc.AMD64.r_rbp;
2601b6
-   Addr fp_min = uregs.xsp;
2601b6
+   Addr fp_min = uregs.xsp - VG_STACK_REDZONE_SZB;
2601b6
 
2601b6
    /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
2601b6
       stopping when the trail goes cold, which we guess to be
2601b6
@@ -654,7 +667,7 @@
2601b6
 #  elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
2601b6
    Addr lr = startRegs->misc.PPC64.r_lr;
2601b6
 #  endif
2601b6
-   Addr fp_min = sp;
2601b6
+   Addr fp_min = sp - VG_STACK_REDZONE_SZB;
2601b6
 
2601b6
    /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
2601b6
       stopping when the trail goes cold, which we guess to be
2601b6
@@ -917,7 +930,7 @@
2601b6
    uregs.r12 = startRegs->misc.ARM.r12;
2601b6
    uregs.r11 = startRegs->misc.ARM.r11;
2601b6
    uregs.r7  = startRegs->misc.ARM.r7;
2601b6
-   Addr fp_min = uregs.r13;
2601b6
+   Addr fp_min = uregs.r13 - VG_STACK_REDZONE_SZB;
2601b6
 
2601b6
    /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
2601b6
       stopping when the trail goes cold, which we guess to be
2601b6
@@ -1061,7 +1074,7 @@
2601b6
    uregs.sp = startRegs->r_sp;
2601b6
    uregs.x30 = startRegs->misc.ARM64.x30;
2601b6
    uregs.x29 = startRegs->misc.ARM64.x29;
2601b6
-   Addr fp_min = uregs.sp;
2601b6
+   Addr fp_min = uregs.sp - VG_STACK_REDZONE_SZB;
2601b6
 
2601b6
    /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
2601b6
       stopping when the trail goes cold, which we guess to be
2601b6
@@ -1155,7 +1168,7 @@
2601b6
    D3UnwindRegs uregs;
2601b6
    uregs.ia = startRegs->r_pc;
2601b6
    uregs.sp = startRegs->r_sp;
2601b6
-   Addr fp_min = uregs.sp;
2601b6
+   Addr fp_min = uregs.sp - VG_STACK_REDZONE_SZB;
2601b6
    uregs.fp = startRegs->misc.S390X.r_fp;
2601b6
    uregs.lr = startRegs->misc.S390X.r_lr;
2601b6
 
2601b6
@@ -1238,7 +1251,7 @@
2601b6
    D3UnwindRegs uregs;
2601b6
    uregs.pc = startRegs->r_pc;
2601b6
    uregs.sp = startRegs->r_sp;
2601b6
-   Addr fp_min = uregs.sp;
2601b6
+   Addr fp_min = uregs.sp - VG_STACK_REDZONE_SZB;
2601b6
 
2601b6
 #if defined(VGP_mips32_linux)
2601b6
    uregs.fp = startRegs->misc.MIPS32.r30;