|
From: <sv...@va...> - 2011-02-14 11:11:02
|
Author: sewardj
Date: 2011-02-14 11:10:53 +0000 (Mon, 14 Feb 2011)
New Revision: 11554
Log:
Merge from trunk, r11523 and r11524 (fixes for #246152, segfault on
pthread_cancel)
Modified:
branches/VALGRIND_3_6_BRANCH/callgrind/bbcc.c
branches/VALGRIND_3_6_BRANCH/callgrind/callstack.c
branches/VALGRIND_3_6_BRANCH/callgrind/global.h
branches/VALGRIND_3_6_BRANCH/callgrind/jumps.c
Modified: branches/VALGRIND_3_6_BRANCH/callgrind/bbcc.c
===================================================================
--- branches/VALGRIND_3_6_BRANCH/callgrind/bbcc.c 2011-02-14 11:05:57 UTC (rev 11553)
+++ branches/VALGRIND_3_6_BRANCH/callgrind/bbcc.c 2011-02-14 11:10:53 UTC (rev 11554)
@@ -741,7 +741,11 @@
}
}
else {
- CLG_(unwind_call_stack)(sp, 0);
+ Int unwind_count = CLG_(unwind_call_stack)(sp, 0);
+ if (unwind_count > 0) {
+ /* if unwinding was done, this actually is a return */
+ jmpkind = Ijk_Ret;
+ }
if (jmpkind == Ijk_Call) {
delayed_push = True;
Modified: branches/VALGRIND_3_6_BRANCH/callgrind/callstack.c
===================================================================
--- branches/VALGRIND_3_6_BRANCH/callgrind/callstack.c 2011-02-14 11:05:57 UTC (rev 11553)
+++ branches/VALGRIND_3_6_BRANCH/callgrind/callstack.c 2011-02-14 11:10:53 UTC (rev 11554)
@@ -394,11 +394,13 @@
}
-/* remove CallStack items to sync with current SP
+/* Unwind enough CallStack items to sync with current stack pointer.
+ * Returns the number of stack frames unwinded.
*/
-void CLG_(unwind_call_stack)(Addr sp, Int minpops)
+Int CLG_(unwind_call_stack)(Addr sp, Int minpops)
{
Int csp;
+ Int unwind_count = 0;
CLG_DEBUG(4,"+ unwind_call_stack(sp %#lx, minpops %d): frame %d\n",
sp, minpops, CLG_(current_call_stack).sp);
@@ -415,6 +417,7 @@
((top_ce->sp == sp) && minpops>0)) {
minpops--;
+ unwind_count++;
CLG_(pop_call_stack)();
csp=CLG_(current_call_stack).sp;
continue;
@@ -423,4 +426,5 @@
}
CLG_DEBUG(4,"- unwind_call_stack\n");
+ return unwind_count;
}
Modified: branches/VALGRIND_3_6_BRANCH/callgrind/global.h
===================================================================
--- branches/VALGRIND_3_6_BRANCH/callgrind/global.h 2011-02-14 11:05:57 UTC (rev 11553)
+++ branches/VALGRIND_3_6_BRANCH/callgrind/global.h 2011-02-14 11:10:53 UTC (rev 11554)
@@ -779,7 +779,7 @@
void CLG_(push_call_stack)(BBCC* from, UInt jmp, BBCC* to, Addr sp, Bool skip);
void CLG_(pop_call_stack)(void);
-void CLG_(unwind_call_stack)(Addr sp, Int);
+Int CLG_(unwind_call_stack)(Addr sp, Int);
/* from context.c */
void CLG_(init_fn_stack)(fn_stack*);
Modified: branches/VALGRIND_3_6_BRANCH/callgrind/jumps.c
===================================================================
--- branches/VALGRIND_3_6_BRANCH/callgrind/jumps.c 2011-02-14 11:05:57 UTC (rev 11553)
+++ branches/VALGRIND_3_6_BRANCH/callgrind/jumps.c 2011-02-14 11:10:53 UTC (rev 11554)
@@ -160,6 +160,8 @@
* This list is only used at dumping time */
if (from) {
+ /* Prohibit corruption by array overrun */
+ CLG_ASSERT((0 <= jmp) && (jmp <= from->bb->cjmp_count));
jcc->next_from = from->jmp[jmp].jcc_list;
from->jmp[jmp].jcc_list = jcc;
}
|