|
38 | 38 | #include "util/time-utils.h"
|
39 | 39 | #include "util/auxtrace.h"
|
40 | 40 | #include "util/units.h"
|
| 41 | +#include "util/branch.h" |
41 | 42 |
|
42 | 43 | #include <dlfcn.h>
|
43 | 44 | #include <errno.h>
|
@@ -73,6 +74,7 @@ struct report {
|
73 | 74 | u64 queue_size;
|
74 | 75 | int socket_filter;
|
75 | 76 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
|
| 77 | + struct branch_type_stat brtype_stat; |
76 | 78 | };
|
77 | 79 |
|
78 | 80 | static int report__config(const char *var, const char *value, void *cb)
|
@@ -150,6 +152,22 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
|
150 | 152 | return err;
|
151 | 153 | }
|
152 | 154 |
|
| 155 | +static int hist_iter__branch_callback(struct hist_entry_iter *iter, |
| 156 | + struct addr_location *al __maybe_unused, |
| 157 | + bool single __maybe_unused, |
| 158 | + void *arg) |
| 159 | +{ |
| 160 | + struct hist_entry *he = iter->he; |
| 161 | + struct report *rep = arg; |
| 162 | + struct branch_info *bi; |
| 163 | + |
| 164 | + bi = he->branch_info; |
| 165 | + branch_type_count(&rep->brtype_stat, &bi->flags, |
| 166 | + bi->from.addr, bi->to.addr); |
| 167 | + |
| 168 | + return 0; |
| 169 | +} |
| 170 | + |
153 | 171 | static int process_sample_event(struct perf_tool *tool,
|
154 | 172 | union perf_event *event,
|
155 | 173 | struct perf_sample *sample,
|
@@ -188,6 +206,8 @@ static int process_sample_event(struct perf_tool *tool,
|
188 | 206 | */
|
189 | 207 | if (!sample->branch_stack)
|
190 | 208 | goto out_put;
|
| 209 | + |
| 210 | + iter.add_entry_cb = hist_iter__branch_callback; |
191 | 211 | iter.ops = &hist_iter_branch;
|
192 | 212 | } else if (rep->mem_mode) {
|
193 | 213 | iter.ops = &hist_iter_mem;
|
@@ -410,6 +430,9 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
|
410 | 430 | perf_read_values_destroy(&rep->show_threads_values);
|
411 | 431 | }
|
412 | 432 |
|
| 433 | + if (sort__mode == SORT_MODE__BRANCH) |
| 434 | + branch_type_stat_display(stdout, &rep->brtype_stat); |
| 435 | + |
413 | 436 | return 0;
|
414 | 437 | }
|
415 | 438 |
|
@@ -944,6 +967,8 @@ int cmd_report(int argc, const char **argv)
|
944 | 967 | if (has_br_stack && branch_call_mode)
|
945 | 968 | symbol_conf.show_branchflag_count = true;
|
946 | 969 |
|
| 970 | + memset(&report.brtype_stat, 0, sizeof(struct branch_type_stat)); |
| 971 | + |
947 | 972 | /*
|
948 | 973 | * Branch mode is a tristate:
|
949 | 974 | * -1 means default, so decide based on the file having branch data.
|
|
0 commit comments