perf TUI: Show filters on the title and add help line about how to zoom out

Suggested-by: default avatarIngo Molnar <molnar@elte.hu>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ca7e0c61
...@@ -411,7 +411,7 @@ static void hist_browser__delete(struct hist_browser *self) ...@@ -411,7 +411,7 @@ static void hist_browser__delete(struct hist_browser *self)
} }
static int hist_browser__populate(struct hist_browser *self, struct rb_root *hists, static int hist_browser__populate(struct hist_browser *self, struct rb_root *hists,
u64 nr_hists, u64 session_total) u64 nr_hists, u64 session_total, const char *title)
{ {
int max_len = 0, idx, cols, rows; int max_len = 0, idx, cols, rows;
struct ui_progress *progress; struct ui_progress *progress;
...@@ -476,7 +476,7 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his ...@@ -476,7 +476,7 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his
newtListboxSetWidth(self->tree, max_len); newtListboxSetWidth(self->tree, max_len);
newtCenteredWindow(max_len + (symbol_conf.use_callchain ? 5 : 0), newtCenteredWindow(max_len + (symbol_conf.use_callchain ? 5 : 0),
rows - 5, "Report"); rows - 5, title);
self->form = newt_form__new(); self->form = newt_form__new();
if (self->form == NULL) if (self->form == NULL)
return -1; return -1;
...@@ -495,7 +495,7 @@ enum hist_filter { ...@@ -495,7 +495,7 @@ enum hist_filter {
HIST_FILTER__THREAD, HIST_FILTER__THREAD,
}; };
static u64 hists__filter_by_dso(struct rb_root *hists, struct dso *dso, static u64 hists__filter_by_dso(struct rb_root *hists, const struct dso *dso,
u64 *session_total) u64 *session_total)
{ {
struct rb_node *nd; struct rb_node *nd;
...@@ -560,25 +560,47 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *self) ...@@ -560,25 +560,47 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *self)
return *(struct thread **)(self->selection + 1); return *(struct thread **)(self->selection + 1);
} }
static int hist_browser__title(char *bf, size_t size, const char *input_name,
const struct dso *dso, const struct thread *thread)
{
int printed = 0;
if (thread)
printed += snprintf(bf + printed, size - printed,
"Thread: %s(%d)",
(thread->comm_set ? thread->comm : ""),
thread->pid);
if (dso)
printed += snprintf(bf + printed, size - printed,
"%sDSO: %s", thread ? " " : "",
dso->short_name);
return printed ?: snprintf(bf, size, "Report: %s", input_name);
}
int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
u64 session_total, const char *helpline, u64 session_total, const char *helpline,
const char *input_name) const char *input_name)
{ {
struct hist_browser *browser = hist_browser__new();
const struct thread *thread_filter = NULL;
const struct dso *dso_filter = NULL;
struct newtExitStruct es; struct newtExitStruct es;
bool dso_filtered = false, thread_filtered = false; char msg[160];
int err = -1; int err = -1;
struct hist_browser *browser = hist_browser__new();
if (browser == NULL) if (browser == NULL)
return -1; return -1;
newtPushHelpLine(helpline); newtPushHelpLine(helpline);
if (hist_browser__populate(browser, hists, nr_hists, session_total) < 0) hist_browser__title(msg, sizeof(msg), input_name,
dso_filter, thread_filter);
if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0)
goto out; goto out;
while (1) { while (1) {
const struct thread *thread; const struct thread *thread;
const struct dso *dso;
char *options[16]; char *options[16];
int nr_options = 0, choice = 0, i, int nr_options = 0, choice = 0, i,
annotate = -2, zoom_dso = -2, zoom_thread = -2; annotate = -2, zoom_dso = -2, zoom_thread = -2;
...@@ -602,20 +624,21 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, ...@@ -602,20 +624,21 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
browser->selection->sym->name) > 0) browser->selection->sym->name) > 0)
annotate = nr_options++; annotate = nr_options++;
if (browser->selection->map != NULL &&
asprintf(&options[nr_options], "Zoom %s %s DSO",
dso_filtered ? "out of" : "into",
(browser->selection->map->dso->kernel ? "the Kernel" :
browser->selection->map->dso->short_name)) > 0)
zoom_dso = nr_options++;
thread = hist_browser__selected_thread(browser); thread = hist_browser__selected_thread(browser);
if (thread != NULL && if (thread != NULL &&
asprintf(&options[nr_options], "Zoom %s %s(%d) thread", asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
(thread_filtered ? "out of" : "into"), (thread_filter ? "out of" : "into"),
(thread->comm_set ? thread->comm : ""), thread->pid) > 0) (thread->comm_set ? thread->comm : ""),
thread->pid) > 0)
zoom_thread = nr_options++; zoom_thread = nr_options++;
dso = browser->selection->map ? browser->selection->map->dso : NULL;
if (dso != NULL &&
asprintf(&options[nr_options], "Zoom %s %s DSO",
(dso_filter ? "out of" : "into"),
(dso->kernel ? "the Kernel" : dso->short_name)) > 0)
zoom_dso = nr_options++;
options[nr_options++] = (char *)"Exit"; options[nr_options++] = (char *)"Exit";
choice = popup_menu(nr_options, options); choice = popup_menu(nr_options, options);
...@@ -637,22 +660,39 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, ...@@ -637,22 +660,39 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
"kallsyms file"); "kallsyms file");
continue; continue;
} }
map_symbol__annotate_browser(browser->selection, map_symbol__annotate_browser(browser->selection, input_name);
input_name);
} else if (choice == zoom_dso) { } else if (choice == zoom_dso) {
nr_hists = hists__filter_by_dso(hists, if (dso_filter) {
(dso_filtered ? NULL : newtPopHelpLine();
browser->selection->map->dso), dso_filter = NULL;
&session_total); } else {
dso_filtered = !dso_filtered; snprintf(msg, sizeof(msg),
if (hist_browser__populate(browser, hists, nr_hists, session_total) < 0) "To zoom out press -> + \"Zoom out of %s DSO\"",
dso->kernel ? "the Kernel" : dso->short_name);
newtPushHelpLine(msg);
dso_filter = dso;
}
nr_hists = hists__filter_by_dso(hists, dso_filter, &session_total);
hist_browser__title(msg, sizeof(msg), input_name,
dso_filter, thread_filter);
if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0)
goto out; goto out;
} else if (choice == zoom_thread) { } else if (choice == zoom_thread) {
nr_hists = hists__filter_by_thread(hists, if (thread_filter) {
(thread_filtered ? NULL : thread), newtPopHelpLine();
&session_total); thread_filter = NULL;
thread_filtered = !thread_filtered; } else {
if (hist_browser__populate(browser, hists, nr_hists, session_total) < 0) snprintf(msg, sizeof(msg),
"To zoom out press -> + \"Zoom out of %s(%d) thread\"",
(thread->comm_set ? thread->comm : ""),
thread->pid);
newtPushHelpLine(msg);
thread_filter = thread;
}
nr_hists = hists__filter_by_thread(hists, thread_filter, &session_total);
hist_browser__title(msg, sizeof(msg), input_name,
dso_filter, thread_filter);
if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0)
goto out; goto out;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment