aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 7a5dc7e5c577..f15731a3d438 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * builtin-annotate.c 3 * builtin-annotate.c
3 * 4 *
@@ -177,14 +178,11 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
177 */ 178 */
178 process_branch_stack(sample->branch_stack, al, sample); 179 process_branch_stack(sample->branch_stack, al, sample);
179 180
180 sample->period = 1;
181 sample->weight = 1;
182
183 he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true); 181 he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true);
184 if (he == NULL) 182 if (he == NULL)
185 return -ENOMEM; 183 return -ENOMEM;
186 184
187 ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 185 ret = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
188 hists__inc_nr_samples(hists, true); 186 hists__inc_nr_samples(hists, true);
189 return ret; 187 return ret;
190} 188}
@@ -359,7 +357,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
359 } 357 }
360 358
361 if (total_nr_samples == 0) { 359 if (total_nr_samples == 0) {
362 ui__error("The %s file has no samples!\n", session->file->path); 360 ui__error("The %s file has no samples!\n", session->data->file.path);
363 goto out; 361 goto out;
364 } 362 }
365 363
@@ -397,21 +395,23 @@ int cmd_annotate(int argc, const char **argv)
397 .namespaces = perf_event__process_namespaces, 395 .namespaces = perf_event__process_namespaces,
398 .attr = perf_event__process_attr, 396 .attr = perf_event__process_attr,
399 .build_id = perf_event__process_build_id, 397 .build_id = perf_event__process_build_id,
398 .tracing_data = perf_event__process_tracing_data,
399 .feature = perf_event__process_feature,
400 .ordered_events = true, 400 .ordered_events = true,
401 .ordering_requires_timestamps = true, 401 .ordering_requires_timestamps = true,
402 }, 402 },
403 }; 403 };
404 struct perf_data_file file = { 404 struct perf_data data = {
405 .mode = PERF_DATA_MODE_READ, 405 .mode = PERF_DATA_MODE_READ,
406 }; 406 };
407 const struct option options[] = { 407 struct option options[] = {
408 OPT_STRING('i', "input", &input_name, "file", 408 OPT_STRING('i', "input", &input_name, "file",
409 "input file name"), 409 "input file name"),
410 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", 410 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
411 "only consider symbols in these dsos"), 411 "only consider symbols in these dsos"),
412 OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol", 412 OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol",
413 "symbol to annotate"), 413 "symbol to annotate"),
414 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), 414 OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"),
415 OPT_INCR('v', "verbose", &verbose, 415 OPT_INCR('v', "verbose", &verbose,
416 "be more verbose (show symbol address, etc)"), 416 "be more verbose (show symbol address, etc)"),
417 OPT_BOOLEAN('q', "quiet", &quiet, "do now show any message"), 417 OPT_BOOLEAN('q', "quiet", &quiet, "do now show any message"),
@@ -446,13 +446,20 @@ int cmd_annotate(int argc, const char **argv)
446 "Show event group information together"), 446 "Show event group information together"),
447 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, 447 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
448 "Show a column with the sum of periods"), 448 "Show a column with the sum of periods"),
449 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
450 "Show a column with the number of samples"),
449 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", 451 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
450 "'always' (default), 'never' or 'auto' only applicable to --stdio mode", 452 "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
451 stdio__config_color, "always"), 453 stdio__config_color, "always"),
452 OPT_END() 454 OPT_END()
453 }; 455 };
454 int ret = hists__init(); 456 int ret;
457
458 set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
459 set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
460
455 461
462 ret = hists__init();
456 if (ret < 0) 463 if (ret < 0)
457 return ret; 464 return ret;
458 465
@@ -468,12 +475,17 @@ int cmd_annotate(int argc, const char **argv)
468 annotate.sym_hist_filter = argv[0]; 475 annotate.sym_hist_filter = argv[0];
469 } 476 }
470 477
478 if (symbol_conf.show_nr_samples && annotate.use_gtk) {
479 pr_err("--show-nr-samples is not available in --gtk mode at this time\n");
480 return ret;
481 }
482
471 if (quiet) 483 if (quiet)
472 perf_quiet_option(); 484 perf_quiet_option();
473 485
474 file.path = input_name; 486 data.file.path = input_name;
475 487
476 annotate.session = perf_session__new(&file, false, &annotate.tool); 488 annotate.session = perf_session__new(&data, false, &annotate.tool);
477 if (annotate.session == NULL) 489 if (annotate.session == NULL)
478 return -1; 490 return -1;
479 491