Skip to content

Commit 3055079

Browse files
committed
feat: allow to skip obj functions from a cli option
1 parent 8cb4de9 commit 3055079

4 files changed

Lines changed: 32 additions & 2 deletions

File tree

callgrind/bbcc.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,23 @@ void CLG_(setup_bbcc)(BB* bb)
725725
}
726726
}
727727

728-
if (jmpkind == jk_Call)
729-
skip = CLG_(get_fn_node)(bb)->skip;
728+
if (jmpkind == jk_Call) {
729+
fn_node* node = CLG_(get_fn_node)(bb);
730+
skip = node->skip;
731+
if (!skip && !node->obj_skip_checked){
732+
HChar* obj_name = node->file->obj->name;
733+
// VG_(printf)(" %s\n", obj_name);
734+
for (int i=0; i<CLG_(clo).objs_to_skip_count; i++) {
735+
// VG_(printf)(" %s\n", CLG_(clo).objs_to_skip[i]);
736+
if (VG_(strcmp)(obj_name, CLG_(clo).objs_to_skip[i]) == 0) {
737+
node->skip = True;
738+
skip = True;
739+
break;
740+
}
741+
}
742+
node->obj_skip_checked = True;
743+
}
744+
}
730745

731746
CLG_DEBUGIF(1) {
732747
if (isConditionalJump)

callgrind/clo.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,14 @@ Bool CLG_(process_cmd_line_option)(const HChar* arg)
430430
fn_config* fnc = get_fnc(tmp_str);
431431
fnc->skip = CONFIG_TRUE;
432432
}
433+
else if VG_STR_CLO(arg, "--obj-skip", tmp_str) {
434+
HChar *obj_name = VG_(strdup)("cl.clo.pclo.1", tmp_str);
435+
CLG_(clo).objs_to_skip_count++;
436+
CLG_(clo).objs_to_skip = VG_(realloc)("cl.clo.pclo.2",
437+
CLG_(clo).objs_to_skip,
438+
CLG_(clo).objs_to_skip_count*sizeof(HChar*));
439+
CLG_(clo).objs_to_skip[CLG_(clo).objs_to_skip_count-1] = obj_name;
440+
}
433441

434442
else if VG_STR_CLO(arg, "--dump-before", tmp_str) {
435443
fn_config* fnc = get_fnc(tmp_str);
@@ -611,6 +619,7 @@ void CLG_(print_usage)(void)
611619
" --skip-plt=no|yes Ignore calls to/from PLT sections? [yes]\n"
612620
" --skip-direct-rec=no|yes Ignore direct recursions? [yes]\n"
613621
" --fn-skip=<function> Ignore calls to/from function?\n"
622+
" --obj-skip=<object> Ignore calls to/from object?\n"
614623
#if CLG_EXPERIMENTAL
615624
" --fn-group<no>=<func> Put function into separation group <no>\n"
616625
#endif
@@ -681,6 +690,8 @@ void CLG_(set_clo_defaults)(void)
681690

682691
/* Call graph */
683692
CLG_(clo).pop_on_jump = False;
693+
CLG_(clo).objs_to_skip_count = 0;
694+
CLG_(clo).objs_to_skip = 0;
684695

685696
#if CLG_ENABLE_DEBUG
686697
CLG_(clo).verbose = 0;

callgrind/fn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ fn_node* new_fn_node(const HChar *fnname,
452452
fn->zero_before = False;
453453
fn->toggle_collect = False;
454454
fn->skip = False;
455+
fn->obj_skip_checked = False;
455456
fn->pop_on_jump = CLG_(clo).pop_on_jump;
456457
fn->is_malloc = False;
457458
fn->is_realloc = False;

callgrind/global.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ struct _CommandLineOptions {
119119

120120
/* Call graph generation */
121121
Bool pop_on_jump; /* Handle a jump between functions as ret+call */
122+
Int objs_to_skip_count; /* Number of objects to skip */
123+
HChar** objs_to_skip; /* List of objects to skip */
122124

123125
#if CLG_ENABLE_DEBUG
124126
Int verbose;
@@ -407,6 +409,7 @@ struct _fn_node {
407409
Bool zero_before :1;
408410
Bool toggle_collect :1;
409411
Bool skip :1;
412+
Bool obj_skip_checked : 1;
410413
Bool pop_on_jump : 1;
411414

412415
Bool is_malloc :1;

0 commit comments

Comments
 (0)