]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - tools/perf/builtin-report.c
Merge branch 'linus' into perf/core
[net-next-2.6.git] / tools / perf / builtin-report.c
index 1d3c1003b43a2f083e94a0926a0000e159379352..ce42bbaa252d822be55aec11fa6392fd67793798 100644 (file)
@@ -107,7 +107,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
                goto out_free_syms;
        err = 0;
        if (symbol_conf.use_callchain) {
-               err = append_chain(he->callchain, data->callchain, syms);
+               err = append_chain(he->callchain, data->callchain, syms, data->period);
                if (err)
                        goto out_free_syms;
        }
@@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
         * so we don't allocated the extra space needed because the stdio
         * code will not use it.
         */
-       if (use_browser)
+       if (use_browser > 0)
                err = hist_entry__inc_addr_samples(he, al->addr);
 out_free_syms:
        free(syms);
@@ -155,30 +155,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
        struct addr_location al;
        struct perf_event_attr *attr;
 
-       event__parse_sample(event, session->sample_type, &data);
-
-       dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc,
-                   data.pid, data.tid, data.ip, data.period);
-
-       if (session->sample_type & PERF_SAMPLE_CALLCHAIN) {
-               unsigned int i;
-
-               dump_printf("... chain: nr:%Lu\n", data.callchain->nr);
-
-               if (!ip_callchain__valid(data.callchain, event)) {
-                       pr_debug("call-chain problem with event, "
-                                "skipping it.\n");
-                       return 0;
-               }
-
-               if (dump_trace) {
-                       for (i = 0; i < data.callchain->nr; i++)
-                               dump_printf("..... %2d: %016Lx\n",
-                                           i, data.callchain->ips[i]);
-               }
-       }
-
-       if (event__preprocess_sample(event, session, &al, NULL) < 0) {
+       if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
                fprintf(stderr, "problem processing %d event, skipping it.\n",
                        event->header.type);
                return -1;
@@ -288,6 +265,38 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
        return ret + fprintf(fp, "\n#\n");
 }
 
+static int hists__tty_browse_tree(struct rb_root *tree, const char *help)
+{
+       struct rb_node *next = rb_first(tree);
+
+       while (next) {
+               struct hists *hists = rb_entry(next, struct hists, rb_node);
+               const char *evname = NULL;
+
+               if (rb_first(&hists->entries) != rb_last(&hists->entries))
+                       evname = __event_name(hists->type, hists->config);
+
+               hists__fprintf_nr_sample_events(hists, evname, stdout);
+               hists__fprintf(hists, NULL, false, stdout);
+               fprintf(stdout, "\n\n");
+               next = rb_next(&hists->rb_node);
+       }
+
+       if (sort_order == default_sort_order &&
+           parent_pattern == default_parent_pattern) {
+               fprintf(stdout, "#\n# (%s)\n#\n", help);
+
+               if (show_threads) {
+                       bool style = !strcmp(pretty_printing_style, "raw");
+                       perf_read_values_display(stdout, &show_threads_values,
+                                                style);
+                       perf_read_values_destroy(&show_threads_values);
+               }
+       }
+
+       return 0;
+}
+
 static int __cmd_report(void)
 {
        int ret = -EINVAL;
@@ -330,34 +339,14 @@ static int __cmd_report(void)
                hists = rb_entry(next, struct hists, rb_node);
                hists__collapse_resort(hists);
                hists__output_resort(hists);
-               if (use_browser)
-                       hists__browse(hists, help, input_name);
-               else {
-                       const char *evname = NULL;
-                       if (rb_first(&session->hists.entries) !=
-                           rb_last(&session->hists.entries))
-                               evname = __event_name(hists->type, hists->config);
-
-                       hists__fprintf_nr_sample_events(hists, evname, stdout);
-
-                       hists__fprintf(hists, NULL, false, stdout);
-                       fprintf(stdout, "\n\n");
-               }
-
                next = rb_next(&hists->rb_node);
        }
 
-       if (!use_browser && sort_order == default_sort_order &&
-           parent_pattern == default_parent_pattern) {
-               fprintf(stdout, "#\n# (%s)\n#\n", help);
+       if (use_browser > 0)
+               hists__tui_browse_tree(&session->hists_tree, help);
+       else
+               hists__tty_browse_tree(&session->hists_tree, help);
 
-               if (show_threads) {
-                       bool style = !strcmp(pretty_printing_style, "raw");
-                       perf_read_values_display(stdout, &show_threads_values,
-                                                style);
-                       perf_read_values_destroy(&show_threads_values);
-               }
-       }
 out_delete:
        perf_session__delete(session);
        return ret;
@@ -491,7 +480,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
         * so don't allocate extra space that won't be used in the stdio
         * implementation.
         */
-       if (use_browser)
+       if (use_browser > 0)
                symbol_conf.priv_size = sizeof(struct sym_priv);
 
        if (symbol__init() < 0)