aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-diff.c')
-rw-r--r--tools/perf/builtin-diff.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index f28799e94f2a..3b67ea2444bd 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -16,6 +16,7 @@
16#include "util/sort.h" 16#include "util/sort.h"
17#include "util/symbol.h" 17#include "util/symbol.h"
18#include "util/util.h" 18#include "util/util.h"
19#include "util/data.h"
19 20
20#include <stdlib.h> 21#include <stdlib.h>
21#include <math.h> 22#include <math.h>
@@ -42,7 +43,7 @@ struct diff_hpp_fmt {
42 43
43struct data__file { 44struct data__file {
44 struct perf_session *session; 45 struct perf_session *session;
45 const char *file; 46 struct perf_data_file file;
46 int idx; 47 int idx;
47 struct hists *hists; 48 struct hists *hists;
48 struct diff_hpp_fmt fmt[PERF_HPP_DIFF__MAX_INDEX]; 49 struct diff_hpp_fmt fmt[PERF_HPP_DIFF__MAX_INDEX];
@@ -302,11 +303,12 @@ static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair,
302 return -1; 303 return -1;
303} 304}
304 305
305static int hists__add_entry(struct hists *self, 306static int hists__add_entry(struct hists *hists,
306 struct addr_location *al, u64 period, 307 struct addr_location *al, u64 period,
307 u64 weight) 308 u64 weight, u64 transaction)
308{ 309{
309 if (__hists__add_entry(self, al, NULL, period, weight) != NULL) 310 if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight,
311 transaction) != NULL)
310 return 0; 312 return 0;
311 return -ENOMEM; 313 return -ENOMEM;
312} 314}
@@ -328,7 +330,8 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
328 if (al.filtered) 330 if (al.filtered)
329 return 0; 331 return 0;
330 332
331 if (hists__add_entry(&evsel->hists, &al, sample->period, sample->weight)) { 333 if (hists__add_entry(&evsel->hists, &al, sample->period,
334 sample->weight, sample->transaction)) {
332 pr_warning("problem incrementing symbol period, skipping event\n"); 335 pr_warning("problem incrementing symbol period, skipping event\n");
333 return -1; 336 return -1;
334 } 337 }
@@ -367,7 +370,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist)
367 list_for_each_entry(evsel, &evlist->entries, node) { 370 list_for_each_entry(evsel, &evlist->entries, node) {
368 struct hists *hists = &evsel->hists; 371 struct hists *hists = &evsel->hists;
369 372
370 hists__collapse_resort(hists); 373 hists__collapse_resort(hists, NULL);
371 } 374 }
372} 375}
373 376
@@ -599,7 +602,7 @@ static void data__fprintf(void)
599 602
600 data__for_each_file(i, d) 603 data__for_each_file(i, d)
601 fprintf(stdout, "# [%d] %s %s\n", 604 fprintf(stdout, "# [%d] %s %s\n",
602 d->idx, d->file, 605 d->idx, d->file.path,
603 !d->idx ? "(Baseline)" : ""); 606 !d->idx ? "(Baseline)" : "");
604 607
605 fprintf(stdout, "#\n"); 608 fprintf(stdout, "#\n");
@@ -661,17 +664,16 @@ static int __cmd_diff(void)
661 int ret = -EINVAL, i; 664 int ret = -EINVAL, i;
662 665
663 data__for_each_file(i, d) { 666 data__for_each_file(i, d) {
664 d->session = perf_session__new(d->file, O_RDONLY, force, 667 d->session = perf_session__new(&d->file, false, &tool);
665 false, &tool);
666 if (!d->session) { 668 if (!d->session) {
667 pr_err("Failed to open %s\n", d->file); 669 pr_err("Failed to open %s\n", d->file.path);
668 ret = -ENOMEM; 670 ret = -ENOMEM;
669 goto out_delete; 671 goto out_delete;
670 } 672 }
671 673
672 ret = perf_session__process_events(d->session, &tool); 674 ret = perf_session__process_events(d->session, &tool);
673 if (ret) { 675 if (ret) {
674 pr_err("Failed to process %s\n", d->file); 676 pr_err("Failed to process %s\n", d->file.path);
675 goto out_delete; 677 goto out_delete;
676 } 678 }
677 679
@@ -1014,7 +1016,12 @@ static int data_init(int argc, const char **argv)
1014 return -ENOMEM; 1016 return -ENOMEM;
1015 1017
1016 data__for_each_file(i, d) { 1018 data__for_each_file(i, d) {
1017 d->file = use_default ? defaults[i] : argv[i]; 1019 struct perf_data_file *file = &d->file;
1020
1021 file->path = use_default ? defaults[i] : argv[i];
1022 file->mode = PERF_DATA_MODE_READ,
1023 file->force = force,
1024
1018 d->idx = i; 1025 d->idx = i;
1019 } 1026 }
1020 1027