Skip to content

Commit 81689f2

Browse files
committed
chore(callgrind): dump per-fn skip state for python objects at dump time
Adds CLG_(dump_python_fn_summary) and calls it from dump_profile. For each fn_node whose obj name contains 'python', prints the fn name, obj path, skip flag, and obj_skip_checked flag, with a final tally. Lets us see, per dump, whether interpreter fns ever had their skip check run.
1 parent a5687f9 commit 81689f2

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

callgrind/dump.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,8 @@ void CLG_(dump_profile)(const HChar* trigger, Bool only_current_thread)
16361636

16371637
print_bbccs(trigger, only_current_thread);
16381638

1639+
CLG_(dump_python_fn_summary)();
1640+
16391641
bbs_done = CLG_(stat).bb_executions++;
16401642

16411643
if (VG_(clo_verbosity) > 1)

callgrind/fn.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,44 @@ void CLG_(count_obj_skip_checked_fns)(Int* checked, Int* skipped)
327327
}
328328
}
329329

330+
static Bool name_contains(const HChar* hay, const HChar* needle)
331+
{
332+
if (!hay || !needle) return False;
333+
Int hlen = VG_(strlen)(hay), nlen = VG_(strlen)(needle);
334+
for (Int i = 0; i + nlen <= hlen; i++)
335+
if (VG_(strncmp)(hay + i, needle, nlen) == 0) return True;
336+
return False;
337+
}
338+
339+
void CLG_(dump_python_fn_summary)(void)
340+
{
341+
Int total = 0, checked = 0, skipped = 0;
342+
VG_(message)(Vg_UserMsg, "=== python fn summary (dump) ===\n");
343+
for (Int i = 0; i < N_OBJ_ENTRIES; i++) {
344+
for (obj_node* obj = obj_table[i]; obj != NULL; obj = obj->next) {
345+
if (!name_contains(obj->name, "python")) continue;
346+
for (Int f = 0; f < N_FILE_ENTRIES; f++) {
347+
for (file_node* file = obj->files[f]; file != NULL; file = file->next) {
348+
for (Int n = 0; n < N_FN_ENTRIES; n++) {
349+
for (fn_node* fn = file->fns[n]; fn != NULL; fn = fn->next) {
350+
total++;
351+
if (fn->obj_skip_checked) checked++;
352+
if (fn->skip) skipped++;
353+
VG_(message)(Vg_UserMsg,
354+
" fn='%s' obj='%s' skip=%d checked=%d\n",
355+
fn->name, obj->name,
356+
fn->skip, fn->obj_skip_checked);
357+
}
358+
}
359+
}
360+
}
361+
}
362+
}
363+
VG_(message)(Vg_UserMsg,
364+
"=== python fn summary: total=%d checked=%d skipped=%d ===\n",
365+
total, checked, skipped);
366+
}
367+
330368
#define HASH_CONSTANT 256
331369

332370
static UInt str_hash(const HChar *s, UInt table_size)

callgrind/global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ UInt* CLG_(get_fn_entry)(Int n);
724724

725725
void CLG_(init_obj_table)(void);
726726
void CLG_(count_obj_skip_checked_fns)(Int* checked, Int* skipped);
727+
void CLG_(dump_python_fn_summary)(void);
727728
obj_node* CLG_(get_obj_node)(DebugInfo* si);
728729
file_node* CLG_(get_file_node)(obj_node*, const HChar *dirname,
729730
const HChar* filename);

0 commit comments

Comments
 (0)