4 * Builtin report command: Analyze the perf.data input file,
5 * look up and read DSOs and symbol information and display
6 * a histogram of results, along various sorting keys.
10 #include "util/util.h"
12 #include "util/color.h"
13 #include <linux/list.h>
14 #include "util/cache.h"
15 #include <linux/rbtree.h>
16 #include "util/symbol.h"
17 #include "util/string.h"
18 #include "util/callchain.h"
19 #include "util/strlist.h"
20 #include "util/values.h"
23 #include "util/debug.h"
24 #include "util/header.h"
26 #include "util/parse-options.h"
27 #include "util/parse-events.h"
29 #include "util/data_map.h"
30 #include "util/thread.h"
31 #include "util/sort.h"
32 #include "util/hist.h"
34 static char const *input_name
= "perf.data";
36 static char *dso_list_str
, *comm_list_str
, *sym_list_str
,
38 static struct strlist
*dso_list
, *comm_list
, *sym_list
;
42 static int full_paths
;
43 static int show_nr_samples
;
45 static int show_threads
;
46 static struct perf_read_values show_threads_values
;
48 static char default_pretty_printing_style
[] = "normal";
49 static char *pretty_printing_style
= default_pretty_printing_style
;
51 static int exclude_other
= 1;
53 static char callchain_default_opt
[] = "fractal,0.5";
58 static struct rb_root threads
;
59 static struct thread
*last_match
;
61 static struct perf_header
*header
;
63 static u64 sample_type
;
65 static size_t ipchain__fprintf_graph_line(FILE *fp
, int depth
, int depth_mask
)
70 ret
+= fprintf(fp
, "%s", " ");
72 for (i
= 0; i
< depth
; i
++)
73 if (depth_mask
& (1 << i
))
74 ret
+= fprintf(fp
, "| ");
76 ret
+= fprintf(fp
, " ");
78 ret
+= fprintf(fp
, "\n");
83 ipchain__fprintf_graph(FILE *fp
, struct callchain_list
*chain
, int depth
,
84 int depth_mask
, int count
, u64 total_samples
,
90 ret
+= fprintf(fp
, "%s", " ");
91 for (i
= 0; i
< depth
; i
++) {
92 if (depth_mask
& (1 << i
))
93 ret
+= fprintf(fp
, "|");
95 ret
+= fprintf(fp
, " ");
96 if (!count
&& i
== depth
- 1) {
99 percent
= hits
* 100.0 / total_samples
;
100 ret
+= percent_color_fprintf(fp
, "--%2.2f%%-- ", percent
);
102 ret
+= fprintf(fp
, "%s", " ");
105 ret
+= fprintf(fp
, "%s\n", chain
->sym
->name
);
107 ret
+= fprintf(fp
, "%p\n", (void *)(long)chain
->ip
);
112 static struct symbol
*rem_sq_bracket
;
113 static struct callchain_list rem_hits
;
115 static void init_rem_hits(void)
117 rem_sq_bracket
= malloc(sizeof(*rem_sq_bracket
) + 6);
118 if (!rem_sq_bracket
) {
119 fprintf(stderr
, "Not enough memory to display remaining hits\n");
123 strcpy(rem_sq_bracket
->name
, "[...]");
124 rem_hits
.sym
= rem_sq_bracket
;
128 callchain__fprintf_graph(FILE *fp
, struct callchain_node
*self
,
129 u64 total_samples
, int depth
, int depth_mask
)
131 struct rb_node
*node
, *next
;
132 struct callchain_node
*child
;
133 struct callchain_list
*chain
;
134 int new_depth_mask
= depth_mask
;
140 if (callchain_param
.mode
== CHAIN_GRAPH_REL
)
141 new_total
= self
->children_hit
;
143 new_total
= total_samples
;
145 remaining
= new_total
;
147 node
= rb_first(&self
->rb_root
);
151 child
= rb_entry(node
, struct callchain_node
, rb_node
);
152 cumul
= cumul_hits(child
);
156 * The depth mask manages the output of pipes that show
157 * the depth. We don't want to keep the pipes of the current
158 * level for the last child of this depth.
159 * Except if we have remaining filtered hits. They will
160 * supersede the last child
162 next
= rb_next(node
);
163 if (!next
&& (callchain_param
.mode
!= CHAIN_GRAPH_REL
|| !remaining
))
164 new_depth_mask
&= ~(1 << (depth
- 1));
167 * But we keep the older depth mask for the line seperator
168 * to keep the level link until we reach the last child
170 ret
+= ipchain__fprintf_graph_line(fp
, depth
, depth_mask
);
172 list_for_each_entry(chain
, &child
->val
, list
) {
173 if (chain
->ip
>= PERF_CONTEXT_MAX
)
175 ret
+= ipchain__fprintf_graph(fp
, chain
, depth
,
180 ret
+= callchain__fprintf_graph(fp
, child
, new_total
,
182 new_depth_mask
| (1 << depth
));
186 if (callchain_param
.mode
== CHAIN_GRAPH_REL
&&
187 remaining
&& remaining
!= new_total
) {
192 new_depth_mask
&= ~(1 << (depth
- 1));
194 ret
+= ipchain__fprintf_graph(fp
, &rem_hits
, depth
,
195 new_depth_mask
, 0, new_total
,
203 callchain__fprintf_flat(FILE *fp
, struct callchain_node
*self
,
206 struct callchain_list
*chain
;
212 ret
+= callchain__fprintf_flat(fp
, self
->parent
, total_samples
);
215 list_for_each_entry(chain
, &self
->val
, list
) {
216 if (chain
->ip
>= PERF_CONTEXT_MAX
)
219 ret
+= fprintf(fp
, " %s\n", chain
->sym
->name
);
221 ret
+= fprintf(fp
, " %p\n",
222 (void *)(long)chain
->ip
);
229 hist_entry_callchain__fprintf(FILE *fp
, struct hist_entry
*self
,
232 struct rb_node
*rb_node
;
233 struct callchain_node
*chain
;
236 rb_node
= rb_first(&self
->sorted_chain
);
240 chain
= rb_entry(rb_node
, struct callchain_node
, rb_node
);
241 percent
= chain
->hit
* 100.0 / total_samples
;
242 switch (callchain_param
.mode
) {
244 ret
+= percent_color_fprintf(fp
, " %6.2f%%\n",
246 ret
+= callchain__fprintf_flat(fp
, chain
, total_samples
);
248 case CHAIN_GRAPH_ABS
: /* Falldown */
249 case CHAIN_GRAPH_REL
:
250 ret
+= callchain__fprintf_graph(fp
, chain
,
251 total_samples
, 1, 1);
256 ret
+= fprintf(fp
, "\n");
257 rb_node
= rb_next(rb_node
);
264 hist_entry__fprintf(FILE *fp
, struct hist_entry
*self
, u64 total_samples
)
266 struct sort_entry
*se
;
269 if (exclude_other
&& !self
->parent
)
273 ret
= percent_color_fprintf(fp
,
274 field_sep
? "%.2f" : " %6.2f%%",
275 (self
->count
* 100.0) / total_samples
);
277 ret
= fprintf(fp
, field_sep
? "%lld" : "%12lld ", self
->count
);
279 if (show_nr_samples
) {
281 fprintf(fp
, "%c%lld", *field_sep
, self
->count
);
283 fprintf(fp
, "%11lld", self
->count
);
286 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
290 fprintf(fp
, "%s", field_sep
?: " ");
291 ret
+= se
->print(fp
, self
, se
->width
? *se
->width
: 0);
294 ret
+= fprintf(fp
, "\n");
297 hist_entry_callchain__fprintf(fp
, self
, total_samples
);
306 static void dso__calc_col_width(struct dso
*self
)
308 if (!col_width_list_str
&& !field_sep
&&
309 (!dso_list
|| strlist__has_entry(dso_list
, self
->name
))) {
310 unsigned int slen
= strlen(self
->name
);
311 if (slen
> dsos__col_width
)
312 dsos__col_width
= slen
;
315 self
->slen_calculated
= 1;
318 static void thread__comm_adjust(struct thread
*self
)
320 char *comm
= self
->comm
;
322 if (!col_width_list_str
&& !field_sep
&&
323 (!comm_list
|| strlist__has_entry(comm_list
, comm
))) {
324 unsigned int slen
= strlen(comm
);
326 if (slen
> comms__col_width
) {
327 comms__col_width
= slen
;
328 threads__col_width
= slen
+ 6;
333 static int thread__set_comm_adjust(struct thread
*self
, const char *comm
)
335 int ret
= thread__set_comm(self
, comm
);
340 thread__comm_adjust(self
);
346 static struct symbol
*
347 resolve_symbol(struct thread
*thread
, struct map
**mapp
, u64
*ipp
)
349 struct map
*map
= mapp
? *mapp
: NULL
;
358 map
= thread__find_map(thread
, ip
);
361 * We have to do this here as we may have a dso
362 * with no symbol hit that has a name longer than
363 * the ones with symbols sampled.
365 if (!sort_dso
.elide
&& !map
->dso
->slen_calculated
)
366 dso__calc_col_width(map
->dso
);
371 ip
= map
->map_ip(map
, ip
);
374 * If this is outside of all known maps,
375 * and is a negative address, try to look it
376 * up in the kernel dso, as it might be a
377 * vsyscall or vdso (which executes in user-mode).
379 * XXX This is nasty, we should have a symbol list in
380 * the "[vdso]" dso, but for now lets use the old
381 * trick of looking in the whole kernel symbol list.
383 if ((long long)ip
< 0)
384 return kernel_maps__find_symbol(ip
, mapp
);
386 dump_printf(" ...... dso: %s\n",
387 map
? map
->dso
->long_name
: "<not found>");
388 dump_printf(" ...... map: %Lx -> %Lx\n", *ipp
, ip
);
391 return map
? map
->dso
->find_symbol(map
->dso
, ip
) : NULL
;
394 static int call__match(struct symbol
*sym
)
396 if (sym
->name
&& !regexec(&parent_regex
, sym
->name
, 0, NULL
, 0))
402 static struct symbol
**resolve_callchain(struct thread
*thread
, struct map
*map
,
403 struct ip_callchain
*chain
,
404 struct symbol
**parent
)
406 u64 context
= PERF_CONTEXT_MAX
;
407 struct symbol
**syms
= NULL
;
411 syms
= calloc(chain
->nr
, sizeof(*syms
));
413 fprintf(stderr
, "Can't allocate memory for symbols\n");
418 for (i
= 0; i
< chain
->nr
; i
++) {
419 u64 ip
= chain
->ips
[i
];
420 struct symbol
*sym
= NULL
;
422 if (ip
>= PERF_CONTEXT_MAX
) {
428 case PERF_CONTEXT_HV
:
430 case PERF_CONTEXT_KERNEL
:
431 sym
= kernel_maps__find_symbol(ip
, &map
);
434 sym
= resolve_symbol(thread
, &map
, &ip
);
439 if (sort__has_parent
&& !*parent
&& call__match(sym
))
451 * collect histogram counts
455 hist_entry__add(struct thread
*thread
, struct map
*map
,
456 struct symbol
*sym
, u64 ip
, struct ip_callchain
*chain
,
457 char level
, u64 count
)
459 struct symbol
**syms
= NULL
, *parent
= NULL
;
461 struct hist_entry
*he
;
463 if ((sort__has_parent
|| callchain
) && chain
)
464 syms
= resolve_callchain(thread
, map
, chain
, &parent
);
466 he
= __hist_entry__add(thread
, map
, sym
, parent
,
467 ip
, count
, level
, &hit
);
476 callchain_init(&he
->callchain
);
477 append_chain(&he
->callchain
, chain
, syms
);
484 static size_t output__fprintf(FILE *fp
, u64 total_samples
)
486 struct hist_entry
*pos
;
487 struct sort_entry
*se
;
491 char *col_width
= col_width_list_str
;
492 int raw_printing_style
;
494 raw_printing_style
= !strcmp(pretty_printing_style
, "raw");
498 fprintf(fp
, "# Samples: %Ld\n", (u64
)total_samples
);
501 fprintf(fp
, "# Overhead");
502 if (show_nr_samples
) {
504 fprintf(fp
, "%cSamples", *field_sep
);
506 fputs(" Samples ", fp
);
508 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
512 fprintf(fp
, "%c%s", *field_sep
, se
->header
);
515 width
= strlen(se
->header
);
517 if (col_width_list_str
) {
519 *se
->width
= atoi(col_width
);
520 col_width
= strchr(col_width
, ',');
525 width
= *se
->width
= max(*se
->width
, width
);
527 fprintf(fp
, " %*s", width
, se
->header
);
534 fprintf(fp
, "# ........");
536 fprintf(fp
, " ..........");
537 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
547 width
= strlen(se
->header
);
548 for (i
= 0; i
< width
; i
++)
556 for (nd
= rb_first(&output_hists
); nd
; nd
= rb_next(nd
)) {
557 pos
= rb_entry(nd
, struct hist_entry
, rb_node
);
558 ret
+= hist_entry__fprintf(fp
, pos
, total_samples
);
561 if (sort_order
== default_sort_order
&&
562 parent_pattern
== default_parent_pattern
) {
564 fprintf(fp
, "# (For a higher level overview, try: perf report --sort comm,dso)\n");
569 free(rem_sq_bracket
);
572 perf_read_values_display(fp
, &show_threads_values
,
578 static int validate_chain(struct ip_callchain
*chain
, event_t
*event
)
580 unsigned int chain_size
;
582 chain_size
= event
->header
.size
;
583 chain_size
-= (unsigned long)&event
->ip
.__more_data
- (unsigned long)event
;
585 if (chain
->nr
*sizeof(u64
) > chain_size
)
592 process_sample_event(event_t
*event
, unsigned long offset
, unsigned long head
)
595 struct symbol
*sym
= NULL
;
596 struct thread
*thread
;
597 u64 ip
= event
->ip
.ip
;
599 struct map
*map
= NULL
;
600 void *more_data
= event
->ip
.__more_data
;
601 struct ip_callchain
*chain
= NULL
;
604 thread
= threads__findnew(event
->ip
.pid
, &threads
, &last_match
);
606 if (sample_type
& PERF_SAMPLE_PERIOD
) {
607 period
= *(u64
*)more_data
;
608 more_data
+= sizeof(u64
);
611 dump_printf("%p [%p]: PERF_RECORD_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n",
612 (void *)(offset
+ head
),
613 (void *)(long)(event
->header
.size
),
615 event
->ip
.pid
, event
->ip
.tid
,
619 if (sample_type
& PERF_SAMPLE_CALLCHAIN
) {
622 chain
= (void *)more_data
;
624 dump_printf("... chain: nr:%Lu\n", chain
->nr
);
626 if (validate_chain(chain
, event
) < 0) {
627 eprintf("call-chain problem with event, skipping it.\n");
632 for (i
= 0; i
< chain
->nr
; i
++)
633 dump_printf("..... %2d: %016Lx\n", i
, chain
->ips
[i
]);
637 dump_printf(" ... thread: %s:%d\n", thread
->comm
, thread
->pid
);
639 if (thread
== NULL
) {
640 eprintf("problem processing %d event, skipping it.\n",
645 if (comm_list
&& !strlist__has_entry(comm_list
, thread
->comm
))
648 cpumode
= event
->header
.misc
& PERF_RECORD_MISC_CPUMODE_MASK
;
650 if (cpumode
== PERF_RECORD_MISC_KERNEL
) {
652 sym
= kernel_maps__find_symbol(ip
, &map
);
653 dump_printf(" ...... dso: %s\n",
654 map
? map
->dso
->long_name
: "<not found>");
655 } else if (cpumode
== PERF_RECORD_MISC_USER
) {
657 sym
= resolve_symbol(thread
, &map
, &ip
);
661 dump_printf(" ...... dso: [hypervisor]\n");
665 (!map
|| !map
->dso
||
666 !(strlist__has_entry(dso_list
, map
->dso
->short_name
) ||
667 (map
->dso
->short_name
!= map
->dso
->long_name
&&
668 strlist__has_entry(dso_list
, map
->dso
->long_name
)))))
671 if (sym_list
&& sym
&& !strlist__has_entry(sym_list
, sym
->name
))
674 if (hist_entry__add(thread
, map
, sym
, ip
,
675 chain
, level
, period
)) {
676 eprintf("problem incrementing symbol count, skipping event\n");
686 process_mmap_event(event_t
*event
, unsigned long offset
, unsigned long head
)
688 struct thread
*thread
;
689 struct map
*map
= map__new(&event
->mmap
, cwd
, cwdlen
);
691 thread
= threads__findnew(event
->mmap
.pid
, &threads
, &last_match
);
693 dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n",
694 (void *)(offset
+ head
),
695 (void *)(long)(event
->header
.size
),
698 (void *)(long)event
->mmap
.start
,
699 (void *)(long)event
->mmap
.len
,
700 (void *)(long)event
->mmap
.pgoff
,
701 event
->mmap
.filename
);
703 if (thread
== NULL
|| map
== NULL
) {
704 dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
708 thread__insert_map(thread
, map
);
715 process_comm_event(event_t
*event
, unsigned long offset
, unsigned long head
)
717 struct thread
*thread
;
719 thread
= threads__findnew(event
->comm
.pid
, &threads
, &last_match
);
721 dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n",
722 (void *)(offset
+ head
),
723 (void *)(long)(event
->header
.size
),
724 event
->comm
.comm
, event
->comm
.pid
);
726 if (thread
== NULL
||
727 thread__set_comm_adjust(thread
, event
->comm
.comm
)) {
728 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
737 process_task_event(event_t
*event
, unsigned long offset
, unsigned long head
)
739 struct thread
*thread
;
740 struct thread
*parent
;
742 thread
= threads__findnew(event
->fork
.pid
, &threads
, &last_match
);
743 parent
= threads__findnew(event
->fork
.ppid
, &threads
, &last_match
);
745 dump_printf("%p [%p]: PERF_RECORD_%s: (%d:%d):(%d:%d)\n",
746 (void *)(offset
+ head
),
747 (void *)(long)(event
->header
.size
),
748 event
->header
.type
== PERF_RECORD_FORK
? "FORK" : "EXIT",
749 event
->fork
.pid
, event
->fork
.tid
,
750 event
->fork
.ppid
, event
->fork
.ptid
);
753 * A thread clone will have the same PID for both
756 if (thread
== parent
)
759 if (event
->header
.type
== PERF_RECORD_EXIT
)
762 if (!thread
|| !parent
|| thread__fork(thread
, parent
)) {
763 dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
772 process_lost_event(event_t
*event
, unsigned long offset
, unsigned long head
)
774 dump_printf("%p [%p]: PERF_RECORD_LOST: id:%Ld: lost:%Ld\n",
775 (void *)(offset
+ head
),
776 (void *)(long)(event
->header
.size
),
780 total_lost
+= event
->lost
.lost
;
786 process_read_event(event_t
*event
, unsigned long offset
, unsigned long head
)
788 struct perf_event_attr
*attr
;
790 attr
= perf_header__find_attr(event
->read
.id
, header
);
793 const char *name
= attr
? __event_name(attr
->type
, attr
->config
)
795 perf_read_values_add_value(&show_threads_values
,
796 event
->read
.pid
, event
->read
.tid
,
802 dump_printf("%p [%p]: PERF_RECORD_READ: %d %d %s %Lu\n",
803 (void *)(offset
+ head
),
804 (void *)(long)(event
->header
.size
),
807 attr
? __event_name(attr
->type
, attr
->config
)
814 static int sample_type_check(u64 type
)
818 if (!(sample_type
& PERF_SAMPLE_CALLCHAIN
)) {
819 if (sort__has_parent
) {
820 fprintf(stderr
, "selected --sort parent, but no"
821 " callchain data. Did you call"
822 " perf record without -g?\n");
826 fprintf(stderr
, "selected -g but no callchain data."
827 " Did you call perf record without"
831 } else if (callchain_param
.mode
!= CHAIN_NONE
&& !callchain
) {
833 if (register_callchain_param(&callchain_param
) < 0) {
834 fprintf(stderr
, "Can't register callchain"
843 static struct perf_file_handler file_handler
= {
844 .process_sample_event
= process_sample_event
,
845 .process_mmap_event
= process_mmap_event
,
846 .process_comm_event
= process_comm_event
,
847 .process_exit_event
= process_task_event
,
848 .process_fork_event
= process_task_event
,
849 .process_lost_event
= process_lost_event
,
850 .process_read_event
= process_read_event
,
851 .sample_type_check
= sample_type_check
,
855 static int __cmd_report(void)
860 idle
= register_idle_thread(&threads
, &last_match
);
861 thread__comm_adjust(idle
);
864 perf_read_values_init(&show_threads_values
);
866 register_perf_file_handler(&file_handler
);
868 ret
= mmap_dispatch_perf_file(&header
, input_name
, force
, full_paths
,
873 dump_printf(" IP events: %10ld\n", total
);
874 dump_printf(" mmap events: %10ld\n", total_mmap
);
875 dump_printf(" comm events: %10ld\n", total_comm
);
876 dump_printf(" fork events: %10ld\n", total_fork
);
877 dump_printf(" lost events: %10ld\n", total_lost
);
878 dump_printf(" unknown events: %10ld\n", file_handler
.total_unknown
);
884 threads__fprintf(stdout
, &threads
);
887 dsos__fprintf(stdout
);
890 output__resort(total
);
891 output__fprintf(stdout
, total
);
894 perf_read_values_destroy(&show_threads_values
);
900 parse_callchain_opt(const struct option
*opt __used
, const char *arg
,
911 tok
= strtok((char *)arg
, ",");
915 /* get the output mode */
916 if (!strncmp(tok
, "graph", strlen(arg
)))
917 callchain_param
.mode
= CHAIN_GRAPH_ABS
;
919 else if (!strncmp(tok
, "flat", strlen(arg
)))
920 callchain_param
.mode
= CHAIN_FLAT
;
922 else if (!strncmp(tok
, "fractal", strlen(arg
)))
923 callchain_param
.mode
= CHAIN_GRAPH_REL
;
925 else if (!strncmp(tok
, "none", strlen(arg
))) {
926 callchain_param
.mode
= CHAIN_NONE
;
935 /* get the min percentage */
936 tok
= strtok(NULL
, ",");
940 callchain_param
.min_percent
= strtod(tok
, &endptr
);
945 if (register_callchain_param(&callchain_param
) < 0) {
946 fprintf(stderr
, "Can't register callchain params\n");
952 //static const char * const report_usage[] = {
953 const char * const report_usage
[] = {
954 "perf report [<options>] <command>",
958 static const struct option options
[] = {
959 OPT_STRING('i', "input", &input_name
, "file",
961 OPT_BOOLEAN('v', "verbose", &verbose
,
962 "be more verbose (show symbol address, etc)"),
963 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace
,
964 "dump raw trace in ASCII"),
965 OPT_STRING('k', "vmlinux", &vmlinux_name
, "file", "vmlinux pathname"),
966 OPT_BOOLEAN('f', "force", &force
, "don't complain, do it"),
967 OPT_BOOLEAN('m', "modules", &modules
,
968 "load module symbols - WARNING: use only with -k and LIVE kernel"),
969 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples
,
970 "Show a column with the number of samples"),
971 OPT_BOOLEAN('T', "threads", &show_threads
,
972 "Show per-thread event counters"),
973 OPT_STRING(0, "pretty", &pretty_printing_style
, "key",
974 "pretty printing style key: normal raw"),
975 OPT_STRING('s', "sort", &sort_order
, "key[,key2...]",
976 "sort by key(s): pid, comm, dso, symbol, parent"),
977 OPT_BOOLEAN('P', "full-paths", &full_paths
,
978 "Don't shorten the pathnames taking into account the cwd"),
979 OPT_STRING('p', "parent", &parent_pattern
, "regex",
980 "regex filter to identify parent, see: '--sort parent'"),
981 OPT_BOOLEAN('x', "exclude-other", &exclude_other
,
982 "Only display entries with parent-match"),
983 OPT_CALLBACK_DEFAULT('g', "call-graph", NULL
, "output_type,min_percent",
984 "Display callchains using output_type and min percent threshold. "
985 "Default: fractal,0.5", &parse_callchain_opt
, callchain_default_opt
),
986 OPT_STRING('d', "dsos", &dso_list_str
, "dso[,dso...]",
987 "only consider symbols in these dsos"),
988 OPT_STRING('C', "comms", &comm_list_str
, "comm[,comm...]",
989 "only consider symbols in these comms"),
990 OPT_STRING('S', "symbols", &sym_list_str
, "symbol[,symbol...]",
991 "only consider these symbols"),
992 OPT_STRING('w', "column-widths", &col_width_list_str
,
994 "don't try to adjust column width, use these fixed values"),
995 OPT_STRING('t', "field-separator", &field_sep
, "separator",
996 "separator for columns, no spaces will be added between "
997 "columns '.' is reserved."),
1001 static void setup_sorting(void)
1003 char *tmp
, *tok
, *str
= strdup(sort_order
);
1005 for (tok
= strtok_r(str
, ", ", &tmp
);
1006 tok
; tok
= strtok_r(NULL
, ", ", &tmp
)) {
1007 if (sort_dimension__add(tok
) < 0) {
1008 error("Unknown --sort key: `%s'", tok
);
1009 usage_with_options(report_usage
, options
);
1016 static void setup_list(struct strlist
**list
, const char *list_str
,
1017 struct sort_entry
*se
, const char *list_name
,
1021 *list
= strlist__new(true, list_str
);
1023 fprintf(stderr
, "problems parsing %s list\n",
1027 if (strlist__nr_entries(*list
) == 1) {
1028 fprintf(fp
, "# %s: %s\n", list_name
,
1029 strlist__entry(*list
, 0)->s
);
1035 int cmd_report(int argc
, const char **argv
, const char *prefix __used
)
1039 argc
= parse_options(argc
, argv
, options
, report_usage
, 0);
1043 if (parent_pattern
!= default_parent_pattern
) {
1044 sort_dimension__add("parent");
1045 sort_parent
.elide
= 1;
1050 * Any (unrecognized) arguments left?
1053 usage_with_options(report_usage
, options
);
1057 setup_list(&dso_list
, dso_list_str
, &sort_dso
, "dso", stdout
);
1058 setup_list(&comm_list
, comm_list_str
, &sort_comm
, "comm", stdout
);
1059 setup_list(&sym_list
, sym_list_str
, &sort_sym
, "symbol", stdout
);
1061 if (field_sep
&& *field_sep
== '.') {
1062 fputs("'.' is the only non valid --field-separator argument\n",
1067 return __cmd_report();