Skip to content

Commit 3934032

Browse files
committed
chore(callgrind): log underflow resets and instrument_state transitions
Two diagnostic logs to attribute every (cxt==0) push_cxt event to its root cause: 1. handleUnderflow: prints the BB address, fn name, obj, and skip flag for the fn that's about to be force-pushed after a call-stack underflow. Tells us whether leaks are driven by signals, longjmp, or shadow-stack quality. 2. set_instrument_state: logs every ON/OFF transition with the cxt and fn-stack depth at that moment. Distinguishes 'fresh start with no cxt' from 'stop/start cycle that preserved cxt'. Together with the existing 'push_cxt FORCED' log, these let us bucket the leaked frames in real Python runs by their root cause.
1 parent ece679d commit 3934032

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

callgrind/bbcc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ static void handleUnderflow(BB* bb)
513513
CLG_(current_fn_stack).top--;
514514
CLG_(current_state).cxt = 0;
515515
caller = CLG_(get_fn_node)(bb);
516+
VG_(message)(Vg_UserMsg,
517+
"underflow reset: cxt=0, BB=%#lx, fn-about-to-push='%s' "
518+
"obj='%s' skip=%d\n",
519+
bb_addr(bb), caller->name,
520+
caller->file->obj->name, caller->skip);
516521
CLG_(push_cxt)( caller );
517522

518523
if (!seen_before) {

callgrind/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,13 @@ void CLG_(set_instrument_state)(const HChar* reason, Bool state)
14531453
reason, state ? "ON" : "OFF");
14541454
return;
14551455
}
1456+
VG_(message)(Vg_UserMsg,
1457+
"instrument_state -> %s (reason='%s', cxt=%p, "
1458+
"fn_stack_depth=%ld)\n",
1459+
state ? "ON" : "OFF", reason,
1460+
(void*)CLG_(current_state).cxt,
1461+
(long)(CLG_(current_fn_stack).top -
1462+
CLG_(current_fn_stack).bottom));
14561463
CLG_(instrument_state) = state;
14571464
CLG_DEBUG(2, "%s: Switching instrumentation %s ...\n",
14581465
reason, state ? "ON" : "OFF");

0 commit comments

Comments
 (0)