perf tools: Adjust some verbosity levels
[safe/jmp/linux-2.6] / tools / perf / builtin-annotate.c
index 1f1341f..4fc3899 100644 (file)
@@ -51,11 +51,6 @@ struct sym_priv {
        struct sym_ext  *ext;
 };
 
-static struct symbol_conf symbol_conf = {
-       .priv_size        = sizeof(struct sym_priv),
-       .try_vmlinux_path = true,
-};
-
 static const char *sym_hist_filter;
 
 static int symbol_filter(struct map *map __used, struct symbol *sym)
@@ -102,9 +97,7 @@ static void hist_hit(struct hist_entry *he, u64 ip)
        sym_size = sym->end - sym->start;
        offset = ip - sym->start;
 
-       if (verbose)
-               fprintf(stderr, "%s: ip=%Lx\n", __func__,
-                       he->map->unmap_ip(he->map, ip));
+       pr_debug3("%s: ip=%#Lx\n", __func__, he->map->unmap_ip(he->map, ip));
 
        if (offset >= sym_size)
                return;
@@ -113,12 +106,8 @@ static void hist_hit(struct hist_entry *he, u64 ip)
        h->sum++;
        h->ip[offset]++;
 
-       if (verbose >= 3)
-               printf("%p %s: count++ [ip: %p, %08Lx] => %Ld\n",
-                       (void *)(unsigned long)he->sym->start,
-                       he->sym->name,
-                       (void *)(unsigned long)ip, ip - he->sym->start,
-                       h->ip[offset]);
+       pr_debug3("%#Lx %s: count++ [ip: %#Lx, %#Lx] => %Ld\n", he->sym->start,
+                 he->sym->name, ip, ip - he->sym->start, h->ip[offset]);
 }
 
 static int perf_session__add_hist_entry(struct perf_session *self,
@@ -137,18 +126,18 @@ 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);
+       dump_printf("(IP, %d): %d: %#Lx\n", event->header.misc,
+                   event->ip.pid, event->ip.ip);
 
        if (event__preprocess_sample(event, session, &al, symbol_filter) < 0) {
-               fprintf(stderr, "problem processing %d event, skipping it.\n",
-                       event->header.type);
+               pr_warning("problem processing %d event, skipping it.\n",
+                          event->header.type);
                return -1;
        }
 
-       if (perf_session__add_hist_entry(session, &al, 1)) {
-               fprintf(stderr, "problem incrementing symbol count, "
-                               "skipping event\n");
+       if (!al.filtered && perf_session__add_hist_entry(session, &al, 1)) {
+               pr_warning("problem incrementing symbol count, "
+                          "skipping event\n");
                return -1;
        }
 
@@ -383,11 +372,9 @@ static void annotate_sym(struct hist_entry *he)
        if (!filename)
                return;
 
-       if (verbose)
-               fprintf(stderr, "%s: filename=%s, sym=%s, start=%Lx, end=%Lx\n",
-                       __func__, filename, sym->name,
-                       map->unmap_ip(map, sym->start),
-                       map->unmap_ip(map, sym->end));
+       pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__,
+                filename, sym->name, map->unmap_ip(map, sym->start),
+                map->unmap_ip(map, sym->end));
 
        if (full_paths)
                d_filename = filename;
@@ -456,18 +443,18 @@ static void perf_session__find_annotations(struct perf_session *self)
 }
 
 static struct perf_event_ops event_ops = {
-       .process_sample_event   = process_sample_event,
-       .process_mmap_event     = event__process_mmap,
-       .process_comm_event     = event__process_comm,
-       .process_fork_event     = event__process_task,
+       .sample = process_sample_event,
+       .mmap   = event__process_mmap,
+       .comm   = event__process_comm,
+       .fork   = event__process_task,
 };
 
 static int __cmd_annotate(void)
 {
-       struct perf_session *session = perf_session__new(input_name, O_RDONLY,
-                                                        force, &symbol_conf);
        int ret;
+       struct perf_session *session;
 
+       session = perf_session__new(input_name, O_RDONLY, force);
        if (session == NULL)
                return -ENOMEM;
 
@@ -487,7 +474,7 @@ static int __cmd_annotate(void)
                dsos__fprintf(stdout);
 
        perf_session__collapse_resort(session);
-       perf_session__output_resort(session, event__total[0]);
+       perf_session__output_resort(session, session->event_total[0]);
        perf_session__find_annotations(session);
 out_delete:
        perf_session__delete(session);
@@ -521,29 +508,17 @@ static const struct option options[] = {
        OPT_END()
 };
 
-static void setup_sorting(void)
+int cmd_annotate(int argc, const char **argv, const char *prefix __used)
 {
-       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);
-               }
-       }
+       argc = parse_options(argc, argv, options, annotate_usage, 0);
 
-       free(str);
-}
+       symbol_conf.priv_size = sizeof(struct sym_priv);
+       symbol_conf.try_vmlinux_path = true;
 
-int cmd_annotate(int argc, const char **argv, const char *prefix __used)
-{
-       if (symbol__init(&symbol_conf) < 0)
+       if (symbol__init() < 0)
                return -1;
 
-       argc = parse_options(argc, argv, options, annotate_usage, 0);
-
-       setup_sorting();
+       setup_sorting(annotate_usage, options);
 
        if (argc) {
                /*
@@ -559,9 +534,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
        setup_pager();
 
        if (field_sep && *field_sep == '.') {
-               fputs("'.' is the only non valid --field-separator argument\n",
-                               stderr);
-               exit(129);
+               pr_err("'.' is the only non valid --field-separator argument\n");
+               return -1;
        }
 
        return __cmd_annotate();