perf hists: Replace perf_evsel arg perf_hpp_fmt's header callback
[deliverable/linux.git] / tools / perf / ui / browsers / hists.c
index 2a83414159a65a026195f102c164ed6f6eae45be..c20425d7d9ae3194d8dba63e232bfee5801af9c3 100644 (file)
@@ -1531,7 +1531,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *
                if (perf_hpp__should_skip(fmt, hists)  || column++ < browser->b.horiz_scroll)
                        continue;
 
-               ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
+               ret = fmt->header(fmt, &dummy_hpp, hists);
                if (advance_hpp_check(&dummy_hpp, ret))
                        break;
 
@@ -1568,7 +1568,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
                if (column++ < browser->b.horiz_scroll)
                        continue;
 
-               ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
+               ret = fmt->header(fmt, &dummy_hpp, hists);
                if (advance_hpp_check(&dummy_hpp, ret))
                        break;
 
@@ -1605,11 +1605,10 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
                        }
                        first_col = false;
 
-                       ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
+                       ret = fmt->header(fmt, &dummy_hpp, hists);
                        dummy_hpp.buf[ret] = '\0';
-                       rtrim(dummy_hpp.buf);
 
-                       start = ltrim(dummy_hpp.buf);
+                       start = trim(dummy_hpp.buf);
                        ret = strlen(start);
 
                        if (start != dummy_hpp.buf)
@@ -1623,21 +1622,38 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
        return ret;
 }
 
-static void hist_browser__show_headers(struct hist_browser *browser)
+static void hists_browser__hierarchy_headers(struct hist_browser *browser)
 {
        char headers[1024];
 
-       if (symbol_conf.report_hierarchy)
-               hists_browser__scnprintf_hierarchy_headers(browser, headers,
-                                                          sizeof(headers));
-       else
-               hists_browser__scnprintf_headers(browser, headers,
-                                                sizeof(headers));
+       hists_browser__scnprintf_hierarchy_headers(browser, headers,
+                                                  sizeof(headers));
+
+       ui_browser__gotorc(&browser->b, 0, 0);
+       ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
+       ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1);
+}
+
+static void hists_browser__headers(struct hist_browser *browser)
+{
+       char headers[1024];
+
+       hists_browser__scnprintf_headers(browser, headers,
+                                        sizeof(headers));
+
        ui_browser__gotorc(&browser->b, 0, 0);
        ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
        ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1);
 }
 
+static void hist_browser__show_headers(struct hist_browser *browser)
+{
+       if (symbol_conf.report_hierarchy)
+               hists_browser__hierarchy_headers(browser);
+       else
+               hists_browser__headers(browser);
+}
+
 static void ui_browser__hists_init_top(struct ui_browser *browser)
 {
        if (browser->top == NULL) {
@@ -1897,11 +1913,10 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
        bool first = true;
        int ret;
 
-       if (symbol_conf.use_callchain)
+       if (symbol_conf.use_callchain) {
                folded_sign = hist_entry__folded(he);
-
-       if (symbol_conf.use_callchain)
                printed += fprintf(fp, "%c ", folded_sign);
+       }
 
        hists__for_each_format(browser->hists, fmt) {
                if (perf_hpp__should_skip(fmt, he->hists))
@@ -2137,7 +2152,7 @@ static int hists__browser_title(struct hists *hists,
                printed += snprintf(bf + printed, size - printed,
                                    ", UID: %s", hists->uid_filter_str);
        if (thread) {
-               if (sort__has_thread) {
+               if (hists__has(hists, thread)) {
                        printed += scnprintf(bf + printed, size - printed,
                                    ", Thread: %s(%d)",
                                     (thread->comm_set ? thread__comm_str(thread) : ""),
@@ -2322,7 +2337,8 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
 {
        struct thread *thread = act->thread;
 
-       if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
+       if ((!hists__has(browser->hists, thread) &&
+            !hists__has(browser->hists, comm)) || thread == NULL)
                return 0;
 
        if (browser->hists->thread_filter) {
@@ -2331,7 +2347,7 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
                thread__zput(browser->hists->thread_filter);
                ui_helpline__pop();
        } else {
-               if (sort__has_thread) {
+               if (hists__has(browser->hists, thread)) {
                        ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
                                           thread->comm_set ? thread__comm_str(thread) : "",
                                           thread->tid);
@@ -2356,10 +2372,11 @@ add_thread_opt(struct hist_browser *browser, struct popup_action *act,
 {
        int ret;
 
-       if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
+       if ((!hists__has(browser->hists, thread) &&
+            !hists__has(browser->hists, comm)) || thread == NULL)
                return 0;
 
-       if (sort__has_thread) {
+       if (hists__has(browser->hists, thread)) {
                ret = asprintf(optstr, "Zoom %s %s(%d) thread",
                               browser->hists->thread_filter ? "out of" : "into",
                               thread->comm_set ? thread__comm_str(thread) : "",
@@ -2382,7 +2399,7 @@ do_zoom_dso(struct hist_browser *browser, struct popup_action *act)
 {
        struct map *map = act->ms.map;
 
-       if (!sort__has_dso || map == NULL)
+       if (!hists__has(browser->hists, dso) || map == NULL)
                return 0;
 
        if (browser->hists->dso_filter) {
@@ -2409,7 +2426,7 @@ static int
 add_dso_opt(struct hist_browser *browser, struct popup_action *act,
            char **optstr, struct map *map)
 {
-       if (!sort__has_dso || map == NULL)
+       if (!hists__has(browser->hists, dso) || map == NULL)
                return 0;
 
        if (asprintf(optstr, "Zoom %s %s DSO",
@@ -2431,10 +2448,10 @@ do_browse_map(struct hist_browser *browser __maybe_unused,
 }
 
 static int
-add_map_opt(struct hist_browser *browser __maybe_unused,
+add_map_opt(struct hist_browser *browser,
            struct popup_action *act, char **optstr, struct map *map)
 {
-       if (!sort__has_dso || map == NULL)
+       if (!hists__has(browser->hists, dso) || map == NULL)
                return 0;
 
        if (asprintf(optstr, "Browse map details") < 0)
@@ -2536,7 +2553,7 @@ add_exit_opt(struct hist_browser *browser __maybe_unused,
 static int
 do_zoom_socket(struct hist_browser *browser, struct popup_action *act)
 {
-       if (!sort__has_socket || act->socket < 0)
+       if (!hists__has(browser->hists, socket) || act->socket < 0)
                return 0;
 
        if (browser->hists->socket_filter > -1) {
@@ -2558,7 +2575,7 @@ static int
 add_socket_opt(struct hist_browser *browser, struct popup_action *act,
               char **optstr, int socket_id)
 {
-       if (!sort__has_socket || socket_id < 0)
+       if (!hists__has(browser->hists, socket) || socket_id < 0)
                return 0;
 
        if (asprintf(optstr, "Zoom %s Processor Socket %d",
@@ -2749,7 +2766,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
                         */
                        goto out_free_stack;
                case 'a':
-                       if (!sort__has_sym) {
+                       if (!hists__has(hists, sym)) {
                                ui_browser__warning(&browser->b, delay_secs * 2,
                        "Annotation is only available for symbolic views, "
                        "include \"sym*\" in --sort to use it.");
@@ -2912,7 +2929,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
                        continue;
                }
 
-               if (!sort__has_sym || browser->selection == NULL)
+               if (!hists__has(hists, sym) || browser->selection == NULL)
                        goto skip_annotation;
 
                if (sort__mode == SORT_MODE__BRANCH) {
@@ -2956,7 +2973,7 @@ skip_annotation:
                        goto skip_scripting;
 
                if (browser->he_selection) {
-                       if (sort__has_thread && thread) {
+                       if (hists__has(hists, thread) && thread) {
                                nr_options += add_script_opt(browser,
                                                             &actions[nr_options],
                                                             &options[nr_options],
@@ -2971,7 +2988,7 @@ skip_annotation:
                         *
                         * See hist_browser__show_entry.
                         */
-                       if (sort__has_sym && browser->selection->sym) {
+                       if (hists__has(hists, sym) && browser->selection->sym) {
                                nr_options += add_script_opt(browser,
                                                             &actions[nr_options],
                                                             &options[nr_options],
This page took 0.045182 seconds and 5 git commands to generate.