]> Pileus Git - ~andy/linux/blobdiff - tools/perf/builtin-annotate.c
perf diff: Improve the help text
[~andy/linux] / tools / perf / builtin-annotate.c
index a931b133f3acbebce09b6602981f01d82e0759df..2e2855a685c6579d663be57b6019f9c17cd0eed7 100644 (file)
@@ -121,30 +121,32 @@ static void hist_hit(struct hist_entry *he, u64 ip)
                        h->ip[offset]);
 }
 
-static int hist_entry__add(struct addr_location *al, u64 count)
+static int perf_session__add_hist_entry(struct perf_session *self,
+                                       struct addr_location *al, u64 count)
 {
        bool hit;
-       struct hist_entry *he = __hist_entry__add(al, NULL, count, &hit);
+       struct hist_entry *he = __perf_session__add_hist_entry(self, al, NULL,
+                                                              count, &hit);
        if (he == NULL)
                return -ENOMEM;
        hist_hit(he, al->addr);
        return 0;
 }
 
-static int process_sample_event(event_t *event, struct perf_session *session __used)
+static int process_sample_event(event_t *event, struct perf_session *session)
 {
        struct addr_location al;
 
        dump_printf("(IP, %d): %d: %p\n", event->header.misc,
                    event->ip.pid, (void *)(long)event->ip.ip);
 
-       if (event__preprocess_sample(event, &al, symbol_filter) < 0) {
+       if (event__preprocess_sample(event, session, &al, symbol_filter) < 0) {
                fprintf(stderr, "problem processing %d event, skipping it.\n",
                        event->header.type);
                return -1;
        }
 
-       if (hist_entry__add(&al, 1)) {
+       if (perf_session__add_hist_entry(session, &al, 1)) {
                fprintf(stderr, "problem incrementing symbol count, "
                                "skipping event\n");
                return -1;
@@ -428,11 +430,11 @@ static void annotate_sym(struct hist_entry *he)
                free_source_line(he, len);
 }
 
-static void find_annotations(void)
+static void perf_session__find_annotations(struct perf_session *self)
 {
        struct rb_node *nd;
 
-       for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
+       for (nd = rb_first(&self->hists); nd; nd = rb_next(nd)) {
                struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
                struct sym_priv *priv;
 
@@ -463,7 +465,7 @@ static struct perf_event_ops event_ops = {
 static int __cmd_annotate(void)
 {
        struct perf_session *session = perf_session__new(input_name, O_RDONLY,
-                                                        force);
+                                                        force, &symbol_conf);
        int ret;
 
        if (session == NULL)
@@ -479,15 +481,14 @@ static int __cmd_annotate(void)
        }
 
        if (verbose > 3)
-               threads__fprintf(stdout);
+               perf_session__fprintf(session, stdout);
 
        if (verbose > 2)
                dsos__fprintf(stdout);
 
-       collapse__resort();
-       output__resort(event__total[0]);
-
-       find_annotations();
+       perf_session__collapse_resort(session);
+       perf_session__output_resort(session, session->event_total[0]);
+       perf_session__find_annotations(session);
 out_delete:
        perf_session__delete(session);
 
@@ -520,21 +521,6 @@ static const struct option options[] = {
        OPT_END()
 };
 
-static void setup_sorting(void)
-{
-       char *tmp, *tok, *str = strdup(sort_order);
-
-       for (tok = strtok_r(str, ", ", &tmp);
-                       tok; tok = strtok_r(NULL, ", ", &tmp)) {
-               if (sort_dimension__add(tok) < 0) {
-                       error("Unknown --sort key: `%s'", tok);
-                       usage_with_options(annotate_usage, options);
-               }
-       }
-
-       free(str);
-}
-
 int cmd_annotate(int argc, const char **argv, const char *prefix __used)
 {
        if (symbol__init(&symbol_conf) < 0)
@@ -542,7 +528,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
 
        argc = parse_options(argc, argv, options, annotate_usage, 0);
 
-       setup_sorting();
+       setup_sorting(annotate_usage, options);
 
        if (argc) {
                /*