diff options
-rw-r--r-- | tools/perf/builtin-report.c | 23 | ||||
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 4 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 4 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 8 |
4 files changed, 24 insertions, 15 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index d9f2de3e81fe..c877982a64d3 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -311,7 +311,7 @@ static int process_sample_event(struct perf_tool *tool, | |||
311 | if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap)) | 311 | if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap)) |
312 | return 0; | 312 | return 0; |
313 | 313 | ||
314 | if (sort__branch_mode == 1) { | 314 | if (sort__mode == SORT_MODE__BRANCH) { |
315 | if (perf_report__add_branch_hist_entry(tool, &al, sample, | 315 | if (perf_report__add_branch_hist_entry(tool, &al, sample, |
316 | evsel, machine)) { | 316 | evsel, machine)) { |
317 | pr_debug("problem adding lbr entry, skipping event\n"); | 317 | pr_debug("problem adding lbr entry, skipping event\n"); |
@@ -387,7 +387,7 @@ static int perf_report__setup_sample_type(struct perf_report *rep) | |||
387 | } | 387 | } |
388 | } | 388 | } |
389 | 389 | ||
390 | if (sort__branch_mode == 1) { | 390 | if (sort__mode == SORT_MODE__BRANCH) { |
391 | if (!self->fd_pipe && | 391 | if (!self->fd_pipe && |
392 | !(sample_type & PERF_SAMPLE_BRANCH_STACK)) { | 392 | !(sample_type & PERF_SAMPLE_BRANCH_STACK)) { |
393 | ui__error("Selected -b but no branch data. " | 393 | ui__error("Selected -b but no branch data. " |
@@ -694,7 +694,9 @@ static int | |||
694 | parse_branch_mode(const struct option *opt __maybe_unused, | 694 | parse_branch_mode(const struct option *opt __maybe_unused, |
695 | const char *str __maybe_unused, int unset) | 695 | const char *str __maybe_unused, int unset) |
696 | { | 696 | { |
697 | sort__branch_mode = !unset; | 697 | int *branch_mode = opt->value; |
698 | |||
699 | *branch_mode = !unset; | ||
698 | return 0; | 700 | return 0; |
699 | } | 701 | } |
700 | 702 | ||
@@ -703,6 +705,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) | |||
703 | struct perf_session *session; | 705 | struct perf_session *session; |
704 | struct stat st; | 706 | struct stat st; |
705 | bool has_br_stack = false; | 707 | bool has_br_stack = false; |
708 | int branch_mode = -1; | ||
706 | int ret = -1; | 709 | int ret = -1; |
707 | char callchain_default_opt[] = "fractal,0.5,callee"; | 710 | char callchain_default_opt[] = "fractal,0.5,callee"; |
708 | const char * const report_usage[] = { | 711 | const char * const report_usage[] = { |
@@ -799,7 +802,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) | |||
799 | "Show a column with the sum of periods"), | 802 | "Show a column with the sum of periods"), |
800 | OPT_BOOLEAN(0, "group", &symbol_conf.event_group, | 803 | OPT_BOOLEAN(0, "group", &symbol_conf.event_group, |
801 | "Show event group information together"), | 804 | "Show event group information together"), |
802 | OPT_CALLBACK_NOOPT('b', "branch-stack", &sort__branch_mode, "", | 805 | OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "", |
803 | "use branch records for histogram filling", parse_branch_mode), | 806 | "use branch records for histogram filling", parse_branch_mode), |
804 | OPT_STRING(0, "objdump", &objdump_path, "path", | 807 | OPT_STRING(0, "objdump", &objdump_path, "path", |
805 | "objdump binary to use for disassembly and annotations"), | 808 | "objdump binary to use for disassembly and annotations"), |
@@ -849,11 +852,11 @@ repeat: | |||
849 | has_br_stack = perf_header__has_feat(&session->header, | 852 | has_br_stack = perf_header__has_feat(&session->header, |
850 | HEADER_BRANCH_STACK); | 853 | HEADER_BRANCH_STACK); |
851 | 854 | ||
852 | if (sort__branch_mode == -1 && has_br_stack) | 855 | if (branch_mode == -1 && has_br_stack) |
853 | sort__branch_mode = 1; | 856 | sort__mode = SORT_MODE__BRANCH; |
854 | 857 | ||
855 | /* sort__branch_mode could be 0 if --no-branch-stack */ | 858 | /* sort__mode could be NORMAL if --no-branch-stack */ |
856 | if (sort__branch_mode == 1) { | 859 | if (sort__mode == SORT_MODE__BRANCH) { |
857 | /* | 860 | /* |
858 | * if no sort_order is provided, then specify | 861 | * if no sort_order is provided, then specify |
859 | * branch-mode specific order | 862 | * branch-mode specific order |
@@ -864,7 +867,7 @@ repeat: | |||
864 | 867 | ||
865 | } | 868 | } |
866 | if (report.mem_mode) { | 869 | if (report.mem_mode) { |
867 | if (sort__branch_mode == 1) { | 870 | if (sort__mode == SORT_MODE__BRANCH) { |
868 | fprintf(stderr, "branch and mem mode incompatible\n"); | 871 | fprintf(stderr, "branch and mem mode incompatible\n"); |
869 | goto error; | 872 | goto error; |
870 | } | 873 | } |
@@ -934,7 +937,7 @@ repeat: | |||
934 | 937 | ||
935 | sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); | 938 | sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); |
936 | 939 | ||
937 | if (sort__branch_mode == 1) { | 940 | if (sort__mode == SORT_MODE__BRANCH) { |
938 | sort_entry__setup_elide(&sort_dso_from, symbol_conf.dso_from_list, "dso_from", stdout); | 941 | sort_entry__setup_elide(&sort_dso_from, symbol_conf.dso_from_list, "dso_from", stdout); |
939 | sort_entry__setup_elide(&sort_dso_to, symbol_conf.dso_to_list, "dso_to", stdout); | 942 | sort_entry__setup_elide(&sort_dso_to, symbol_conf.dso_to_list, "dso_to", stdout); |
940 | sort_entry__setup_elide(&sort_sym_from, symbol_conf.sym_from_list, "sym_from", stdout); | 943 | sort_entry__setup_elide(&sort_sym_from, symbol_conf.sym_from_list, "sym_from", stdout); |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index d88a2d0acb6d..cad8e37f05d9 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1155,7 +1155,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists) | |||
1155 | browser->b.refresh = hist_browser__refresh; | 1155 | browser->b.refresh = hist_browser__refresh; |
1156 | browser->b.seek = ui_browser__hists_seek; | 1156 | browser->b.seek = ui_browser__hists_seek; |
1157 | browser->b.use_navkeypressed = true; | 1157 | browser->b.use_navkeypressed = true; |
1158 | if (sort__branch_mode == 1) | 1158 | if (sort__mode == SORT_MODE__BRANCH) |
1159 | browser->has_symbols = sort_sym_from.list.next != NULL; | 1159 | browser->has_symbols = sort_sym_from.list.next != NULL; |
1160 | else | 1160 | else |
1161 | browser->has_symbols = sort_sym.list.next != NULL; | 1161 | browser->has_symbols = sort_sym.list.next != NULL; |
@@ -1488,7 +1488,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1488 | if (!browser->has_symbols) | 1488 | if (!browser->has_symbols) |
1489 | goto add_exit_option; | 1489 | goto add_exit_option; |
1490 | 1490 | ||
1491 | if (sort__branch_mode == 1) { | 1491 | if (sort__mode == SORT_MODE__BRANCH) { |
1492 | bi = browser->he_selection->branch_info; | 1492 | bi = browser->he_selection->branch_info; |
1493 | if (browser->selection != NULL && | 1493 | if (browser->selection != NULL && |
1494 | bi && | 1494 | bi && |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 16d5e38befe5..a6ddad41d57a 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -9,7 +9,7 @@ const char *sort_order = default_sort_order; | |||
9 | int sort__need_collapse = 0; | 9 | int sort__need_collapse = 0; |
10 | int sort__has_parent = 0; | 10 | int sort__has_parent = 0; |
11 | int sort__has_sym = 0; | 11 | int sort__has_sym = 0; |
12 | int sort__branch_mode = -1; /* -1 = means not set */ | 12 | enum sort_mode sort__mode = SORT_MODE__NORMAL; |
13 | 13 | ||
14 | enum sort_type sort__first_dimension; | 14 | enum sort_type sort__first_dimension; |
15 | 15 | ||
@@ -943,7 +943,7 @@ int sort_dimension__add(const char *tok) | |||
943 | if (strncasecmp(tok, sd->name, strlen(tok))) | 943 | if (strncasecmp(tok, sd->name, strlen(tok))) |
944 | continue; | 944 | continue; |
945 | 945 | ||
946 | if (sort__branch_mode != 1) | 946 | if (sort__mode != SORT_MODE__BRANCH) |
947 | return -EINVAL; | 947 | return -EINVAL; |
948 | 948 | ||
949 | if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) | 949 | if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index f24bdf64238c..39ff4b86ae84 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -32,7 +32,7 @@ extern const char default_sort_order[]; | |||
32 | extern int sort__need_collapse; | 32 | extern int sort__need_collapse; |
33 | extern int sort__has_parent; | 33 | extern int sort__has_parent; |
34 | extern int sort__has_sym; | 34 | extern int sort__has_sym; |
35 | extern int sort__branch_mode; | 35 | extern enum sort_mode sort__mode; |
36 | extern struct sort_entry sort_comm; | 36 | extern struct sort_entry sort_comm; |
37 | extern struct sort_entry sort_dso; | 37 | extern struct sort_entry sort_dso; |
38 | extern struct sort_entry sort_sym; | 38 | extern struct sort_entry sort_sym; |
@@ -123,6 +123,12 @@ static inline void hist_entry__add_pair(struct hist_entry *he, | |||
123 | list_add_tail(&he->pairs.head, &pair->pairs.node); | 123 | list_add_tail(&he->pairs.head, &pair->pairs.node); |
124 | } | 124 | } |
125 | 125 | ||
126 | enum sort_mode { | ||
127 | SORT_MODE__NORMAL, | ||
128 | SORT_MODE__BRANCH, | ||
129 | SORT_MODE__MEMORY, | ||
130 | }; | ||
131 | |||
126 | enum sort_type { | 132 | enum sort_type { |
127 | /* common sort keys */ | 133 | /* common sort keys */ |
128 | SORT_PID, | 134 | SORT_PID, |