blob: 806e0a286634a6bd7b7a766706c32426730c7727 [file] [log] [blame]
Ingo Molnar8035e422009-06-06 15:19:13 +02001/*
2 * builtin-annotate.c
3 *
4 * Builtin annotate command: Analyze the perf.data input file,
5 * look up and read DSOs and symbol information and display
6 * a histogram of results, along various sorting keys.
7 */
8#include "builtin.h"
9
10#include "util/util.h"
Ingo Molnar8035e422009-06-06 15:19:13 +020011#include "util/color.h"
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -030012#include <linux/list.h>
Ingo Molnar8035e422009-06-06 15:19:13 +020013#include "util/cache.h"
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -030014#include <linux/rbtree.h>
Ingo Molnar8035e422009-06-06 15:19:13 +020015#include "util/symbol.h"
Ingo Molnar8035e422009-06-06 15:19:13 +020016
17#include "perf.h"
Frederic Weisbecker8f288272009-08-16 22:05:48 +020018#include "util/debug.h"
Ingo Molnar8035e422009-06-06 15:19:13 +020019
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030020#include "util/evlist.h"
21#include "util/evsel.h"
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -020022#include "util/annotate.h"
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -020023#include "util/event.h"
Ingo Molnar8035e422009-06-06 15:19:13 +020024#include "util/parse-options.h"
25#include "util/parse-events.h"
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020026#include "util/thread.h"
John Kacurdd68ada2009-09-24 18:02:49 +020027#include "util/sort.h"
John Kacur3d1d07e2009-09-28 15:32:55 +020028#include "util/hist.h"
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020029#include "util/session.h"
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020030#include "util/tool.h"
Ingo Molnar8035e422009-06-06 15:19:13 +020031
Anton Blanchard5d67be92011-07-04 21:57:50 +100032#include <linux/bitmap.h>
33
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -020034struct perf_annotate {
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020035 struct perf_tool tool;
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -020036 char const *input_name;
37 bool force, use_tui, use_stdio;
38 bool full_paths;
39 bool print_line;
40 const char *sym_hist_filter;
41 const char *cpu_list;
42 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -020043};
Anton Blanchard5d67be92011-07-04 21:57:50 +100044
Arnaldo Carvalho de Melod04b35f2011-11-11 22:17:32 -020045static int perf_evsel__add_sample(struct perf_evsel *evsel,
46 struct perf_sample *sample,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -020047 struct addr_location *al,
48 struct perf_annotate *ann)
Ingo Molnar8035e422009-06-06 15:19:13 +020049{
Arnaldo Carvalho de Melo628ada02010-02-25 12:57:40 -030050 struct hist_entry *he;
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030051 int ret;
Arnaldo Carvalho de Melo628ada02010-02-25 12:57:40 -030052
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -020053 if (ann->sym_hist_filter != NULL &&
54 (al->sym == NULL ||
55 strcmp(ann->sym_hist_filter, al->sym->name) != 0)) {
Arnaldo Carvalho de Melo628ada02010-02-25 12:57:40 -030056 /* We're only interested in a symbol named sym_hist_filter */
57 if (al->sym != NULL) {
58 rb_erase(&al->sym->rb_node,
59 &al->map->dso->symbols[al->map->type]);
60 symbol__delete(al->sym);
61 }
62 return 0;
63 }
64
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030065 he = __hists__add_entry(&evsel->hists, al, NULL, 1);
Arnaldo Carvalho de Melo9735abf2009-10-03 10:42:45 -030066 if (he == NULL)
Ingo Molnar8035e422009-06-06 15:19:13 +020067 return -ENOMEM;
Arnaldo Carvalho de Melo628ada02010-02-25 12:57:40 -030068
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030069 ret = 0;
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -020070 if (he->ms.sym != NULL) {
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -020071 struct annotation *notes = symbol__annotation(he->ms.sym);
Arnaldo Carvalho de Melod04b35f2011-11-11 22:17:32 -020072 if (notes->src == NULL && symbol__alloc_hist(he->ms.sym) < 0)
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -020073 return -ENOMEM;
74
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030075 ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -020076 }
77
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030078 evsel->hists.stats.total_period += sample->period;
79 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
80 return ret;
Ingo Molnar8035e422009-06-06 15:19:13 +020081}
82
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020083static int process_sample_event(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -020084 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -020085 struct perf_sample *sample,
Arnaldo Carvalho de Melo9e69c212011-03-15 15:44:01 -030086 struct perf_evsel *evsel,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020087 struct machine *machine)
Ingo Molnar8035e422009-06-06 15:19:13 +020088{
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020089 struct perf_annotate *ann = container_of(tool, struct perf_annotate, tool);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020090 struct addr_location al;
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020091
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020092 if (perf_event__preprocess_sample(event, machine, &al, sample,
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -020093 symbol__annotate_init) < 0) {
Arnaldo Carvalho de Melo29a9f662010-02-03 16:52:06 -020094 pr_warning("problem processing %d event, skipping it.\n",
95 event->header.type);
Ingo Molnar8035e422009-06-06 15:19:13 +020096 return -1;
97 }
98
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -020099 if (ann->cpu_list && !test_bit(sample->cpu, ann->cpu_bitmap))
Anton Blanchard5d67be92011-07-04 21:57:50 +1000100 return 0;
101
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200102 if (!al.filtered && perf_evsel__add_sample(evsel, sample, &al, ann)) {
Arnaldo Carvalho de Melo29a9f662010-02-03 16:52:06 -0200103 pr_warning("problem incrementing symbol count, "
104 "skipping event\n");
Arnaldo Carvalho de Meloec218fc2009-10-03 20:30:48 -0300105 return -1;
Ingo Molnar8035e422009-06-06 15:19:13 +0200106 }
Ingo Molnar8035e422009-06-06 15:19:13 +0200107
108 return 0;
109}
110
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200111static int hist_entry__tty_annotate(struct hist_entry *he, int evidx,
112 struct perf_annotate *ann)
Ingo Molnar0b73da32009-06-06 15:48:52 +0200113{
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200114 return symbol__tty_annotate(he->ms.sym, he->ms.map, evidx,
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200115 ann->print_line, ann->full_paths, 0, 0);
Ingo Molnar0b73da32009-06-06 15:48:52 +0200116}
117
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200118static void hists__find_annotations(struct hists *self, int evidx,
119 struct perf_annotate *ann)
Ingo Molnar0b73da32009-06-06 15:48:52 +0200120{
Arnaldo Carvalho de Melob50e0032010-08-11 10:07:43 -0300121 struct rb_node *nd = rb_first(&self->entries), *next;
Arnaldo Carvalho de Melocf958002011-10-20 16:59:15 -0200122 int key = K_RIGHT;
Ingo Molnar0b73da32009-06-06 15:48:52 +0200123
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300124 while (nd) {
Arnaldo Carvalho de Meloed52ce22009-10-19 17:17:57 -0200125 struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200126 struct annotation *notes;
Ingo Molnar0b73da32009-06-06 15:48:52 +0200127
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300128 if (he->ms.sym == NULL || he->ms.map->dso->annotate_warned)
129 goto find_next;
Ingo Molnar0b73da32009-06-06 15:48:52 +0200130
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200131 notes = symbol__annotation(he->ms.sym);
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200132 if (notes->src == NULL) {
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300133find_next:
Arnaldo Carvalho de Melocf958002011-10-20 16:59:15 -0200134 if (key == K_LEFT)
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300135 nd = rb_prev(nd);
136 else
137 nd = rb_next(nd);
Arnaldo Carvalho de Meloe4204992009-10-20 14:25:40 -0200138 continue;
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300139 }
Arnaldo Carvalho de Meloe4204992009-10-20 14:25:40 -0200140
Arnaldo Carvalho de Melo62e34362010-05-26 13:22:26 -0300141 if (use_browser > 0) {
Arnaldo Carvalho de Melod04b35f2011-11-11 22:17:32 -0200142 key = hist_entry__tui_annotate(he, evidx, NULL, NULL, 0);
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300143 switch (key) {
Arnaldo Carvalho de Melocf958002011-10-20 16:59:15 -0200144 case K_RIGHT:
Arnaldo Carvalho de Melob50e0032010-08-11 10:07:43 -0300145 next = rb_next(nd);
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300146 break;
Arnaldo Carvalho de Melocf958002011-10-20 16:59:15 -0200147 case K_LEFT:
Arnaldo Carvalho de Melob50e0032010-08-11 10:07:43 -0300148 next = rb_prev(nd);
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300149 break;
Arnaldo Carvalho de Melob50e0032010-08-11 10:07:43 -0300150 default:
151 return;
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300152 }
Arnaldo Carvalho de Melob50e0032010-08-11 10:07:43 -0300153
154 if (next != NULL)
155 nd = next;
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300156 } else {
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200157 hist_entry__tty_annotate(he, evidx, ann);
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300158 nd = rb_next(nd);
159 /*
160 * Since we have a hist_entry per IP for the same
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200161 * symbol, free he->ms.sym->src to signal we already
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300162 * processed this symbol.
163 */
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200164 free(notes->src);
165 notes->src = NULL;
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300166 }
Ingo Molnar0b73da32009-06-06 15:48:52 +0200167 }
Ingo Molnar0b73da32009-06-06 15:48:52 +0200168}
169
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200170static int __cmd_annotate(struct perf_annotate *ann)
Ingo Molnar8035e422009-06-06 15:19:13 +0200171{
Li Zefanbab81b62009-12-01 14:04:49 +0800172 int ret;
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -0200173 struct perf_session *session;
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -0300174 struct perf_evsel *pos;
175 u64 total_nr_samples;
Ingo Molnar8035e422009-06-06 15:19:13 +0200176
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200177 session = perf_session__new(ann->input_name, O_RDONLY,
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200178 ann->force, false, &ann->tool);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200179 if (session == NULL)
180 return -ENOMEM;
181
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200182 if (ann->cpu_list) {
183 ret = perf_session__cpu_bitmap(session, ann->cpu_list,
184 ann->cpu_bitmap);
Anton Blanchard5d67be92011-07-04 21:57:50 +1000185 if (ret)
186 goto out_delete;
187 }
188
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200189 ret = perf_session__process_events(session, &ann->tool);
Li Zefanbab81b62009-12-01 14:04:49 +0800190 if (ret)
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200191 goto out_delete;
Ingo Molnar8035e422009-06-06 15:19:13 +0200192
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200193 if (dump_trace) {
Arnaldo Carvalho de Meloc8446b92010-05-14 10:36:42 -0300194 perf_session__fprintf_nr_events(session, stdout);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200195 goto out_delete;
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200196 }
Ingo Molnar8035e422009-06-06 15:19:13 +0200197
Arnaldo Carvalho de Meloda21d1b2009-10-07 10:49:00 -0300198 if (verbose > 3)
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -0200199 perf_session__fprintf(session, stdout);
Ingo Molnar8035e422009-06-06 15:19:13 +0200200
Arnaldo Carvalho de Meloda21d1b2009-10-07 10:49:00 -0300201 if (verbose > 2)
Arnaldo Carvalho de Melocbf69682010-04-27 21:22:44 -0300202 perf_session__fprintf_dsos(session, stdout);
Ingo Molnar8035e422009-06-06 15:19:13 +0200203
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -0300204 total_nr_samples = 0;
205 list_for_each_entry(pos, &session->evlist->entries, node) {
206 struct hists *hists = &pos->hists;
207 u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
Ingo Molnar8035e422009-06-06 15:19:13 +0200208
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -0300209 if (nr_samples > 0) {
210 total_nr_samples += nr_samples;
211 hists__collapse_resort(hists);
212 hists__output_resort(hists);
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200213 hists__find_annotations(hists, pos->idx, ann);
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -0300214 }
215 }
216
217 if (total_nr_samples == 0) {
Robert Richterefad1412011-12-07 10:02:54 +0100218 ui__warning("The %s file has no samples!\n", session->filename);
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -0300219 goto out_delete;
220 }
221out_delete:
222 /*
223 * Speed up the exit process, for large files this can
224 * take quite a while.
225 *
226 * XXX Enable this when using valgrind or if we ever
227 * librarize this command.
228 *
229 * Also experiment with obstacks to see how much speed
230 * up we'll get here.
231 *
232 * perf_session__delete(session);
233 */
Li Zefanbab81b62009-12-01 14:04:49 +0800234 return ret;
Ingo Molnar8035e422009-06-06 15:19:13 +0200235}
236
237static const char * const annotate_usage[] = {
Namhyung Kim99345252012-01-08 02:25:30 +0900238 "perf annotate [<options>]",
Ingo Molnar8035e422009-06-06 15:19:13 +0200239 NULL
240};
241
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200242int cmd_annotate(int argc, const char **argv, const char *prefix __used)
243{
244 struct perf_annotate annotate = {
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200245 .tool = {
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200246 .sample = process_sample_event,
247 .mmap = perf_event__process_mmap,
248 .comm = perf_event__process_comm,
249 .fork = perf_event__process_task,
250 .ordered_samples = true,
251 .ordering_requires_timestamps = true,
252 },
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200253 };
254 const struct option options[] = {
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200255 OPT_STRING('i', "input", &annotate.input_name, "file",
Ingo Molnar8035e422009-06-06 15:19:13 +0200256 "input file name"),
Arnaldo Carvalho de Meloac73c5a2010-03-24 16:40:16 -0300257 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
258 "only consider symbols in these dsos"),
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200259 OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol",
Ingo Molnar0b73da32009-06-06 15:48:52 +0200260 "symbol to annotate"),
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200261 OPT_BOOLEAN('f', "force", &annotate.force, "don't complain, do it"),
Ian Munsiec0555642010-04-13 18:37:33 +1000262 OPT_INCR('v', "verbose", &verbose,
Ingo Molnar8035e422009-06-06 15:19:13 +0200263 "be more verbose (show symbol address, etc)"),
264 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
265 "dump raw trace in ASCII"),
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200266 OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"),
267 OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"),
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -0200268 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
269 "file", "vmlinux pathname"),
270 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
Mike Galbraith42976482009-07-02 08:09:46 +0200271 "load module symbols - WARNING: use only with -k and LIVE kernel"),
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200272 OPT_BOOLEAN('l', "print-line", &annotate.print_line,
Frederic Weisbecker301406b2009-06-13 00:11:21 +0200273 "print matching source lines (may be slow)"),
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200274 OPT_BOOLEAN('P', "full-paths", &annotate.full_paths,
Mike Galbraith42976482009-07-02 08:09:46 +0200275 "Don't shorten the displayed pathnames"),
David Ahernc8e66722011-11-13 11:30:08 -0700276 OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
Stephane Eraniane71a0592011-07-30 01:20:40 +0200277 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
278 "Look for files with symbols relative to this directory"),
Arnaldo Carvalho de Melo64c6f0c2011-10-06 12:48:31 -0300279 OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src,
Stephane Eranian3e6a2a72011-05-17 17:32:07 +0200280 "Interleave source code with assembly code (default)"),
Arnaldo Carvalho de Melo64c6f0c2011-10-06 12:48:31 -0300281 OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
Stephane Eranian3e6a2a72011-05-17 17:32:07 +0200282 "Display raw encoding of assembly instructions (default)"),
Andi Kleenf69b64f2011-09-15 14:31:41 -0700283 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
284 "Specify disassembler style (e.g. -M intel for intel syntax)"),
Ingo Molnar8035e422009-06-06 15:19:13 +0200285 OPT_END()
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200286 };
Ingo Molnar8035e422009-06-06 15:19:13 +0200287
Arnaldo Carvalho de Melo655000e2009-12-15 20:04:40 -0200288 argc = parse_options(argc, argv, options, annotate_usage, 0);
289
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200290 if (annotate.use_stdio)
Arnaldo Carvalho de Melo8b9e74e2010-08-21 10:38:16 -0300291 use_browser = 0;
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200292 else if (annotate.use_tui)
Arnaldo Carvalho de Melo8b9e74e2010-08-21 10:38:16 -0300293 use_browser = 1;
294
Arnaldo Carvalho de Melo229ade92011-01-31 18:08:39 -0200295 setup_browser(true);
Arnaldo Carvalho de Melo46e3e052010-05-22 11:25:40 -0300296
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200297 symbol_conf.priv_size = sizeof(struct annotation);
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -0200298 symbol_conf.try_vmlinux_path = true;
299
300 if (symbol__init() < 0)
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -0200301 return -1;
Ingo Molnar8035e422009-06-06 15:19:13 +0200302
Arnaldo Carvalho de Meloc8829c72009-12-14 20:09:29 -0200303 setup_sorting(annotate_usage, options);
Ingo Molnar8035e422009-06-06 15:19:13 +0200304
Ingo Molnar0b73da32009-06-06 15:48:52 +0200305 if (argc) {
306 /*
307 * Special case: if there's an argument left then assume tha
308 * it's a symbol filter:
309 */
310 if (argc > 1)
311 usage_with_options(annotate_usage, options);
312
Arnaldo Carvalho de Melo7009cc32011-11-17 12:33:21 -0200313 annotate.sym_hist_filter = argv[0];
Ingo Molnar0b73da32009-06-06 15:48:52 +0200314 }
315
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200316 return __cmd_annotate(&annotate);
Ingo Molnar8035e422009-06-06 15:19:13 +0200317}