|
From: <sv...@va...> - 2005-11-05 00:17:23
|
Author: tom
Date: 2005-11-05 00:17:21 +0000 (Sat, 05 Nov 2005)
New Revision: 5012
Log:
Add a comment documenting the reason for subtracting one from the IP valu=
e
after each pass of the loop.
Modified:
trunk/coregrind/m_stacktrace.c
Modified: trunk/coregrind/m_stacktrace.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_stacktrace.c 2005-11-05 00:10:36 UTC (rev 5011)
+++ trunk/coregrind/m_stacktrace.c 2005-11-05 00:17:21 UTC (rev 5012)
@@ -110,6 +110,21 @@
ips[0] =3D ip;
i =3D 1;
=20
+ /* 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) {
=20
if (i >=3D n_ips)
|