@@ -1697,6 +1697,7 @@ struct perf_script {
1697
1697
bool show_cgroup_events ;
1698
1698
bool allocated ;
1699
1699
bool per_event_dump ;
1700
+ bool stitch_lbr ;
1700
1701
struct evswitch evswitch ;
1701
1702
struct perf_cpu_map * cpus ;
1702
1703
struct perf_thread_map * threads ;
@@ -1923,6 +1924,9 @@ static void process_event(struct perf_script *script,
1923
1924
if (PRINT_FIELD (IP )) {
1924
1925
struct callchain_cursor * cursor = NULL ;
1925
1926
1927
+ if (script -> stitch_lbr )
1928
+ al -> thread -> lbr_stitch_enable = true;
1929
+
1926
1930
if (symbol_conf .use_callchain && sample -> callchain &&
1927
1931
thread__resolve_callchain (al -> thread , & callchain_cursor , evsel ,
1928
1932
sample , NULL , NULL , scripting_max_stack ) == 0 )
@@ -3170,6 +3174,12 @@ static void script__setup_sample_type(struct perf_script *script)
3170
3174
else
3171
3175
callchain_param .record_mode = CALLCHAIN_FP ;
3172
3176
}
3177
+
3178
+ if (script -> stitch_lbr && (callchain_param .record_mode != CALLCHAIN_LBR )) {
3179
+ pr_warning ("Can't find LBR callchain. Switch off --stitch-lbr.\n"
3180
+ "Please apply --call-graph lbr when recording.\n" );
3181
+ script -> stitch_lbr = false;
3182
+ }
3173
3183
}
3174
3184
3175
3185
static int process_stat_round_event (struct perf_session * session ,
@@ -3481,6 +3491,8 @@ int cmd_script(int argc, const char **argv)
3481
3491
"file" , "file saving guest os /proc/kallsyms" ),
3482
3492
OPT_STRING (0 , "guestmodules" , & symbol_conf .default_guest_modules ,
3483
3493
"file" , "file saving guest os /proc/modules" ),
3494
+ OPT_BOOLEAN ('\0' , "stitch-lbr" , & script .stitch_lbr ,
3495
+ "Enable LBR callgraph stitching approach" ),
3484
3496
OPTS_EVSWITCH (& script .evswitch ),
3485
3497
OPT_END ()
3486
3498
};
0 commit comments