blob: e13cfac0b0631ff4fce390aefe488ad0af832d53 [file] [log] [blame]
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -02001/*
2 * builtin-diff.c
3 *
4 * Builtin diff command: Analyze two perf.data input files, look up and read
5 * DSOs and symbol information, sort them and produce a diff.
6 */
7#include "builtin.h"
8
9#include "util/debug.h"
10#include "util/event.h"
11#include "util/hist.h"
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020012#include "util/evsel.h"
Jiri Olsa863e4512012-09-06 17:46:55 +020013#include "util/evlist.h"
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -020014#include "util/session.h"
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020015#include "util/tool.h"
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -020016#include "util/sort.h"
17#include "util/symbol.h"
18#include "util/util.h"
19
20#include <stdlib.h>
21
Arnaldo Carvalho de Meloc351c282009-12-16 13:49:27 -020022static char const *input_old = "perf.data.old",
23 *input_new = "perf.data";
Arnaldo Carvalho de Melo604c5c92009-12-16 14:09:53 -020024static char diff__default_sort_order[] = "dso,symbol";
Ian Munsiec0555642010-04-13 18:37:33 +100025static bool force;
Arnaldo Carvalho de Meloc351c282009-12-16 13:49:27 -020026static bool show_displacement;
Jiri Olsaa06d1432012-10-05 16:44:40 +020027static bool show_baseline_only;
Jiri Olsa96c47f12012-10-05 16:44:42 +020028static bool sort_compute;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -020029
Jiri Olsa7aaf6b32012-10-05 16:44:41 +020030enum {
31 COMPUTE_DELTA,
32 COMPUTE_RATIO,
33 COMPUTE_MAX,
34};
35
36const char *compute_names[COMPUTE_MAX] = {
37 [COMPUTE_DELTA] = "delta",
38 [COMPUTE_RATIO] = "ratio",
39};
40
41static int compute;
42
43static int setup_compute(const struct option *opt, const char *str,
44 int unset __maybe_unused)
45{
46 int *cp = (int *) opt->value;
47 unsigned i;
48
49 if (!str) {
50 *cp = COMPUTE_DELTA;
51 return 0;
52 }
53
Jiri Olsa96c47f12012-10-05 16:44:42 +020054 if (*str == '+') {
55 sort_compute = true;
56 str++;
57 if (!*str)
58 return 0;
59 }
60
Jiri Olsa7aaf6b32012-10-05 16:44:41 +020061 for (i = 0; i < COMPUTE_MAX; i++)
62 if (!strcmp(str, compute_names[i])) {
63 *cp = i;
64 return 0;
65 }
66
67 pr_err("Failed: '%s' is not computation method "
68 "(use 'delta' or 'ratio').\n", str);
69 return -EINVAL;
70}
71
Jiri Olsa96c47f12012-10-05 16:44:42 +020072static double get_period_percent(struct hist_entry *he, u64 period)
73{
74 u64 total = he->hists->stats.total_period;
75 return (period * 100.0) / total;
76}
77
78double perf_diff__compute_delta(struct hist_entry *he)
79{
80 struct hist_entry *pair = he->pair;
81 double new_percent = get_period_percent(he, he->stat.period);
82 double old_percent = pair ? get_period_percent(pair, pair->stat.period) : 0.0;
83
84 he->diff.period_ratio_delta = new_percent - old_percent;
85 he->diff.computed = true;
86 return he->diff.period_ratio_delta;
87}
88
89double perf_diff__compute_ratio(struct hist_entry *he)
90{
91 struct hist_entry *pair = he->pair;
92 double new_period = he->stat.period;
93 double old_period = pair ? pair->stat.period : 0;
94
95 he->diff.computed = true;
96 he->diff.period_ratio = pair ? (new_period / old_period) : 0;
97 return he->diff.period_ratio;
98}
99
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300100static int hists__add_entry(struct hists *self,
Arnaldo Carvalho de Meloc82ee822010-05-14 14:19:35 -0300101 struct addr_location *al, u64 period)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200102{
Arnaldo Carvalho de Meloc82ee822010-05-14 14:19:35 -0300103 if (__hists__add_entry(self, al, NULL, period) != NULL)
Arnaldo Carvalho de Melo28e2a102010-05-09 13:02:23 -0300104 return 0;
105 return -ENOMEM;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200106}
107
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300108static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200109 union perf_event *event,
Arnaldo Carvalho de Melo8d50e5b2011-01-29 13:02:00 -0200110 struct perf_sample *sample,
Jiri Olsa863e4512012-09-06 17:46:55 +0200111 struct perf_evsel *evsel,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200112 struct machine *machine)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200113{
114 struct addr_location al;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200115
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200116 if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) {
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200117 pr_warning("problem processing %d event, skipping it.\n",
118 event->header.type);
119 return -1;
120 }
121
Arnaldo Carvalho de Melocdbae312009-12-28 22:48:35 -0200122 if (al.filtered || al.sym == NULL)
Arnaldo Carvalho de Meloc410a332009-12-15 20:04:41 -0200123 return 0;
124
Jiri Olsa863e4512012-09-06 17:46:55 +0200125 if (hists__add_entry(&evsel->hists, &al, sample->period)) {
Arnaldo Carvalho de Meloc82ee822010-05-14 14:19:35 -0300126 pr_warning("problem incrementing symbol period, skipping event\n");
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200127 return -1;
128 }
129
Jiri Olsa863e4512012-09-06 17:46:55 +0200130 evsel->hists.stats.total_period += sample->period;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200131 return 0;
132}
133
Jiri Olsa863e4512012-09-06 17:46:55 +0200134static struct perf_tool tool = {
135 .sample = diff__process_sample_event,
136 .mmap = perf_event__process_mmap,
137 .comm = perf_event__process_comm,
138 .exit = perf_event__process_task,
139 .fork = perf_event__process_task,
140 .lost = perf_event__process_lost,
141 .ordered_samples = true,
142 .ordering_requires_timestamps = true,
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200143};
144
Jiri Olsadd464342012-10-04 21:49:36 +0900145static void insert_hist_entry_by_name(struct rb_root *root,
146 struct hist_entry *he)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200147{
148 struct rb_node **p = &root->rb_node;
149 struct rb_node *parent = NULL;
150 struct hist_entry *iter;
151
152 while (*p != NULL) {
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200153 parent = *p;
154 iter = rb_entry(parent, struct hist_entry, rb_node);
Arnaldo Carvalho de Melo9c443df2009-12-28 22:48:36 -0200155 if (hist_entry__cmp(he, iter) < 0)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200156 p = &(*p)->rb_left;
Arnaldo Carvalho de Melo9c443df2009-12-28 22:48:36 -0200157 else
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200158 p = &(*p)->rb_right;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200159 }
160
161 rb_link_node(&he->rb_node, parent, p);
162 rb_insert_color(&he->rb_node, root);
163}
164
Jiri Olsadd464342012-10-04 21:49:36 +0900165static void hists__name_resort(struct hists *self, bool sort)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200166{
167 unsigned long position = 1;
168 struct rb_root tmp = RB_ROOT;
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300169 struct rb_node *next = rb_first(&self->entries);
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200170
171 while (next != NULL) {
172 struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node);
173
174 next = rb_next(&n->rb_node);
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200175 n->position = position++;
Jiri Olsadd464342012-10-04 21:49:36 +0900176
177 if (sort) {
178 rb_erase(&n->rb_node, &self->entries);
179 insert_hist_entry_by_name(&tmp, n);
180 }
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200181 }
182
Jiri Olsadd464342012-10-04 21:49:36 +0900183 if (sort)
184 self->entries = tmp;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200185}
186
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300187static struct hist_entry *hists__find_entry(struct hists *self,
188 struct hist_entry *he)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200189{
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300190 struct rb_node *n = self->entries.rb_node;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200191
192 while (n) {
193 struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node);
Arnaldo Carvalho de Melo9c443df2009-12-28 22:48:36 -0200194 int64_t cmp = hist_entry__cmp(he, iter);
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200195
Arnaldo Carvalho de Melo9c443df2009-12-28 22:48:36 -0200196 if (cmp < 0)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200197 n = n->rb_left;
Arnaldo Carvalho de Melo9c443df2009-12-28 22:48:36 -0200198 else if (cmp > 0)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200199 n = n->rb_right;
Jiri Olsadd464342012-10-04 21:49:36 +0900200 else
Arnaldo Carvalho de Melo9c443df2009-12-28 22:48:36 -0200201 return iter;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200202 }
203
204 return NULL;
205}
206
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300207static void hists__match(struct hists *older, struct hists *newer)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200208{
209 struct rb_node *nd;
210
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300211 for (nd = rb_first(&newer->entries); nd; nd = rb_next(nd)) {
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200212 struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node);
Arnaldo Carvalho de Melo1c02c4d2010-05-10 13:04:11 -0300213 pos->pair = hists__find_entry(older, pos);
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200214 }
215}
216
Jiri Olsa863e4512012-09-06 17:46:55 +0200217static struct perf_evsel *evsel_match(struct perf_evsel *evsel,
218 struct perf_evlist *evlist)
219{
220 struct perf_evsel *e;
221
222 list_for_each_entry(e, &evlist->entries, node)
223 if (perf_evsel__match2(evsel, e))
224 return e;
225
226 return NULL;
227}
228
Jiri Olsadd464342012-10-04 21:49:36 +0900229static void perf_evlist__resort_hists(struct perf_evlist *evlist, bool name)
230{
231 struct perf_evsel *evsel;
232
233 list_for_each_entry(evsel, &evlist->entries, node) {
234 struct hists *hists = &evsel->hists;
235
236 hists__output_resort(hists);
237
238 /*
239 * The hists__name_resort only sets possition
240 * if name is false.
241 */
242 if (name || ((!name) && show_displacement))
243 hists__name_resort(hists, name);
244 }
245}
246
Jiri Olsaa06d1432012-10-05 16:44:40 +0200247static void hists__baseline_only(struct hists *hists)
248{
249 struct rb_node *next = rb_first(&hists->entries);
250
251 while (next != NULL) {
252 struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node);
253
254 next = rb_next(&he->rb_node);
255 if (!he->pair) {
256 rb_erase(&he->rb_node, &hists->entries);
257 hist_entry__free(he);
258 }
259 }
260}
261
Jiri Olsa96c47f12012-10-05 16:44:42 +0200262static void hists__precompute(struct hists *hists)
263{
264 struct rb_node *next = rb_first(&hists->entries);
265
266 while (next != NULL) {
267 struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node);
268
269 next = rb_next(&he->rb_node);
270
271 switch (compute) {
272 case COMPUTE_DELTA:
273 perf_diff__compute_delta(he);
274 break;
275 case COMPUTE_RATIO:
276 perf_diff__compute_ratio(he);
277 break;
278 default:
279 BUG_ON(1);
280 }
281 }
282}
283
284static int64_t cmp_doubles(double l, double r)
285{
286 if (l > r)
287 return -1;
288 else if (l < r)
289 return 1;
290 else
291 return 0;
292}
293
294static int64_t
295hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
296 int c)
297{
298 switch (c) {
299 case COMPUTE_DELTA:
300 {
301 double l = left->diff.period_ratio_delta;
302 double r = right->diff.period_ratio_delta;
303
304 return cmp_doubles(l, r);
305 }
306 case COMPUTE_RATIO:
307 {
308 double l = left->diff.period_ratio;
309 double r = right->diff.period_ratio;
310
311 return cmp_doubles(l, r);
312 }
313 default:
314 BUG_ON(1);
315 }
316
317 return 0;
318}
319
320static void insert_hist_entry_by_compute(struct rb_root *root,
321 struct hist_entry *he,
322 int c)
323{
324 struct rb_node **p = &root->rb_node;
325 struct rb_node *parent = NULL;
326 struct hist_entry *iter;
327
328 while (*p != NULL) {
329 parent = *p;
330 iter = rb_entry(parent, struct hist_entry, rb_node);
331 if (hist_entry__cmp_compute(he, iter, c) < 0)
332 p = &(*p)->rb_left;
333 else
334 p = &(*p)->rb_right;
335 }
336
337 rb_link_node(&he->rb_node, parent, p);
338 rb_insert_color(&he->rb_node, root);
339}
340
341static void hists__compute_resort(struct hists *hists)
342{
343 struct rb_root tmp = RB_ROOT;
344 struct rb_node *next = rb_first(&hists->entries);
345
346 while (next != NULL) {
347 struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node);
348
349 next = rb_next(&he->rb_node);
350
351 rb_erase(&he->rb_node, &hists->entries);
352 insert_hist_entry_by_compute(&tmp, he, compute);
353 }
354
355 hists->entries = tmp;
356}
357
Jiri Olsaa06d1432012-10-05 16:44:40 +0200358static void hists__process(struct hists *old, struct hists *new)
359{
360 hists__match(old, new);
361
362 if (show_baseline_only)
363 hists__baseline_only(new);
364
Jiri Olsa96c47f12012-10-05 16:44:42 +0200365 if (sort_compute) {
366 hists__precompute(new);
367 hists__compute_resort(new);
368 }
369
Jiri Olsaa06d1432012-10-05 16:44:40 +0200370 hists__fprintf(new, true, 0, 0, stdout);
371}
372
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200373static int __cmd_diff(void)
374{
375 int ret, i;
Jiri Olsa4bf9ce12012-03-22 14:37:26 +0100376#define older (session[0])
377#define newer (session[1])
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200378 struct perf_session *session[2];
Jiri Olsa863e4512012-09-06 17:46:55 +0200379 struct perf_evlist *evlist_new, *evlist_old;
380 struct perf_evsel *evsel;
381 bool first = true;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200382
Jiri Olsa4bf9ce12012-03-22 14:37:26 +0100383 older = perf_session__new(input_old, O_RDONLY, force, false,
Jiri Olsa863e4512012-09-06 17:46:55 +0200384 &tool);
Jiri Olsa4bf9ce12012-03-22 14:37:26 +0100385 newer = perf_session__new(input_new, O_RDONLY, force, false,
Jiri Olsa863e4512012-09-06 17:46:55 +0200386 &tool);
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200387 if (session[0] == NULL || session[1] == NULL)
388 return -ENOMEM;
389
390 for (i = 0; i < 2; ++i) {
Jiri Olsa863e4512012-09-06 17:46:55 +0200391 ret = perf_session__process_events(session[i], &tool);
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200392 if (ret)
393 goto out_delete;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200394 }
395
Jiri Olsa863e4512012-09-06 17:46:55 +0200396 evlist_old = older->evlist;
397 evlist_new = newer->evlist;
Arnaldo Carvalho de Melo9c443df2009-12-28 22:48:36 -0200398
Jiri Olsadd464342012-10-04 21:49:36 +0900399 perf_evlist__resort_hists(evlist_old, true);
400 perf_evlist__resort_hists(evlist_new, false);
Jiri Olsa863e4512012-09-06 17:46:55 +0200401
402 list_for_each_entry(evsel, &evlist_new->entries, node) {
403 struct perf_evsel *evsel_old;
404
405 evsel_old = evsel_match(evsel, evlist_old);
406 if (!evsel_old)
407 continue;
408
409 fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
410 perf_evsel__name(evsel));
411
412 first = false;
413
Jiri Olsaa06d1432012-10-05 16:44:40 +0200414 hists__process(&evsel_old->hists, &evsel->hists);
Jiri Olsa863e4512012-09-06 17:46:55 +0200415 }
416
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200417out_delete:
418 for (i = 0; i < 2; ++i)
419 perf_session__delete(session[i]);
420 return ret;
Jiri Olsa4bf9ce12012-03-22 14:37:26 +0100421#undef older
422#undef newer
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200423}
424
Arnaldo Carvalho de Melo0422a4f2009-12-18 16:35:58 -0200425static const char * const diff_usage[] = {
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200426 "perf diff [<options>] [old_file] [new_file]",
Arnaldo Carvalho de Melo0422a4f2009-12-18 16:35:58 -0200427 NULL,
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200428};
429
430static const struct option options[] = {
Ian Munsiec0555642010-04-13 18:37:33 +1000431 OPT_INCR('v', "verbose", &verbose,
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200432 "be more verbose (show symbol address, etc)"),
Shawn Bohrer34295552010-11-30 19:57:11 -0600433 OPT_BOOLEAN('M', "displacement", &show_displacement,
Arnaldo Carvalho de Meloc351c282009-12-16 13:49:27 -0200434 "Show position displacement relative to baseline"),
Jiri Olsaa06d1432012-10-05 16:44:40 +0200435 OPT_BOOLEAN('b', "baseline-only", &show_baseline_only,
436 "Show only items with match in baseline"),
Jiri Olsa7aaf6b32012-10-05 16:44:41 +0200437 OPT_CALLBACK('c', "compute", &compute, "delta,ratio (default delta)",
438 "Entries differential computation selection",
439 setup_compute),
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200440 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
441 "dump raw trace in ASCII"),
442 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
443 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
444 "load module symbols - WARNING: use only with -k and LIVE kernel"),
Arnaldo Carvalho de Meloc410a332009-12-15 20:04:41 -0200445 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
446 "only consider symbols in these dsos"),
447 OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
448 "only consider symbols in these comms"),
449 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
450 "only consider these symbols"),
Arnaldo Carvalho de Meloc351c282009-12-16 13:49:27 -0200451 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
452 "sort by key(s): pid, comm, dso, symbol, parent"),
453 OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
454 "separator for columns, no spaces will be added between "
455 "columns '.' is reserved."),
David Ahernec5761e2010-12-09 13:27:07 -0700456 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
457 "Look for files with symbols relative to this directory"),
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200458 OPT_END()
459};
460
Jiri Olsa1d778222012-10-04 21:49:39 +0900461static void ui_init(void)
462{
463 perf_hpp__init();
464
465 /* No overhead column. */
466 perf_hpp__column_enable(PERF_HPP__OVERHEAD, false);
467
Jiri Olsa7aaf6b32012-10-05 16:44:41 +0200468 /* Display baseline/delta/ratio/displacement columns. */
Jiri Olsa1d778222012-10-04 21:49:39 +0900469 perf_hpp__column_enable(PERF_HPP__BASELINE, true);
Jiri Olsa7aaf6b32012-10-05 16:44:41 +0200470
471 switch (compute) {
472 case COMPUTE_DELTA:
473 perf_hpp__column_enable(PERF_HPP__DELTA, true);
474 break;
475 case COMPUTE_RATIO:
476 perf_hpp__column_enable(PERF_HPP__RATIO, true);
477 break;
478 default:
479 BUG_ON(1);
480 };
Jiri Olsa1d778222012-10-04 21:49:39 +0900481
482 if (show_displacement)
483 perf_hpp__column_enable(PERF_HPP__DISPL, true);
484}
485
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300486int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200487{
Arnaldo Carvalho de Melo604c5c92009-12-16 14:09:53 -0200488 sort_order = diff__default_sort_order;
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200489 argc = parse_options(argc, argv, options, diff_usage, 0);
490 if (argc) {
491 if (argc > 2)
492 usage_with_options(diff_usage, options);
493 if (argc == 2) {
494 input_old = argv[0];
495 input_new = argv[1];
496 } else
497 input_new = argv[0];
Zhang, Yanmina1645ce2010-04-19 13:32:50 +0800498 } else if (symbol_conf.default_guest_vmlinux_name ||
499 symbol_conf.default_guest_kallsyms) {
500 input_old = "perf.data.host";
501 input_new = "perf.data.guest";
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200502 }
503
Arnaldo Carvalho de Meloc351c282009-12-16 13:49:27 -0200504 symbol_conf.exclude_other = false;
Arnaldo Carvalho de Melo655000e2009-12-15 20:04:40 -0200505 if (symbol__init() < 0)
506 return -1;
507
Jiri Olsa1d778222012-10-04 21:49:39 +0900508 ui_init();
509
Arnaldo Carvalho de Melo655000e2009-12-15 20:04:40 -0200510 setup_sorting(diff_usage, options);
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200511 setup_pager();
Arnaldo Carvalho de Meloc351c282009-12-16 13:49:27 -0200512
513 sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", NULL);
514 sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", NULL);
515 sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", NULL);
516
Arnaldo Carvalho de Melo86a9eee2009-12-14 20:09:31 -0200517 return __cmd_diff();
518}