@@ -19,6 +19,7 @@ static bool debug_mode;
1919static u64 last_timestamp ;
2020static u64 nr_unordered ;
2121extern const struct option record_options [];
22+ static bool no_callchain ;
2223
2324enum perf_output_field {
2425 PERF_OUTPUT_COMM = 1U << 0 ,
@@ -28,6 +29,7 @@ enum perf_output_field {
2829 PERF_OUTPUT_CPU = 1U << 4 ,
2930 PERF_OUTPUT_EVNAME = 1U << 5 ,
3031 PERF_OUTPUT_TRACE = 1U << 6 ,
32+ PERF_OUTPUT_SYM = 1U << 7 ,
3133};
3234
3335struct output_option {
@@ -41,6 +43,7 @@ struct output_option {
4143 {.str = "cpu" , .field = PERF_OUTPUT_CPU },
4244 {.str = "event" , .field = PERF_OUTPUT_EVNAME },
4345 {.str = "trace" , .field = PERF_OUTPUT_TRACE },
46+ {.str = "sym" , .field = PERF_OUTPUT_SYM },
4447};
4548
4649/* default set to maintain compatibility with current format */
@@ -65,6 +68,8 @@ static void print_sample_start(struct perf_sample *sample,
6568 if (PRINT_FIELD (COMM )) {
6669 if (latency_format )
6770 printf ("%8.8s " , thread -> comm );
71+ else if (PRINT_FIELD (SYM ) && symbol_conf .use_callchain )
72+ printf ("%s " , thread -> comm );
6873 else
6974 printf ("%16s " , thread -> comm );
7075 }
@@ -112,6 +117,14 @@ static void process_event(union perf_event *event __unused,
112117 print_trace_event (sample -> cpu , sample -> raw_data ,
113118 sample -> raw_size );
114119
120+ if (PRINT_FIELD (SYM )) {
121+ if (!symbol_conf .use_callchain )
122+ printf (" " );
123+ else
124+ printf ("\n" );
125+ perf_session__print_symbols (event , sample , session );
126+ }
127+
115128 printf ("\n" );
116129}
117130
@@ -190,7 +203,10 @@ static int process_sample_event(union perf_event *event,
190203
191204static struct perf_event_ops event_ops = {
192205 .sample = process_sample_event ,
206+ .mmap = perf_event__process_mmap ,
193207 .comm = perf_event__process_comm ,
208+ .exit = perf_event__process_task ,
209+ .fork = perf_event__process_task ,
194210 .attr = perf_event__process_attr ,
195211 .event_type = perf_event__process_event_type ,
196212 .tracing_data = perf_event__process_tracing_data ,
@@ -722,8 +738,16 @@ static const struct option options[] = {
722738 "input file name" ),
723739 OPT_BOOLEAN ('d' , "debug-mode" , & debug_mode ,
724740 "do various checks like samples ordering and lost events" ),
741+ OPT_STRING ('k' , "vmlinux" , & symbol_conf .vmlinux_name ,
742+ "file" , "vmlinux pathname" ),
743+ OPT_STRING (0 , "kallsyms" , & symbol_conf .kallsyms_name ,
744+ "file" , "kallsyms pathname" ),
745+ OPT_BOOLEAN ('G' , "hide-call-graph" , & no_callchain ,
746+ "When printing symbols do not display call chain" ),
747+ OPT_STRING (0 , "symfs" , & symbol_conf .symfs , "directory" ,
748+ "Look for files with symbols relative to this directory" ),
725749 OPT_CALLBACK ('f' , "fields" , NULL , "str" ,
726- "comma separated output fields. Options: comm,tid,pid,time,cpu,event,trace" ,
750+ "comma separated output fields. Options: comm,tid,pid,time,cpu,event,trace,sym " ,
727751 parse_output_fields ),
728752
729753 OPT_END ()
@@ -905,6 +929,11 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
905929 if (session == NULL )
906930 return - ENOMEM ;
907931
932+ if (!no_callchain && (session -> sample_type & PERF_SAMPLE_CALLCHAIN ))
933+ symbol_conf .use_callchain = true;
934+ else
935+ symbol_conf .use_callchain = false;
936+
908937 if (strcmp (input_name , "-" ) &&
909938 !perf_session__has_traces (session , "record -R" ))
910939 return - EINVAL ;
0 commit comments