]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a comment documenting the reason for subtracting one from the IP value
authorTom Hughes <tom@compton.nu>
Sat, 5 Nov 2005 00:17:21 +0000 (00:17 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 5 Nov 2005 00:17:21 +0000 (00:17 +0000)
after each pass of the loop.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5012

coregrind/m_stacktrace.c

index 62b83c29da0e977f8039237483a17dd1b0f6b28b..c14b57e34787f3e3c221235fcbd6e964ae9d192c 100644 (file)
@@ -110,6 +110,21 @@ UInt VG_(get_StackTrace2) ( Addr* ips, UInt n_ips,
    ips[0] = ip;
    i = 1;
 
+   /* Loop unwinding the stack. Note that the IP value we get on
+    * each pass (whether from CFI info or a stack frame) is a
+    * return address so is actually after the calling instruction
+    * in the calling function.
+    *
+    * Because of this we subtract one from the IP after each pass
+    * of the loop so that we find the right CFI block on the next
+    * pass - otherwise we can find the wrong CFI info if it happens
+    * to change after the calling instruction and that will mean
+    * that we will fail to unwind the next step.
+    *
+    * This most frequently happens at the end of a function when
+    * a tail call occurs and we wind up using the CFI info for the
+    * next function which is completely wrong.
+    */
    while (True) {
 
       if (i >= n_ips)