]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - tools/perf/ui/browsers/hists.c
perf env: Rename some leftovers from rename to perf_env
[karo-tx-linux.git] / tools / perf / ui / browsers / hists.c
index fa67613976a80147e672bd2b960c9f577ff06b74..17d6c6dbb27fc59ace0f532868df5761b88bea45 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include "../libslang.h"
 #include <stdlib.h>
 #include <string.h>
 #include <linux/rbtree.h>
@@ -27,7 +26,7 @@ struct hist_browser {
        struct map_symbol   *selection;
        struct hist_browser_timer *hbt;
        struct pstack       *pstack;
-       struct perf_session_env *env;
+       struct perf_env *env;
        int                  print_seq;
        bool                 show_dso;
        bool                 show_headers;
@@ -540,10 +539,10 @@ static void hist_browser__show_callchain_entry(struct hist_browser *browser,
 
        ui_browser__set_color(&browser->b, color);
        hist_browser__gotorc(browser, row, 0);
-       slsmg_write_nstring(" ", offset);
-       slsmg_printf("%c", folded_sign);
+       ui_browser__write_nstring(&browser->b, " ", offset);
+       ui_browser__printf(&browser->b, "%c", folded_sign);
        ui_browser__write_graph(&browser->b, show_annotated ? SLSMG_RARROW_CHAR : ' ');
-       slsmg_write_nstring(str, width);
+       ui_browser__write_nstring(&browser->b, str, width);
 }
 
 static void hist_browser__fprintf_callchain_entry(struct hist_browser *b __maybe_unused,
@@ -680,7 +679,7 @@ static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...)
        ui_browser__set_percent_color(arg->b, percent, arg->current_entry);
 
        ret = scnprintf(hpp->buf, hpp->size, fmt, len, percent);
-       slsmg_printf("%s", hpp->buf);
+       ui_browser__printf(arg->b, "%s", hpp->buf);
 
        advance_hpp(hpp, ret);
        return ret;
@@ -713,10 +712,11 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt,         \
                                struct hist_entry *he)                  \
 {                                                                      \
        if (!symbol_conf.cumulate_callchain) {                          \
+               struct hpp_arg *arg = hpp->ptr;                         \
                int len = fmt->user_len ?: fmt->len;                    \
                int ret = scnprintf(hpp->buf, hpp->size,                \
                                    "%*s", len, "N/A");                 \
-               slsmg_printf("%s", hpp->buf);                           \
+               ui_browser__printf(arg->b, "%s", hpp->buf);             \
                                                                        \
                return ret;                                             \
        }                                                               \
@@ -801,12 +801,12 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 
                        if (first) {
                                if (symbol_conf.use_callchain) {
-                                       slsmg_printf("%c ", folded_sign);
+                                       ui_browser__printf(&browser->b, "%c ", folded_sign);
                                        width -= 2;
                                }
                                first = false;
                        } else {
-                               slsmg_printf("  ");
+                               ui_browser__printf(&browser->b, "  ");
                                width -= 2;
                        }
 
@@ -814,7 +814,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
                                width -= fmt->color(fmt, &hpp, entry);
                        } else {
                                width -= fmt->entry(fmt, &hpp, entry);
-                               slsmg_printf("%s", s);
+                               ui_browser__printf(&browser->b, "%s", s);
                        }
                }
 
@@ -822,7 +822,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
                if (!browser->b.navkeypressed)
                        width += 1;
 
-               slsmg_write_nstring("", width);
+               ui_browser__write_nstring(&browser->b, "", width);
 
                ++row;
                ++printed;
@@ -899,7 +899,7 @@ static void hist_browser__show_headers(struct hist_browser *browser)
        hists__scnprintf_headers(headers, sizeof(headers), browser->hists);
        ui_browser__gotorc(&browser->b, 0, 0);
        ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
-       slsmg_write_nstring(headers, browser->b.width + 1);
+       ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1);
 }
 
 static void ui_browser__hists_init_top(struct ui_browser *browser)
@@ -1214,7 +1214,7 @@ static int hist_browser__dump(struct hist_browser *browser)
 
 static struct hist_browser *hist_browser__new(struct hists *hists,
                                              struct hist_browser_timer *hbt,
-                                             struct perf_session_env *env)
+                                             struct perf_env *env)
 {
        struct hist_browser *browser = zalloc(sizeof(*browser));
 
@@ -1267,6 +1267,8 @@ static int hists__browser_title(struct hists *hists,
        const char *ev_name = perf_evsel__name(evsel);
        char buf[512];
        size_t buflen = sizeof(buf);
+       char ref[30] = " show reference callgraph, ";
+       bool enable_ref = false;
 
        if (symbol_conf.filter_relative) {
                nr_samples = hists->stats.nr_non_filtered_samples;
@@ -1292,10 +1294,13 @@ static int hists__browser_title(struct hists *hists,
                }
        }
 
+       if (symbol_conf.show_ref_callgraph &&
+           strstr(ev_name, "call-graph=no"))
+               enable_ref = true;
        nr_samples = convert_unit(nr_samples, &unit);
        printed = scnprintf(bf, size,
-                          "Samples: %lu%c of event '%s', Event count (approx.): %" PRIu64,
-                          nr_samples, unit, ev_name, nr_events);
+                          "Samples: %lu%c of event '%s',%sEvent count (approx.): %" PRIu64,
+                          nr_samples, unit, ev_name, enable_ref ? ref : " ", nr_events);
 
 
        if (hists->uid_filter_str)
@@ -1432,7 +1437,7 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)
        struct hist_entry *he;
        int err;
 
-       if (!objdump_path && perf_session_env__lookup_objdump(browser->env))
+       if (!objdump_path && perf_env__lookup_objdump(browser->env))
                return 0;
 
        notes = symbol__annotation(act->ms.sym);
@@ -1690,7 +1695,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
                                    bool left_exits,
                                    struct hist_browser_timer *hbt,
                                    float min_pcnt,
-                                   struct perf_session_env *env)
+                                   struct perf_env *env)
 {
        struct hists *hists = evsel__hists(evsel);
        struct hist_browser *browser = hist_browser__new(hists, hbt, env);
@@ -1868,6 +1873,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
                case K_RIGHT:
                        /* menu */
                        break;
+               case K_ESC:
                case K_LEFT: {
                        const void *top;
 
@@ -1877,6 +1883,12 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
                                 */
                                if (left_exits)
                                        goto out_free_stack;
+
+                               if (key == K_ESC &&
+                                   ui_browser__dialog_yesno(&browser->b,
+                                                            "Do you really want to exit?"))
+                                       goto out_free_stack;
+
                                continue;
                        }
                        top = pstack__peek(browser->pstack);
@@ -1892,12 +1904,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
                                do_zoom_thread(browser, actions);
                        continue;
                }
-               case K_ESC:
-                       if (!left_exits &&
-                           !ui_browser__dialog_yesno(&browser->b,
-                                              "Do you really want to exit?"))
-                               continue;
-                       /* Fall thru */
                case 'q':
                case CTRL('c'):
                        goto out_free_stack;
@@ -2010,7 +2016,7 @@ struct perf_evsel_menu {
        struct perf_evsel *selection;
        bool lost_events, lost_events_warned;
        float min_pcnt;
-       struct perf_session_env *env;
+       struct perf_env *env;
 };
 
 static void perf_evsel_menu__write(struct ui_browser *browser,
@@ -2044,7 +2050,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser,
        nr_events = convert_unit(nr_events, &unit);
        printed = scnprintf(bf, sizeof(bf), "%lu%c%s%s", nr_events,
                           unit, unit == ' ' ? "" : " ", ev_name);
-       slsmg_printf("%s", bf);
+       ui_browser__printf(browser, "%s", bf);
 
        nr_events = hists->stats.nr_events[PERF_RECORD_LOST];
        if (nr_events != 0) {
@@ -2057,7 +2063,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser,
                warn = bf;
        }
 
-       slsmg_write_nstring(warn, browser->width - printed);
+       ui_browser__write_nstring(browser, warn, browser->width - printed);
 
        if (current_entry)
                menu->selection = evsel;
@@ -2120,15 +2126,11 @@ browse_hists:
                                else
                                        pos = perf_evsel__prev(pos);
                                goto browse_hists;
-                       case K_ESC:
-                               if (!ui_browser__dialog_yesno(&menu->b,
-                                               "Do you really want to exit?"))
-                                       continue;
-                               /* Fall thru */
                        case K_SWITCH_INPUT_DATA:
                        case 'q':
                        case CTRL('c'):
                                goto out;
+                       case K_ESC:
                        default:
                                continue;
                        }
@@ -2167,7 +2169,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
                                           int nr_entries, const char *help,
                                           struct hist_browser_timer *hbt,
                                           float min_pcnt,
-                                          struct perf_session_env *env)
+                                          struct perf_env *env)
 {
        struct perf_evsel *pos;
        struct perf_evsel_menu menu = {
@@ -2200,7 +2202,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
 int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
                                  struct hist_browser_timer *hbt,
                                  float min_pcnt,
-                                 struct perf_session_env *env)
+                                 struct perf_env *env)
 {
        int nr_entries = evlist->nr_entries;