|
75 | 75 | } \
|
76 | 76 | }
|
77 | 77 |
|
78 |
| - |
| 78 | +/* Note about calculation of fp_min : fp_min is the lowest address |
| 79 | + which can be accessed during unwinding. This is SP - VG_STACK_REDZONE_SZB. |
| 80 | + On most platforms, this will be equal to SP (as VG_STACK_REDZONE_SZB |
| 81 | + is 0). However, on some platforms (e.g. amd64), there is an accessible |
| 82 | + redzone below the SP. Some CFI unwind info are generated, taking this |
| 83 | + into account. As an example, the following is a CFI unwind info on |
| 84 | + amd64 found for a 'retq' instruction: |
| 85 | +[0x400f7e .. 0x400f7e]: let cfa=oldSP+8 in RA=*(cfa+-8) SP=cfa+0 BP=*(cfa+-16) |
| 86 | + 0x400f7e: retq |
| 87 | + As you can see, the previous BP is found 16 bytes below the cfa, which |
| 88 | + is the oldSP+8. So, effectively, the BP is found 8 bytes below the SP. |
| 89 | + The fp_min must take this into account, otherwise, VG_(use_CF_info) will |
| 90 | + not unwind the BP. */ |
| 91 | + |
79 | 92 | /* ------------------------ x86 ------------------------- */
|
80 | 93 |
|
81 | 94 | #if defined(VGP_x86_linux) || defined(VGP_x86_darwin)
|
@@ -196,7 +209,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
196 | 209 | uregs.xip = (Addr)startRegs->r_pc;
|
197 | 210 | uregs.xsp = (Addr)startRegs->r_sp;
|
198 | 211 | uregs.xbp = startRegs->misc.X86.r_ebp;
|
199 |
| - Addr fp_min = uregs.xsp; |
| 212 | + Addr fp_min = uregs.xsp - VG_STACK_REDZONE_SZB; |
200 | 213 |
|
201 | 214 | /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
|
202 | 215 | stopping when the trail goes cold, which we guess to be
|
@@ -479,7 +492,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
479 | 492 | uregs.xip = startRegs->r_pc;
|
480 | 493 | uregs.xsp = startRegs->r_sp;
|
481 | 494 | uregs.xbp = startRegs->misc.AMD64.r_rbp;
|
482 |
| - Addr fp_min = uregs.xsp; |
| 495 | + Addr fp_min = uregs.xsp - VG_STACK_REDZONE_SZB; |
483 | 496 |
|
484 | 497 | /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
|
485 | 498 | stopping when the trail goes cold, which we guess to be
|
@@ -682,7 +695,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
682 | 695 | # elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
|
683 | 696 | Addr lr = startRegs->misc.PPC64.r_lr;
|
684 | 697 | # endif
|
685 |
| - Addr fp_min = sp; |
| 698 | + Addr fp_min = sp - VG_STACK_REDZONE_SZB; |
686 | 699 |
|
687 | 700 | /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
|
688 | 701 | stopping when the trail goes cold, which we guess to be
|
@@ -947,7 +960,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
947 | 960 | uregs.r12 = startRegs->misc.ARM.r12;
|
948 | 961 | uregs.r11 = startRegs->misc.ARM.r11;
|
949 | 962 | uregs.r7 = startRegs->misc.ARM.r7;
|
950 |
| - Addr fp_min = uregs.r13; |
| 963 | + Addr fp_min = uregs.r13 - VG_STACK_REDZONE_SZB; |
951 | 964 |
|
952 | 965 | /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
|
953 | 966 | stopping when the trail goes cold, which we guess to be
|
@@ -1091,7 +1104,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
1091 | 1104 | uregs.sp = startRegs->r_sp;
|
1092 | 1105 | uregs.x30 = startRegs->misc.ARM64.x30;
|
1093 | 1106 | uregs.x29 = startRegs->misc.ARM64.x29;
|
1094 |
| - Addr fp_min = uregs.sp; |
| 1107 | + Addr fp_min = uregs.sp - VG_STACK_REDZONE_SZB; |
1095 | 1108 |
|
1096 | 1109 | /* Snaffle IPs from the client's stack into ips[0 .. max_n_ips-1],
|
1097 | 1110 | stopping when the trail goes cold, which we guess to be
|
@@ -1185,7 +1198,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
1185 | 1198 | D3UnwindRegs uregs;
|
1186 | 1199 | uregs.ia = startRegs->r_pc;
|
1187 | 1200 | uregs.sp = startRegs->r_sp;
|
1188 |
| - Addr fp_min = uregs.sp; |
| 1201 | + Addr fp_min = uregs.sp - VG_STACK_REDZONE_SZB; |
1189 | 1202 | uregs.fp = startRegs->misc.S390X.r_fp;
|
1190 | 1203 | uregs.lr = startRegs->misc.S390X.r_lr;
|
1191 | 1204 |
|
@@ -1268,7 +1281,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
1268 | 1281 | D3UnwindRegs uregs;
|
1269 | 1282 | uregs.pc = startRegs->r_pc;
|
1270 | 1283 | uregs.sp = startRegs->r_sp;
|
1271 |
| - Addr fp_min = uregs.sp; |
| 1284 | + Addr fp_min = uregs.sp - VG_STACK_REDZONE_SZB; |
1272 | 1285 |
|
1273 | 1286 | #if defined(VGP_mips32_linux)
|
1274 | 1287 | uregs.fp = startRegs->misc.MIPS32.r30;
|
@@ -1423,7 +1436,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
1423 | 1436 | D3UnwindRegs uregs;
|
1424 | 1437 | uregs.pc = startRegs->r_pc;
|
1425 | 1438 | uregs.sp = startRegs->r_sp;
|
1426 |
| - Addr fp_min = uregs.sp; |
| 1439 | + Addr fp_min = uregs.sp - VG_STACK_REDZONE_SZB; |
1427 | 1440 |
|
1428 | 1441 | uregs.fp = startRegs->misc.TILEGX.r52;
|
1429 | 1442 | uregs.lr = startRegs->misc.TILEGX.r55;
|
|
0 commit comments