Blame view
tools/perf/builtin-report.c
16.7 KB
bf9e18763 perf_counter tool... |
1 2 3 4 5 6 7 |
/* * builtin-report.c * * Builtin report command: Analyze the perf.data input file, * look up and read DSOs and symbol information and display * a histogram of results, along various sorting keys. */ |
16f762a2a perf_counter tool... |
8 |
#include "builtin.h" |
53cb8bc2a perf record: Conv... |
9 |
|
bf9e18763 perf_counter tool... |
10 |
#include "util/util.h" |
78f7defed perf annotate: Mo... |
11 |
#include "util/annotate.h" |
8fc0321f1 perf_counter tool... |
12 |
#include "util/color.h" |
5da502585 perf_counter tool... |
13 |
#include <linux/list.h> |
a930d2c0d perf_counter tool... |
14 |
#include "util/cache.h" |
43cbcd8ac perf_counter tool... |
15 |
#include <linux/rbtree.h> |
a2928c42a perf_counter tool... |
16 |
#include "util/symbol.h" |
f55c55522 perf report: Prin... |
17 |
#include "util/callchain.h" |
25903407d perf report: Add ... |
18 |
#include "util/strlist.h" |
8d5132709 perf report: Fix ... |
19 |
#include "util/values.h" |
8fa66bdcc perf_counter: Fir... |
20 |
|
53cb8bc2a perf record: Conv... |
21 |
#include "perf.h" |
8f28827a1 perf tools: Libra... |
22 |
#include "util/debug.h" |
e248de331 perf tools: Impro... |
23 24 |
#include "util/evlist.h" #include "util/evsel.h" |
7c6a1c65b perf_counter tool... |
25 |
#include "util/header.h" |
94c744b6c perf tools: Intro... |
26 |
#include "util/session.h" |
45694aa77 perf tools: Renam... |
27 |
#include "util/tool.h" |
53cb8bc2a perf record: Conv... |
28 29 30 |
#include "util/parse-options.h" #include "util/parse-events.h" |
6baa0a5ae perf tools: Facto... |
31 |
#include "util/thread.h" |
dd68ada2d perf tools: Creat... |
32 |
#include "util/sort.h" |
3d1d07ecd perf tools: Put c... |
33 |
#include "util/hist.h" |
6baa0a5ae perf tools: Facto... |
34 |
|
5d67be97f perf report/annot... |
35 |
#include <linux/bitmap.h> |
d20deb64e perf tools: Pass ... |
36 |
struct perf_report { |
45694aa77 perf tools: Renam... |
37 |
struct perf_tool tool; |
d20deb64e perf tools: Pass ... |
38 |
struct perf_session *session; |
fa372aae3 perf report: Grou... |
39 40 41 42 43 44 45 46 47 48 49 50 |
char const *input_name; bool force, use_tui, use_stdio; bool hide_unresolved; bool dont_use_callchains; bool show_full_info; bool show_threads; bool inverted_callchain; struct perf_read_values show_threads_values; const char *pretty_printing_style; symbol_filter_t annotate_init; const char *cpu_list; DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
d20deb64e perf tools: Pass ... |
51 |
}; |
5d67be97f perf report/annot... |
52 |
|
743eb8686 perf tools: Resol... |
53 54 55 56 |
static int perf_evsel__add_hist_entry(struct perf_evsel *evsel, struct addr_location *al, struct perf_sample *sample, struct machine *machine) |
8fa66bdcc perf_counter: Fir... |
57 |
{ |
b3c9ac084 perf callchains: ... |
58 |
struct symbol *parent = NULL; |
1b3a0e959 perf callchain: F... |
59 |
int err = 0; |
e7fb08b1d perf_counter: too... |
60 |
struct hist_entry *he; |
e7fb08b1d perf_counter: too... |
61 |
|
8d50e5b41 perf tools: Renam... |
62 |
if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { |
743eb8686 perf tools: Resol... |
63 64 |
err = machine__resolve_callchain(machine, evsel, al->thread, sample->callchain, &parent); |
1b3a0e959 perf callchain: F... |
65 66 |
if (err) return err; |
ad5b217b1 perf session: Rem... |
67 |
} |
cbbc79a53 perf report: Add ... |
68 |
|
e248de331 perf tools: Impro... |
69 |
he = __hists__add_entry(&evsel->hists, al, parent, sample->period); |
9735abf11 perf tools: Move ... |
70 |
if (he == NULL) |
1b3a0e959 perf callchain: F... |
71 |
return -ENOMEM; |
ef7b93a11 perf report: Libr... |
72 |
if (symbol_conf.use_callchain) { |
246d4ce81 perf session: Rem... |
73 74 |
err = callchain_append(he->callchain, &evsel->hists.callchain_cursor, |
8d50e5b41 perf tools: Renam... |
75 |
sample->period); |
ef7b93a11 perf report: Libr... |
76 |
if (err) |
1b3a0e959 perf callchain: F... |
77 |
return err; |
ef7b93a11 perf report: Libr... |
78 79 80 81 82 83 |
} /* * Only in the newt browser we are doing integrated annotation, * so we don't allocated the extra space needed because the stdio * code will not use it. */ |
2f525d014 perf annotate: Su... |
84 |
if (al->sym != NULL && use_browser > 0) { |
2f525d014 perf annotate: Su... |
85 |
struct annotation *notes = symbol__annotation(he->ms.sym); |
e248de331 perf tools: Impro... |
86 87 88 89 |
assert(evsel != NULL); err = -ENOMEM; |
d04b35f80 perf symbols: Add... |
90 |
if (notes->src == NULL && symbol__alloc_hist(he->ms.sym) < 0) |
e248de331 perf tools: Impro... |
91 92 93 |
goto out; err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); |
2f525d014 perf annotate: Su... |
94 |
} |
1b3a0e959 perf callchain: F... |
95 |
|
e248de331 perf tools: Impro... |
96 97 98 |
evsel->hists.stats.total_period += sample->period; hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); out: |
39d1e1b1e perf report: Fix ... |
99 |
return err; |
8fa66bdcc perf_counter: Fir... |
100 |
} |
cbbc79a53 perf report: Add ... |
101 |
|
45694aa77 perf tools: Renam... |
102 |
static int process_sample_event(struct perf_tool *tool, |
d20deb64e perf tools: Pass ... |
103 |
union perf_event *event, |
8115d60c3 perf tools: Kill ... |
104 |
struct perf_sample *sample, |
9e69c2108 perf session: Pas... |
105 |
struct perf_evsel *evsel, |
743eb8686 perf tools: Resol... |
106 |
struct machine *machine) |
75051724f perf report: Spli... |
107 |
{ |
45694aa77 perf tools: Renam... |
108 |
struct perf_report *rep = container_of(tool, struct perf_report, tool); |
1ed091c45 perf tools: Conso... |
109 |
struct addr_location al; |
180f95e29 perf: Make common... |
110 |
|
743eb8686 perf tools: Resol... |
111 |
if (perf_event__preprocess_sample(event, machine, &al, sample, |
fa372aae3 perf report: Grou... |
112 |
rep->annotate_init) < 0) { |
c410a3388 perf symbols: Mov... |
113 114 |
fprintf(stderr, "problem processing %d event, skipping it. ", |
75051724f perf report: Spli... |
115 116 117 |
event->header.type); return -1; } |
e7fb08b1d perf_counter: too... |
118 |
|
fa372aae3 perf report: Grou... |
119 |
if (al.filtered || (rep->hide_unresolved && al.sym == NULL)) |
ec218fc4a perf tools: Remov... |
120 |
return 0; |
7bec7a913 perf report: Add ... |
121 |
|
fa372aae3 perf report: Grou... |
122 |
if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap)) |
5d67be97f perf report/annot... |
123 |
return 0; |
ec80fde74 perf symbols: Han... |
124 125 |
if (al.map != NULL) al.map->dso->hit = 1; |
743eb8686 perf tools: Resol... |
126 |
if (perf_evsel__add_hist_entry(evsel, &al, sample, machine)) { |
c82ee828a perf report: Repo... |
127 128 |
pr_debug("problem incrementing symbol period, skipping event "); |
ec218fc4a perf tools: Remov... |
129 |
return -1; |
8fa66bdcc perf_counter: Fir... |
130 |
} |
ec218fc4a perf tools: Remov... |
131 |
|
75051724f perf report: Spli... |
132 133 |
return 0; } |
3502973d0 perf report: Prin... |
134 |
|
45694aa77 perf tools: Renam... |
135 |
static int process_read_event(struct perf_tool *tool, |
d20deb64e perf tools: Pass ... |
136 |
union perf_event *event, |
8115d60c3 perf tools: Kill ... |
137 |
struct perf_sample *sample __used, |
743eb8686 perf tools: Resol... |
138 139 |
struct perf_evsel *evsel, struct machine *machine __used) |
e9ea2fde7 perf-report: Add ... |
140 |
{ |
45694aa77 perf tools: Renam... |
141 |
struct perf_report *rep = container_of(tool, struct perf_report, tool); |
743eb8686 perf tools: Resol... |
142 |
|
fa372aae3 perf report: Grou... |
143 |
if (rep->show_threads) { |
e248de331 perf tools: Impro... |
144 |
const char *name = evsel ? event_name(evsel) : "unknown"; |
fa372aae3 perf report: Grou... |
145 |
perf_read_values_add_value(&rep->show_threads_values, |
8d5132709 perf report: Fix ... |
146 147 148 149 150 |
event->read.pid, event->read.tid, event->read.id, name, event->read.value); } |
9486aa387 perf tools: Fix 6... |
151 152 |
dump_printf(": %d %d %s %" PRIu64 " ", event->read.pid, event->read.tid, |
e248de331 perf tools: Impro... |
153 |
evsel ? event_name(evsel) : "FAIL", |
62daacb51 perf tools: Reorg... |
154 |
event->read.value); |
e9ea2fde7 perf-report: Add ... |
155 156 157 |
return 0; } |
d20deb64e perf tools: Pass ... |
158 |
static int perf_report__setup_sample_type(struct perf_report *rep) |
d80d338d2 perf report: Clea... |
159 |
{ |
d20deb64e perf tools: Pass ... |
160 |
struct perf_session *self = rep->session; |
d549c7690 perf session: Rem... |
161 |
if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) { |
91b4eaea9 perf report: Warn... |
162 |
if (sort__has_parent) { |
00894ce9b perf report: Use ... |
163 164 165 166 |
ui__warning("Selected --sort parent, but no " "callchain data. Did you call " "'perf record' without -g? "); |
d549c7690 perf session: Rem... |
167 |
return -EINVAL; |
91b4eaea9 perf report: Warn... |
168 |
} |
d599db3fc perf report: Gene... |
169 |
if (symbol_conf.use_callchain) { |
00894ce9b perf report: Use ... |
170 171 172 |
ui__warning("Selected -g but no callchain data. Did " "you call 'perf record' without -g? "); |
016e92fbc perf tools: Unify... |
173 |
return -1; |
91b4eaea9 perf report: Warn... |
174 |
} |
fa372aae3 perf report: Grou... |
175 176 |
} else if (!rep->dont_use_callchains && callchain_param.mode != CHAIN_NONE && |
b9a63b9b5 perf report: Fix ... |
177 |
!symbol_conf.use_callchain) { |
d599db3fc perf report: Gene... |
178 |
symbol_conf.use_callchain = true; |
16537f135 perf callchain: R... |
179 |
if (callchain_register_param(&callchain_param) < 0) { |
00894ce9b perf report: Use ... |
180 181 182 |
ui__warning("Can't register callchain " "params. "); |
d549c7690 perf session: Rem... |
183 |
return -EINVAL; |
b1a88349c perf tools: callc... |
184 |
} |
f5970550d perf_counter tool... |
185 |
} |
016e92fbc perf tools: Unify... |
186 187 |
return 0; } |
6142f9ec1 perf report: More... |
188 |
|
46656ac7f perf report: Intr... |
189 |
extern volatile int session_done; |
c82ee828a perf report: Repo... |
190 |
static void sig_handler(int sig __used) |
46656ac7f perf report: Intr... |
191 192 193 |
{ session_done = 1; } |
c82ee828a perf report: Repo... |
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
static size_t hists__fprintf_nr_sample_events(struct hists *self, const char *evname, FILE *fp) { size_t ret; char unit; unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE]; nr_events = convert_unit(nr_events, &unit); ret = fprintf(fp, "# Events: %lu%c", nr_events, unit); if (evname != NULL) ret += fprintf(fp, " %s", evname); return ret + fprintf(fp, " # "); } |
7f0030b21 perf report tui: ... |
209 |
static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, |
d20deb64e perf tools: Pass ... |
210 |
struct perf_report *rep, |
7f0030b21 perf report tui: ... |
211 |
const char *help) |
d67f088e0 perf report: Supp... |
212 |
{ |
e248de331 perf tools: Impro... |
213 |
struct perf_evsel *pos; |
d67f088e0 perf report: Supp... |
214 |
|
e248de331 perf tools: Impro... |
215 216 |
list_for_each_entry(pos, &evlist->entries, node) { struct hists *hists = &pos->hists; |
b53af0f23 perf report: Fix ... |
217 |
const char *evname = event_name(pos); |
d67f088e0 perf report: Supp... |
218 219 |
hists__fprintf_nr_sample_events(hists, evname, stdout); |
ef9dfe6ec perf hists: Allow... |
220 |
hists__fprintf(hists, NULL, false, true, 0, 0, stdout); |
d67f088e0 perf report: Supp... |
221 222 223 |
fprintf(stdout, " "); |
d67f088e0 perf report: Supp... |
224 225 226 227 228 229 230 231 |
} if (sort_order == default_sort_order && parent_pattern == default_parent_pattern) { fprintf(stdout, "# # (%s) # ", help); |
fa372aae3 perf report: Grou... |
232 233 234 |
if (rep->show_threads) { bool style = !strcmp(rep->pretty_printing_style, "raw"); perf_read_values_display(stdout, &rep->show_threads_values, |
d67f088e0 perf report: Supp... |
235 |
style); |
fa372aae3 perf report: Grou... |
236 |
perf_read_values_destroy(&rep->show_threads_values); |
d67f088e0 perf report: Supp... |
237 238 239 240 241 |
} } return 0; } |
d20deb64e perf tools: Pass ... |
242 |
static int __cmd_report(struct perf_report *rep) |
016e92fbc perf tools: Unify... |
243 |
{ |
d549c7690 perf session: Rem... |
244 |
int ret = -EINVAL; |
e248de331 perf tools: Impro... |
245 |
u64 nr_samples; |
d8f66248d perf session: Pas... |
246 |
struct perf_session *session; |
e248de331 perf tools: Impro... |
247 |
struct perf_evsel *pos; |
ec80fde74 perf symbols: Han... |
248 249 |
struct map *kernel_map; struct kmap *kernel_kmap; |
f9224c5c9 perf report: Impl... |
250 |
const char *help = "For a higher level overview, try: perf report --sort comm,dso"; |
8fa66bdcc perf_counter: Fir... |
251 |
|
46656ac7f perf report: Intr... |
252 |
signal(SIGINT, sig_handler); |
fa372aae3 perf report: Grou... |
253 |
session = perf_session__new(rep->input_name, O_RDONLY, |
45694aa77 perf tools: Renam... |
254 |
rep->force, false, &rep->tool); |
94c744b6c perf tools: Intro... |
255 256 |
if (session == NULL) return -ENOMEM; |
d20deb64e perf tools: Pass ... |
257 |
rep->session = session; |
fa372aae3 perf report: Grou... |
258 259 260 |
if (rep->cpu_list) { ret = perf_session__cpu_bitmap(session, rep->cpu_list, rep->cpu_bitmap); |
5d67be97f perf report/annot... |
261 262 263 |
if (ret) goto out_delete; } |
fbe96f29c perf tools: Make ... |
264 |
if (use_browser <= 0) |
fa372aae3 perf report: Grou... |
265 |
perf_session__fprintf_info(session, stdout, rep->show_full_info); |
fbe96f29c perf tools: Make ... |
266 |
|
fa372aae3 perf report: Grou... |
267 268 |
if (rep->show_threads) perf_read_values_init(&rep->show_threads_values); |
f5970550d perf_counter tool... |
269 |
|
d20deb64e perf tools: Pass ... |
270 |
ret = perf_report__setup_sample_type(rep); |
d549c7690 perf session: Rem... |
271 272 |
if (ret) goto out_delete; |
45694aa77 perf tools: Renam... |
273 |
ret = perf_session__process_events(session, &rep->tool); |
016e92fbc perf tools: Unify... |
274 |
if (ret) |
94c744b6c perf tools: Intro... |
275 |
goto out_delete; |
97b07b699 perf report: add ... |
276 |
|
ec80fde74 perf symbols: Han... |
277 278 279 280 281 282 283 |
kernel_map = session->host_machine.vmlinux_maps[MAP__FUNCTION]; kernel_kmap = map__kmap(kernel_map); if (kernel_map == NULL || (kernel_map->dso->hit && (kernel_kmap->ref_reloc_sym == NULL || kernel_kmap->ref_reloc_sym->addr == 0))) { const struct dso *kdso = kernel_map->dso; |
646aaea61 perf tools: Make ... |
284 285 286 287 288 289 290 291 292 293 294 295 |
ui__warning( "Kernel address maps (/proc/{kallsyms,modules}) were restricted. " "Check /proc/sys/kernel/kptr_restrict before running 'perf record'. %s " "Samples in kernel modules can't be resolved as well. ", |
ec80fde74 perf symbols: Han... |
296 |
RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION]) ? |
646aaea61 perf tools: Make ... |
297 298 299 300 |
"As no suitable kallsyms nor vmlinux was found, kernel samples " "can't be resolved." : "If some relocation was applied (e.g. kexec) symbols may be misresolved."); |
ec80fde74 perf symbols: Han... |
301 |
} |
62daacb51 perf tools: Reorg... |
302 |
if (dump_trace) { |
c8446b9bd perf hist: Make e... |
303 |
perf_session__fprintf_nr_events(session, stdout); |
94c744b6c perf tools: Intro... |
304 |
goto out_delete; |
62daacb51 perf tools: Reorg... |
305 |
} |
97b07b699 perf report: add ... |
306 |
|
da21d1b54 perf tools: Up th... |
307 |
if (verbose > 3) |
b3165f414 perf session: Mov... |
308 |
perf_session__fprintf(session, stdout); |
9ac995457 perf report: Add ... |
309 |
|
da21d1b54 perf tools: Up th... |
310 |
if (verbose > 2) |
cbf696809 perf machines: Ma... |
311 |
perf_session__fprintf_dsos(session, stdout); |
16f762a2a perf_counter tool... |
312 |
|
e248de331 perf tools: Impro... |
313 314 315 |
nr_samples = 0; list_for_each_entry(pos, &session->evlist->entries, node) { struct hists *hists = &pos->hists; |
cbbc79a53 perf report: Add ... |
316 |
|
1c02c4d2e perf hist: Introd... |
317 |
hists__collapse_resort(hists); |
fefb0b94b perf hist: Calcul... |
318 |
hists__output_resort(hists); |
e248de331 perf tools: Impro... |
319 320 321 322 |
nr_samples += hists->stats.nr_events[PERF_RECORD_SAMPLE]; } if (nr_samples == 0) { |
efad14150 perf report: Acce... |
323 324 |
ui__warning("The %s file has no samples! ", session->filename); |
e248de331 perf tools: Impro... |
325 |
goto out_delete; |
cbbc79a53 perf report: Add ... |
326 |
} |
81cce8de9 perf browsers: Ad... |
327 328 329 330 |
if (use_browser > 0) { perf_evlist__tui_browse_hists(session->evlist, help, NULL, NULL, 0); } else |
d20deb64e perf tools: Pass ... |
331 |
perf_evlist__tty_browse_hists(session->evlist, rep, help); |
3e6055ab9 perf session: Mov... |
332 |
|
94c744b6c perf tools: Intro... |
333 |
out_delete: |
71e7cf3a3 perf report: Spee... |
334 335 336 337 338 339 340 341 342 343 344 345 |
/* * Speed up the exit process, for large files this can * take quite a while. * * XXX Enable this when using valgrind or if we ever * librarize this command. * * Also experiment with obstacks to see how much speed * up we'll get here. * * perf_session__delete(session); */ |
016e92fbc perf tools: Unify... |
346 |
return ret; |
8fa66bdcc perf_counter: Fir... |
347 |
} |
4eb3e4788 perf report: Add ... |
348 |
static int |
d20deb64e perf tools: Pass ... |
349 |
parse_callchain_opt(const struct option *opt, const char *arg, int unset) |
4eb3e4788 perf report: Add ... |
350 |
{ |
d20deb64e perf tools: Pass ... |
351 |
struct perf_report *rep = (struct perf_report *)opt->value; |
232a5c948 perf report: Allo... |
352 |
char *tok, *tok2; |
c20ab37ef perf_counter tool... |
353 |
char *endptr; |
b9a63b9b5 perf report: Fix ... |
354 355 356 357 |
/* * --no-call-graph */ if (unset) { |
fa372aae3 perf report: Grou... |
358 |
rep->dont_use_callchains = true; |
b9a63b9b5 perf report: Fix ... |
359 360 |
return 0; } |
d599db3fc perf report: Gene... |
361 |
symbol_conf.use_callchain = true; |
4eb3e4788 perf report: Add ... |
362 363 364 |
if (!arg) return 0; |
c20ab37ef perf_counter tool... |
365 366 367 368 369 370 |
tok = strtok((char *)arg, ","); if (!tok) return -1; /* get the output mode */ if (!strncmp(tok, "graph", strlen(arg))) |
805d127d6 perf report: Add ... |
371 |
callchain_param.mode = CHAIN_GRAPH_ABS; |
4eb3e4788 perf report: Add ... |
372 |
|
c20ab37ef perf_counter tool... |
373 |
else if (!strncmp(tok, "flat", strlen(arg))) |
805d127d6 perf report: Add ... |
374 375 376 377 |
callchain_param.mode = CHAIN_FLAT; else if (!strncmp(tok, "fractal", strlen(arg))) callchain_param.mode = CHAIN_GRAPH_REL; |
b1a88349c perf tools: callc... |
378 379 |
else if (!strncmp(tok, "none", strlen(arg))) { callchain_param.mode = CHAIN_NONE; |
b7ae11b34 perf report: Fix ... |
380 |
symbol_conf.use_callchain = false; |
b1a88349c perf tools: callc... |
381 382 383 |
return 0; } |
4eb3e4788 perf report: Add ... |
384 385 |
else return -1; |
c20ab37ef perf_counter tool... |
386 387 388 |
/* get the min percentage */ tok = strtok(NULL, ","); if (!tok) |
805d127d6 perf report: Add ... |
389 |
goto setup; |
c20ab37ef perf_counter tool... |
390 |
|
805d127d6 perf report: Add ... |
391 |
callchain_param.min_percent = strtod(tok, &endptr); |
c20ab37ef perf_counter tool... |
392 393 |
if (tok == endptr) return -1; |
d797fdc5c perf tools: Add i... |
394 395 396 397 398 399 |
/* get the print limit */ tok2 = strtok(NULL, ","); if (!tok2) goto setup; if (tok2[0] != 'c') { |
6581f6e35 perf report: Docu... |
400 |
callchain_param.print_limit = strtoul(tok2, &endptr, 0); |
d797fdc5c perf tools: Add i... |
401 402 403 404 405 406 407 408 409 410 411 412 |
tok2 = strtok(NULL, ","); if (!tok2) goto setup; } /* get the call chain order */ if (!strcmp(tok2, "caller")) callchain_param.order = ORDER_CALLER; else if (!strcmp(tok2, "callee")) callchain_param.order = ORDER_CALLEE; else return -1; |
805d127d6 perf report: Add ... |
413 |
setup: |
16537f135 perf callchain: R... |
414 |
if (callchain_register_param(&callchain_param) < 0) { |
805d127d6 perf report: Add ... |
415 416 417 418 |
fprintf(stderr, "Can't register callchain params "); return -1; } |
4eb3e4788 perf report: Add ... |
419 420 |
return 0; } |
d20deb64e perf tools: Pass ... |
421 422 |
int cmd_report(int argc, const char **argv, const char *prefix __used) { |
efad14150 perf report: Acce... |
423 |
struct stat st; |
d20deb64e perf tools: Pass ... |
424 425 |
char callchain_default_opt[] = "fractal,0.5,callee"; const char * const report_usage[] = { |
fb2baceb5 perf report: Fix ... |
426 |
"perf report [<options>]", |
d20deb64e perf tools: Pass ... |
427 428 429 |
NULL }; struct perf_report report = { |
45694aa77 perf tools: Renam... |
430 |
.tool = { |
d20deb64e perf tools: Pass ... |
431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
.sample = process_sample_event, .mmap = perf_event__process_mmap, .comm = perf_event__process_comm, .exit = perf_event__process_task, .fork = perf_event__process_task, .lost = perf_event__process_lost, .read = process_read_event, .attr = perf_event__process_attr, .event_type = perf_event__process_event_type, .tracing_data = perf_event__process_tracing_data, .build_id = perf_event__process_build_id, .ordered_samples = true, .ordering_requires_timestamps = true, }, |
d20deb64e perf tools: Pass ... |
445 446 447 |
.pretty_printing_style = "normal", }; const struct option options[] = { |
fa372aae3 perf report: Grou... |
448 |
OPT_STRING('i', "input", &report.input_name, "file", |
53cb8bc2a perf record: Conv... |
449 |
"input file name"), |
c05556421 perf: Fix endiann... |
450 |
OPT_INCR('v', "verbose", &verbose, |
815e777f9 perf report: Show... |
451 |
"be more verbose (show symbol address, etc)"), |
97b07b699 perf report: add ... |
452 453 |
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), |
b32d133ae perf symbols: Sim... |
454 455 |
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, "file", "vmlinux pathname"), |
b226a5a72 perf report: Allo... |
456 457 |
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file", "kallsyms pathname"), |
fa372aae3 perf report: Grou... |
458 |
OPT_BOOLEAN('f', "force", &report.force, "don't complain, do it"), |
b32d133ae perf symbols: Sim... |
459 |
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, |
429764873 perf_counter tool... |
460 |
"load module symbols - WARNING: use only with -k and LIVE kernel"), |
d599db3fc perf report: Gene... |
461 |
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, |
e3d7e183d perf report: Intr... |
462 |
"Show a column with the number of samples"), |
fa372aae3 perf report: Grou... |
463 |
OPT_BOOLEAN('T', "threads", &report.show_threads, |
8d5132709 perf report: Fix ... |
464 |
"Show per-thread event counters"), |
fa372aae3 perf report: Grou... |
465 |
OPT_STRING(0, "pretty", &report.pretty_printing_style, "key", |
9f8666971 perf report: Add ... |
466 |
"pretty printing style key: normal raw"), |
fa372aae3 perf report: Grou... |
467 468 469 |
OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"), OPT_BOOLEAN(0, "stdio", &report.use_stdio, "Use the stdio interface"), |
63299f057 perf_counter tool... |
470 |
OPT_STRING('s', "sort", &sort_order, "key[,key2...]", |
b25bcf2f1 perf report: Tidy... |
471 |
"sort by key(s): pid, comm, dso, symbol, parent"), |
a1645ce12 perf: 'perf kvm' ... |
472 473 |
OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, "Show sample percentage for different cpu modes"), |
b25bcf2f1 perf report: Tidy... |
474 475 |
OPT_STRING('p', "parent", &parent_pattern, "regex", "regex filter to identify parent, see: '--sort parent'"), |
d599db3fc perf report: Gene... |
476 |
OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other, |
b8e6d8297 perf report: Filt... |
477 |
"Only display entries with parent-match"), |
6581f6e35 perf report: Docu... |
478 479 |
OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order", "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit and callchain order. " |
d797fdc5c perf tools: Add i... |
480 |
"Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt), |
fa372aae3 perf report: Grou... |
481 482 |
OPT_BOOLEAN('G', "inverted", &report.inverted_callchain, "alias for inverted call graph"), |
655000e7c perf symbols: Ado... |
483 |
OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", |
25903407d perf report: Add ... |
484 |
"only consider symbols in these dsos"), |
c8e667203 perf tools: make ... |
485 |
OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
cc8b88b15 perf report: Add ... |
486 |
"only consider symbols in these comms"), |
655000e7c perf symbols: Ado... |
487 |
OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
7bec7a913 perf report: Add ... |
488 |
"only consider these symbols"), |
655000e7c perf symbols: Ado... |
489 |
OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str, |
52d422de2 perf report: Adju... |
490 491 |
"width[,width...]", "don't try to adjust column width, use these fixed values"), |
c410a3388 perf symbols: Mov... |
492 |
OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", |
52d422de2 perf report: Adju... |
493 494 |
"separator for columns, no spaces will be added between " "columns '.' is reserved."), |
fa372aae3 perf report: Grou... |
495 |
OPT_BOOLEAN('U', "hide-unresolved", &report.hide_unresolved, |
71289be76 perf report: Add ... |
496 |
"Only display entries resolved to a symbol"), |
ec5761eab perf symbols: Add... |
497 498 |
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", "Look for files with symbols relative to this directory"), |
c8e667203 perf tools: make ... |
499 |
OPT_STRING('C', "cpu", &report.cpu_list, "cpu", |
fa372aae3 perf report: Grou... |
500 501 |
"list of cpus to profile"), OPT_BOOLEAN('I', "show-info", &report.show_full_info, |
fbe96f29c perf tools: Make ... |
502 |
"Display extended information about perf.data file"), |
64c6f0c7f perf tools: Make ... |
503 504 505 506 |
OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src, "Interleave source code with assembly code (default)"), OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw, "Display raw encoding of assembly instructions (default)"), |
f69b64f73 perf: Support set... |
507 508 |
OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", "Specify disassembler style (e.g. -M intel for intel syntax)"), |
3f2728bdb perf report: Add ... |
509 510 |
OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, "Show a column with the sum of periods"), |
53cb8bc2a perf record: Conv... |
511 |
OPT_END() |
d20deb64e perf tools: Pass ... |
512 |
}; |
53cb8bc2a perf record: Conv... |
513 |
|
655000e7c perf symbols: Ado... |
514 |
argc = parse_options(argc, argv, options, report_usage, 0); |
fa372aae3 perf report: Grou... |
515 |
if (report.use_stdio) |
8b9e74eb8 perf tools: Add -... |
516 |
use_browser = 0; |
fa372aae3 perf report: Grou... |
517 |
else if (report.use_tui) |
8b9e74eb8 perf tools: Add -... |
518 |
use_browser = 1; |
fa372aae3 perf report: Grou... |
519 |
if (report.inverted_callchain) |
d797fdc5c perf tools: Add i... |
520 |
callchain_param.order = ORDER_CALLER; |
efad14150 perf report: Acce... |
521 522 523 524 525 526 |
if (!report.input_name || !strlen(report.input_name)) { if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode)) report.input_name = "-"; else report.input_name = "perf.data"; } |
fa372aae3 perf report: Grou... |
527 |
if (strcmp(report.input_name, "-") != 0) |
229ade9ba perf tools: Don't... |
528 |
setup_browser(true); |
8b9e74eb8 perf tools: Add -... |
529 530 |
else use_browser = 0; |
efad14150 perf report: Acce... |
531 |
|
ef7b93a11 perf report: Libr... |
532 533 534 535 536 |
/* * Only in the newt browser we are doing integrated annotation, * so don't allocate extra space that won't be used in the stdio * implementation. */ |
80d50cae1 perf ui: Add sear... |
537 |
if (use_browser > 0) { |
78f7defed perf annotate: Mo... |
538 |
symbol_conf.priv_size = sizeof(struct annotation); |
fa372aae3 perf report: Grou... |
539 |
report.annotate_init = symbol__annotate_init; |
80d50cae1 perf ui: Add sear... |
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
/* * For searching by name on the "Browse map details". * providing it only in verbose mode not to bloat too * much struct symbol. */ if (verbose) { /* * XXX: Need to provide a less kludgy way to ask for * more space per symbol, the u32 is for the index on * the ui browser. * See symbol__browser_index. */ symbol_conf.priv_size += sizeof(u32); symbol_conf.sort_by_name = true; } } |
655000e7c perf symbols: Ado... |
556 |
|
75be6cf48 perf symbols: Mak... |
557 |
if (symbol__init() < 0) |
b32d133ae perf symbols: Sim... |
558 |
return -1; |
53cb8bc2a perf record: Conv... |
559 |
|
c8829c7a3 perf util: Remove... |
560 |
setup_sorting(report_usage, options); |
1aa167382 perf_counter: too... |
561 |
|
021191b35 perf report: Make... |
562 |
if (parent_pattern != default_parent_pattern) { |
2aefa4f73 perf tools: sort_... |
563 564 |
if (sort_dimension__add("parent") < 0) return -1; |
cb1955b86 perf tools: Only ... |
565 566 567 568 569 570 571 572 |
/* * Only show the parent fields if we explicitly * sort that way. If we only use parent machinery * for filtering, we don't want it. */ if (!strstr(sort_order, "parent")) sort_parent.elide = 1; |
021191b35 perf report: Make... |
573 |
} else |
d599db3fc perf report: Gene... |
574 |
symbol_conf.exclude_other = false; |
b8e6d8297 perf report: Filt... |
575 |
|
edc52deac perf report: Bail... |
576 577 578 579 580 |
/* * Any (unrecognized) arguments left? */ if (argc) usage_with_options(report_usage, options); |
655000e7c perf symbols: Ado... |
581 582 583 |
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout); sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout); |
25903407d perf report: Add ... |
584 |
|
d20deb64e perf tools: Pass ... |
585 |
return __cmd_report(&report); |
53cb8bc2a perf record: Conv... |
586 |
} |