Skip to content

Commit bcfb4c9

Browse files
committed
fix(callgrind): drop BBCCs whose top context fn is skip-flagged
When the (cxt == 0) clause in setup_bbcc force-pushes a skipped fn — e.g. the first BB after CALLGRIND_START_INSTRUMENTATION lives in a skipped object — the BBCC ends up with cxt->fn[0]->skip == True. Without filtering, those BBCCs emit a top-level fn= block and the skipped fn leaks into the dump. Filter them out at dump time in print_bbccs_of_thread, right before print_fn_pos would emit the ob=/fl=/fn= header. The call edges from non-skipped callers into skipped fns (cfn=) are unaffected because they're emitted from the caller's BBCC, whose context is not skipped. Also broadens the runtime_obj_skip_c post-check to grep for any fn=skipme*, since the actual leaked fn in the repro is skipme_run (the one calling START_INSTRUMENTATION), not skipme_func.
1 parent 731dc7d commit bcfb4c9

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

callgrind/dump.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,17 @@ static void print_bbccs_of_thread(thread_info* ti)
15531553
}
15541554

15551555
if (*p == 0) break;
1556-
1556+
1557+
/* Don't emit BBCCs whose top context fn is flagged for obj-skip.
1558+
* This happens when the (cxt == 0) clause in setup_bbcc force-
1559+
* pushes a skipped fn (first BB after instrumentation start that
1560+
* landed in a skipped object). Without this filter the skipped fn
1561+
* leaks into the dump as a top-level fn= block. */
1562+
if ((*p)->cxt->fn[0]->skip) {
1563+
p++;
1564+
continue;
1565+
}
1566+
15571567
if (print_fn_pos(print_fp, &lastFnPos, *p)) {
15581568

15591569
/* new function */
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
prereq: test -f runtime_obj_skip_c && test -f runtime_obj_skip_c_lib.so
22
prog-asis: ./runtime_obj_skip_c
33
vgopts: --instr-atstart=no --compress-strings=no --callgrind-out-file=callgrind.out.runtime_obj_skip_c
4-
post: sh -c 'if grep -q "^fn=skipme_func" callgrind.out.runtime_obj_skip_c; then echo "FAIL: skipme_func leaked into top-level fn= block"; else echo OK; fi'
4+
post: sh -c 'if grep -q "^fn=skipme" callgrind.out.runtime_obj_skip_c; then echo "FAIL: skipme_* leaked into top-level fn= block"; else echo OK; fi'
55
cleanup: rm -f callgrind.out.runtime_obj_skip_c

0 commit comments

Comments
 (0)