Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 1 | /* |
| 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 Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 12 | #include "util/evsel.h" |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 13 | #include "util/evlist.h" |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 14 | #include "util/session.h" |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 15 | #include "util/tool.h" |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 16 | #include "util/sort.h" |
| 17 | #include "util/symbol.h" |
| 18 | #include "util/util.h" |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 22 | static char const *input_old = "perf.data.old", |
| 23 | *input_new = "perf.data"; |
Arnaldo Carvalho de Melo | 604c5c9 | 2009-12-16 14:09:53 -0200 | [diff] [blame] | 24 | static char diff__default_sort_order[] = "dso,symbol"; |
Ian Munsie | c055564 | 2010-04-13 18:37:33 +1000 | [diff] [blame] | 25 | static bool force; |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 26 | static bool show_displacement; |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame^] | 27 | static bool show_baseline_only; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 28 | |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 29 | static int hists__add_entry(struct hists *self, |
Arnaldo Carvalho de Melo | c82ee82 | 2010-05-14 14:19:35 -0300 | [diff] [blame] | 30 | struct addr_location *al, u64 period) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 31 | { |
Arnaldo Carvalho de Melo | c82ee82 | 2010-05-14 14:19:35 -0300 | [diff] [blame] | 32 | if (__hists__add_entry(self, al, NULL, period) != NULL) |
Arnaldo Carvalho de Melo | 28e2a10 | 2010-05-09 13:02:23 -0300 | [diff] [blame] | 33 | return 0; |
| 34 | return -ENOMEM; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 35 | } |
| 36 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 37 | static int diff__process_sample_event(struct perf_tool *tool __maybe_unused, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 38 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8d50e5b | 2011-01-29 13:02:00 -0200 | [diff] [blame] | 39 | struct perf_sample *sample, |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 40 | struct perf_evsel *evsel, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 41 | struct machine *machine) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 42 | { |
| 43 | struct addr_location al; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 44 | |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 45 | if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) { |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 46 | pr_warning("problem processing %d event, skipping it.\n", |
| 47 | event->header.type); |
| 48 | return -1; |
| 49 | } |
| 50 | |
Arnaldo Carvalho de Melo | cdbae31 | 2009-12-28 22:48:35 -0200 | [diff] [blame] | 51 | if (al.filtered || al.sym == NULL) |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 52 | return 0; |
| 53 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 54 | if (hists__add_entry(&evsel->hists, &al, sample->period)) { |
Arnaldo Carvalho de Melo | c82ee82 | 2010-05-14 14:19:35 -0300 | [diff] [blame] | 55 | pr_warning("problem incrementing symbol period, skipping event\n"); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 56 | return -1; |
| 57 | } |
| 58 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 59 | evsel->hists.stats.total_period += sample->period; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 60 | return 0; |
| 61 | } |
| 62 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 63 | static struct perf_tool tool = { |
| 64 | .sample = diff__process_sample_event, |
| 65 | .mmap = perf_event__process_mmap, |
| 66 | .comm = perf_event__process_comm, |
| 67 | .exit = perf_event__process_task, |
| 68 | .fork = perf_event__process_task, |
| 69 | .lost = perf_event__process_lost, |
| 70 | .ordered_samples = true, |
| 71 | .ordering_requires_timestamps = true, |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 72 | }; |
| 73 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 74 | static void insert_hist_entry_by_name(struct rb_root *root, |
| 75 | struct hist_entry *he) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 76 | { |
| 77 | struct rb_node **p = &root->rb_node; |
| 78 | struct rb_node *parent = NULL; |
| 79 | struct hist_entry *iter; |
| 80 | |
| 81 | while (*p != NULL) { |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 82 | parent = *p; |
| 83 | iter = rb_entry(parent, struct hist_entry, rb_node); |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 84 | if (hist_entry__cmp(he, iter) < 0) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 85 | p = &(*p)->rb_left; |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 86 | else |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 87 | p = &(*p)->rb_right; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | rb_link_node(&he->rb_node, parent, p); |
| 91 | rb_insert_color(&he->rb_node, root); |
| 92 | } |
| 93 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 94 | static void hists__name_resort(struct hists *self, bool sort) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 95 | { |
| 96 | unsigned long position = 1; |
| 97 | struct rb_root tmp = RB_ROOT; |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 98 | struct rb_node *next = rb_first(&self->entries); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 99 | |
| 100 | while (next != NULL) { |
| 101 | struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node); |
| 102 | |
| 103 | next = rb_next(&n->rb_node); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 104 | n->position = position++; |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 105 | |
| 106 | if (sort) { |
| 107 | rb_erase(&n->rb_node, &self->entries); |
| 108 | insert_hist_entry_by_name(&tmp, n); |
| 109 | } |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 110 | } |
| 111 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 112 | if (sort) |
| 113 | self->entries = tmp; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 114 | } |
| 115 | |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 116 | static struct hist_entry *hists__find_entry(struct hists *self, |
| 117 | struct hist_entry *he) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 118 | { |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 119 | struct rb_node *n = self->entries.rb_node; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 120 | |
| 121 | while (n) { |
| 122 | struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node); |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 123 | int64_t cmp = hist_entry__cmp(he, iter); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 124 | |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 125 | if (cmp < 0) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 126 | n = n->rb_left; |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 127 | else if (cmp > 0) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 128 | n = n->rb_right; |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 129 | else |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 130 | return iter; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | return NULL; |
| 134 | } |
| 135 | |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 136 | static void hists__match(struct hists *older, struct hists *newer) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 137 | { |
| 138 | struct rb_node *nd; |
| 139 | |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 140 | for (nd = rb_first(&newer->entries); nd; nd = rb_next(nd)) { |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 141 | struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node); |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 142 | pos->pair = hists__find_entry(older, pos); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 146 | static struct perf_evsel *evsel_match(struct perf_evsel *evsel, |
| 147 | struct perf_evlist *evlist) |
| 148 | { |
| 149 | struct perf_evsel *e; |
| 150 | |
| 151 | list_for_each_entry(e, &evlist->entries, node) |
| 152 | if (perf_evsel__match2(evsel, e)) |
| 153 | return e; |
| 154 | |
| 155 | return NULL; |
| 156 | } |
| 157 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 158 | static void perf_evlist__resort_hists(struct perf_evlist *evlist, bool name) |
| 159 | { |
| 160 | struct perf_evsel *evsel; |
| 161 | |
| 162 | list_for_each_entry(evsel, &evlist->entries, node) { |
| 163 | struct hists *hists = &evsel->hists; |
| 164 | |
| 165 | hists__output_resort(hists); |
| 166 | |
| 167 | /* |
| 168 | * The hists__name_resort only sets possition |
| 169 | * if name is false. |
| 170 | */ |
| 171 | if (name || ((!name) && show_displacement)) |
| 172 | hists__name_resort(hists, name); |
| 173 | } |
| 174 | } |
| 175 | |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame^] | 176 | static void hists__baseline_only(struct hists *hists) |
| 177 | { |
| 178 | struct rb_node *next = rb_first(&hists->entries); |
| 179 | |
| 180 | while (next != NULL) { |
| 181 | struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); |
| 182 | |
| 183 | next = rb_next(&he->rb_node); |
| 184 | if (!he->pair) { |
| 185 | rb_erase(&he->rb_node, &hists->entries); |
| 186 | hist_entry__free(he); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | static void hists__process(struct hists *old, struct hists *new) |
| 192 | { |
| 193 | hists__match(old, new); |
| 194 | |
| 195 | if (show_baseline_only) |
| 196 | hists__baseline_only(new); |
| 197 | |
| 198 | hists__fprintf(new, true, 0, 0, stdout); |
| 199 | } |
| 200 | |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 201 | static int __cmd_diff(void) |
| 202 | { |
| 203 | int ret, i; |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 204 | #define older (session[0]) |
| 205 | #define newer (session[1]) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 206 | struct perf_session *session[2]; |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 207 | struct perf_evlist *evlist_new, *evlist_old; |
| 208 | struct perf_evsel *evsel; |
| 209 | bool first = true; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 210 | |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 211 | older = perf_session__new(input_old, O_RDONLY, force, false, |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 212 | &tool); |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 213 | newer = perf_session__new(input_new, O_RDONLY, force, false, |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 214 | &tool); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 215 | if (session[0] == NULL || session[1] == NULL) |
| 216 | return -ENOMEM; |
| 217 | |
| 218 | for (i = 0; i < 2; ++i) { |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 219 | ret = perf_session__process_events(session[i], &tool); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 220 | if (ret) |
| 221 | goto out_delete; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 222 | } |
| 223 | |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 224 | evlist_old = older->evlist; |
| 225 | evlist_new = newer->evlist; |
Arnaldo Carvalho de Melo | 9c443df | 2009-12-28 22:48:36 -0200 | [diff] [blame] | 226 | |
Jiri Olsa | dd46434 | 2012-10-04 21:49:36 +0900 | [diff] [blame] | 227 | perf_evlist__resort_hists(evlist_old, true); |
| 228 | perf_evlist__resort_hists(evlist_new, false); |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 229 | |
| 230 | list_for_each_entry(evsel, &evlist_new->entries, node) { |
| 231 | struct perf_evsel *evsel_old; |
| 232 | |
| 233 | evsel_old = evsel_match(evsel, evlist_old); |
| 234 | if (!evsel_old) |
| 235 | continue; |
| 236 | |
| 237 | fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n", |
| 238 | perf_evsel__name(evsel)); |
| 239 | |
| 240 | first = false; |
| 241 | |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame^] | 242 | hists__process(&evsel_old->hists, &evsel->hists); |
Jiri Olsa | 863e451 | 2012-09-06 17:46:55 +0200 | [diff] [blame] | 243 | } |
| 244 | |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 245 | out_delete: |
| 246 | for (i = 0; i < 2; ++i) |
| 247 | perf_session__delete(session[i]); |
| 248 | return ret; |
Jiri Olsa | 4bf9ce1 | 2012-03-22 14:37:26 +0100 | [diff] [blame] | 249 | #undef older |
| 250 | #undef newer |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 251 | } |
| 252 | |
Arnaldo Carvalho de Melo | 0422a4f | 2009-12-18 16:35:58 -0200 | [diff] [blame] | 253 | static const char * const diff_usage[] = { |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 254 | "perf diff [<options>] [old_file] [new_file]", |
Arnaldo Carvalho de Melo | 0422a4f | 2009-12-18 16:35:58 -0200 | [diff] [blame] | 255 | NULL, |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | static const struct option options[] = { |
Ian Munsie | c055564 | 2010-04-13 18:37:33 +1000 | [diff] [blame] | 259 | OPT_INCR('v', "verbose", &verbose, |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 260 | "be more verbose (show symbol address, etc)"), |
Shawn Bohrer | 3429555 | 2010-11-30 19:57:11 -0600 | [diff] [blame] | 261 | OPT_BOOLEAN('M', "displacement", &show_displacement, |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 262 | "Show position displacement relative to baseline"), |
Jiri Olsa | a06d143 | 2012-10-05 16:44:40 +0200 | [diff] [blame^] | 263 | OPT_BOOLEAN('b', "baseline-only", &show_baseline_only, |
| 264 | "Show only items with match in baseline"), |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 265 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
| 266 | "dump raw trace in ASCII"), |
| 267 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
| 268 | OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, |
| 269 | "load module symbols - WARNING: use only with -k and LIVE kernel"), |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 270 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", |
| 271 | "only consider symbols in these dsos"), |
| 272 | OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
| 273 | "only consider symbols in these comms"), |
| 274 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
| 275 | "only consider these symbols"), |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 276 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", |
| 277 | "sort by key(s): pid, comm, dso, symbol, parent"), |
| 278 | OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", |
| 279 | "separator for columns, no spaces will be added between " |
| 280 | "columns '.' is reserved."), |
David Ahern | ec5761e | 2010-12-09 13:27:07 -0700 | [diff] [blame] | 281 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", |
| 282 | "Look for files with symbols relative to this directory"), |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 283 | OPT_END() |
| 284 | }; |
| 285 | |
Jiri Olsa | 1d77822 | 2012-10-04 21:49:39 +0900 | [diff] [blame] | 286 | static void ui_init(void) |
| 287 | { |
| 288 | perf_hpp__init(); |
| 289 | |
| 290 | /* No overhead column. */ |
| 291 | perf_hpp__column_enable(PERF_HPP__OVERHEAD, false); |
| 292 | |
| 293 | /* Display baseline/delta/displacement columns. */ |
| 294 | perf_hpp__column_enable(PERF_HPP__BASELINE, true); |
| 295 | perf_hpp__column_enable(PERF_HPP__DELTA, true); |
| 296 | |
| 297 | if (show_displacement) |
| 298 | perf_hpp__column_enable(PERF_HPP__DISPL, true); |
| 299 | } |
| 300 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 301 | int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 302 | { |
Arnaldo Carvalho de Melo | 604c5c9 | 2009-12-16 14:09:53 -0200 | [diff] [blame] | 303 | sort_order = diff__default_sort_order; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 304 | argc = parse_options(argc, argv, options, diff_usage, 0); |
| 305 | if (argc) { |
| 306 | if (argc > 2) |
| 307 | usage_with_options(diff_usage, options); |
| 308 | if (argc == 2) { |
| 309 | input_old = argv[0]; |
| 310 | input_new = argv[1]; |
| 311 | } else |
| 312 | input_new = argv[0]; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 313 | } else if (symbol_conf.default_guest_vmlinux_name || |
| 314 | symbol_conf.default_guest_kallsyms) { |
| 315 | input_old = "perf.data.host"; |
| 316 | input_new = "perf.data.guest"; |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 317 | } |
| 318 | |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 319 | symbol_conf.exclude_other = false; |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 320 | if (symbol__init() < 0) |
| 321 | return -1; |
| 322 | |
Jiri Olsa | 1d77822 | 2012-10-04 21:49:39 +0900 | [diff] [blame] | 323 | ui_init(); |
| 324 | |
Arnaldo Carvalho de Melo | 655000e | 2009-12-15 20:04:40 -0200 | [diff] [blame] | 325 | setup_sorting(diff_usage, options); |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 326 | setup_pager(); |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 327 | |
| 328 | sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", NULL); |
| 329 | sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", NULL); |
| 330 | sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", NULL); |
| 331 | |
Arnaldo Carvalho de Melo | 86a9eee | 2009-12-14 20:09:31 -0200 | [diff] [blame] | 332 | return __cmd_diff(); |
| 333 | } |