forked from Minki/linux
perf ui browser: Return the exit key in all browsers
Make all browsers return the exit key uniformly and remove the newtExitStruct parameter, removing one more newt specific thing from the ui API. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
8f9bbc408b
commit
b50e003db1
@ -321,7 +321,7 @@ static int hist_entry__tty_annotate(struct hist_entry *he)
|
|||||||
|
|
||||||
static void hists__find_annotations(struct hists *self)
|
static void hists__find_annotations(struct hists *self)
|
||||||
{
|
{
|
||||||
struct rb_node *first = rb_first(&self->entries), *nd = first;
|
struct rb_node *nd = rb_first(&self->entries), *next;
|
||||||
int key = KEY_RIGHT;
|
int key = KEY_RIGHT;
|
||||||
|
|
||||||
while (nd) {
|
while (nd) {
|
||||||
@ -343,20 +343,19 @@ find_next:
|
|||||||
|
|
||||||
if (use_browser > 0) {
|
if (use_browser > 0) {
|
||||||
key = hist_entry__tui_annotate(he);
|
key = hist_entry__tui_annotate(he);
|
||||||
if (is_exit_key(key))
|
|
||||||
break;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
case '\t':
|
next = rb_next(nd);
|
||||||
nd = rb_next(nd);
|
|
||||||
break;
|
break;
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
if (nd == first)
|
next = rb_prev(nd);
|
||||||
continue;
|
|
||||||
nd = rb_prev(nd);
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (next != NULL)
|
||||||
|
nd = next;
|
||||||
} else {
|
} else {
|
||||||
hist_entry__tty_annotate(he);
|
hist_entry__tty_annotate(he);
|
||||||
nd = rb_next(nd);
|
nd = rb_next(nd);
|
||||||
|
@ -204,21 +204,21 @@ int ui_browser__refresh(struct ui_browser *self)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es)
|
int ui_browser__run(struct ui_browser *self)
|
||||||
{
|
{
|
||||||
|
struct newtExitStruct es;
|
||||||
|
|
||||||
if (ui_browser__refresh(self) < 0)
|
if (ui_browser__refresh(self) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
off_t offset;
|
off_t offset;
|
||||||
|
|
||||||
newtFormRun(self->form, es);
|
newtFormRun(self->form, &es);
|
||||||
|
|
||||||
if (es->reason != NEWT_EXIT_HOTKEY)
|
if (es.reason != NEWT_EXIT_HOTKEY)
|
||||||
break;
|
break;
|
||||||
if (is_exit_key(es->u.key))
|
switch (es.u.key) {
|
||||||
return es->u.key;
|
|
||||||
switch (es->u.key) {
|
|
||||||
case NEWT_KEY_DOWN:
|
case NEWT_KEY_DOWN:
|
||||||
if (self->index == self->nr_entries - 1)
|
if (self->index == self->nr_entries - 1)
|
||||||
break;
|
break;
|
||||||
@ -275,12 +275,12 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es)
|
|||||||
self->seek(self, -offset, SEEK_END);
|
self->seek(self, -offset, SEEK_END);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return es->u.key;
|
return es.u.key;
|
||||||
}
|
}
|
||||||
if (ui_browser__refresh(self) < 0)
|
if (ui_browser__refresh(self) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ui_browser__list_head_refresh(struct ui_browser *self)
|
unsigned int ui_browser__list_head_refresh(struct ui_browser *self)
|
||||||
|
@ -37,7 +37,7 @@ int ui_browser__show(struct ui_browser *self, const char *title,
|
|||||||
const char *helpline, ...);
|
const char *helpline, ...);
|
||||||
void ui_browser__hide(struct ui_browser *self);
|
void ui_browser__hide(struct ui_browser *self);
|
||||||
int ui_browser__refresh(struct ui_browser *self);
|
int ui_browser__refresh(struct ui_browser *self);
|
||||||
int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es);
|
int ui_browser__run(struct ui_browser *self);
|
||||||
|
|
||||||
void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence);
|
void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence);
|
||||||
unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self);
|
unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self);
|
||||||
|
@ -133,14 +133,14 @@ static void annotate_browser__set_top(struct annotate_browser *self,
|
|||||||
self->curr_hot = nd;
|
self->curr_hot = nd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int annotate_browser__run(struct annotate_browser *self,
|
static int annotate_browser__run(struct annotate_browser *self)
|
||||||
struct newtExitStruct *es)
|
|
||||||
{
|
{
|
||||||
struct rb_node *nd;
|
struct rb_node *nd;
|
||||||
struct hist_entry *he = self->b.priv;
|
struct hist_entry *he = self->b.priv;
|
||||||
|
int key;
|
||||||
|
|
||||||
if (ui_browser__show(&self->b, he->ms.sym->name,
|
if (ui_browser__show(&self->b, he->ms.sym->name,
|
||||||
"<- or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0)
|
"<-, -> or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
|
newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
|
||||||
@ -153,12 +153,9 @@ static int annotate_browser__run(struct annotate_browser *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ui_browser__run(&self->b, es);
|
key = ui_browser__run(&self->b);
|
||||||
|
|
||||||
if (es->reason != NEWT_EXIT_HOTKEY)
|
switch (key) {
|
||||||
break;
|
|
||||||
|
|
||||||
switch (es->u.key) {
|
|
||||||
case NEWT_KEY_TAB:
|
case NEWT_KEY_TAB:
|
||||||
nd = rb_prev(nd);
|
nd = rb_prev(nd);
|
||||||
if (nd == NULL)
|
if (nd == NULL)
|
||||||
@ -177,12 +174,11 @@ static int annotate_browser__run(struct annotate_browser *self,
|
|||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
ui_browser__hide(&self->b);
|
ui_browser__hide(&self->b);
|
||||||
return es->u.key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hist_entry__tui_annotate(struct hist_entry *self)
|
int hist_entry__tui_annotate(struct hist_entry *self)
|
||||||
{
|
{
|
||||||
struct newtExitStruct es;
|
|
||||||
struct objdump_line *pos, *n;
|
struct objdump_line *pos, *n;
|
||||||
struct objdump_line_rb_node *rbpos;
|
struct objdump_line_rb_node *rbpos;
|
||||||
LIST_HEAD(head);
|
LIST_HEAD(head);
|
||||||
@ -230,7 +226,7 @@ int hist_entry__tui_annotate(struct hist_entry *self)
|
|||||||
annotate_browser__set_top(&browser, browser.curr_hot);
|
annotate_browser__set_top(&browser, browser.curr_hot);
|
||||||
|
|
||||||
browser.b.width += 18; /* Percentage */
|
browser.b.width += 18; /* Percentage */
|
||||||
ret = annotate_browser__run(&browser, &es);
|
ret = annotate_browser__run(&browser);
|
||||||
list_for_each_entry_safe(pos, n, &head, node) {
|
list_for_each_entry_safe(pos, n, &head, node) {
|
||||||
list_del(&pos->node);
|
list_del(&pos->node);
|
||||||
objdump_line__free(pos);
|
objdump_line__free(pos);
|
||||||
|
@ -195,9 +195,9 @@ static bool hist_browser__toggle_fold(struct hist_browser *self)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hist_browser__run(struct hist_browser *self, const char *title,
|
static int hist_browser__run(struct hist_browser *self, const char *title)
|
||||||
struct newtExitStruct *es)
|
|
||||||
{
|
{
|
||||||
|
int key;
|
||||||
char str[256], unit;
|
char str[256], unit;
|
||||||
unsigned long nr_events = self->hists->stats.nr_events[PERF_RECORD_SAMPLE];
|
unsigned long nr_events = self->hists->stats.nr_events[PERF_RECORD_SAMPLE];
|
||||||
|
|
||||||
@ -227,11 +227,9 @@ static int hist_browser__run(struct hist_browser *self, const char *title,
|
|||||||
newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER);
|
newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ui_browser__run(&self->b, es);
|
key = ui_browser__run(&self->b);
|
||||||
|
|
||||||
if (es->reason != NEWT_EXIT_HOTKEY)
|
switch (key) {
|
||||||
break;
|
|
||||||
switch (es->u.key) {
|
|
||||||
case 'D': { /* Debug */
|
case 'D': { /* Debug */
|
||||||
static int seq;
|
static int seq;
|
||||||
struct hist_entry *h = rb_entry(self->b.top,
|
struct hist_entry *h = rb_entry(self->b.top,
|
||||||
@ -251,12 +249,12 @@ static int hist_browser__run(struct hist_browser *self, const char *title,
|
|||||||
break;
|
break;
|
||||||
/* fall thru */
|
/* fall thru */
|
||||||
default:
|
default:
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
ui_browser__hide(&self->b);
|
ui_browser__hide(&self->b);
|
||||||
return 0;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *callchain_list__sym_name(struct callchain_list *self,
|
static char *callchain_list__sym_name(struct callchain_list *self,
|
||||||
@ -687,8 +685,6 @@ static struct hist_browser *hist_browser__new(struct hists *hists)
|
|||||||
|
|
||||||
static void hist_browser__delete(struct hist_browser *self)
|
static void hist_browser__delete(struct hist_browser *self)
|
||||||
{
|
{
|
||||||
newtFormDestroy(self->b.form);
|
|
||||||
newtPopWindow();
|
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,7 +721,6 @@ int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
|
|||||||
struct pstack *fstack;
|
struct pstack *fstack;
|
||||||
const struct thread *thread_filter = NULL;
|
const struct thread *thread_filter = NULL;
|
||||||
const struct dso *dso_filter = NULL;
|
const struct dso *dso_filter = NULL;
|
||||||
struct newtExitStruct es;
|
|
||||||
char msg[160];
|
char msg[160];
|
||||||
int key = -1;
|
int key = -1;
|
||||||
|
|
||||||
@ -749,15 +744,11 @@ int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
|
|||||||
annotate = -2, zoom_dso = -2, zoom_thread = -2,
|
annotate = -2, zoom_dso = -2, zoom_thread = -2,
|
||||||
browse_map = -2;
|
browse_map = -2;
|
||||||
|
|
||||||
if (hist_browser__run(browser, msg, &es))
|
key = hist_browser__run(browser, msg);
|
||||||
break;
|
|
||||||
|
|
||||||
thread = hist_browser__selected_thread(browser);
|
thread = hist_browser__selected_thread(browser);
|
||||||
dso = browser->selection->map ? browser->selection->map->dso : NULL;
|
dso = browser->selection->map ? browser->selection->map->dso : NULL;
|
||||||
|
|
||||||
if (es.reason == NEWT_EXIT_HOTKEY) {
|
|
||||||
key = es.u.key;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case NEWT_KEY_F1:
|
case NEWT_KEY_F1:
|
||||||
goto do_help;
|
goto do_help;
|
||||||
@ -768,10 +759,6 @@ int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
|
|||||||
* go to the next or previous
|
* go to the next or previous
|
||||||
*/
|
*/
|
||||||
goto out_free_stack;
|
goto out_free_stack;
|
||||||
default:;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (key) {
|
|
||||||
case 'a':
|
case 'a':
|
||||||
if (browser->selection->map == NULL &&
|
if (browser->selection->map == NULL &&
|
||||||
browser->selection->map->dso->annotate_warned)
|
browser->selection->map->dso->annotate_warned)
|
||||||
@ -792,16 +779,11 @@ do_help:
|
|||||||
"t Zoom into current Thread\n"
|
"t Zoom into current Thread\n"
|
||||||
"q/CTRL+C Exit browser");
|
"q/CTRL+C Exit browser");
|
||||||
continue;
|
continue;
|
||||||
default:;
|
case NEWT_KEY_ENTER:
|
||||||
}
|
case NEWT_KEY_RIGHT:
|
||||||
if (is_exit_key(key)) {
|
/* menu */
|
||||||
if (key == NEWT_KEY_ESCAPE &&
|
|
||||||
!ui__dialog_yesno("Do you really want to exit?"))
|
|
||||||
continue;
|
|
||||||
break;
|
break;
|
||||||
}
|
case NEWT_KEY_LEFT: {
|
||||||
|
|
||||||
if (es.u.key == NEWT_KEY_LEFT) {
|
|
||||||
const void *top;
|
const void *top;
|
||||||
|
|
||||||
if (pstack__empty(fstack))
|
if (pstack__empty(fstack))
|
||||||
@ -813,6 +795,12 @@ do_help:
|
|||||||
goto zoom_out_thread;
|
goto zoom_out_thread;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
case NEWT_KEY_ESCAPE:
|
||||||
|
if (!ui__dialog_yesno("Do you really want to exit?"))
|
||||||
|
continue;
|
||||||
|
/* Fall thru */
|
||||||
|
default:
|
||||||
|
goto out_free_stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser->selection->sym != NULL &&
|
if (browser->selection->sym != NULL &&
|
||||||
@ -925,10 +913,6 @@ int hists__tui_browse_tree(struct rb_root *self, const char *help)
|
|||||||
const char *ev_name = __event_name(hists->type, hists->config);
|
const char *ev_name = __event_name(hists->type, hists->config);
|
||||||
|
|
||||||
key = hists__browse(hists, help, ev_name);
|
key = hists__browse(hists, help, ev_name);
|
||||||
|
|
||||||
if (is_exit_key(key))
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case NEWT_KEY_TAB:
|
case NEWT_KEY_TAB:
|
||||||
next = rb_next(nd);
|
next = rb_next(nd);
|
||||||
@ -940,7 +924,7 @@ int hists__tui_browse_tree(struct rb_root *self, const char *help)
|
|||||||
continue;
|
continue;
|
||||||
nd = rb_prev(nd);
|
nd = rb_prev(nd);
|
||||||
default:
|
default:
|
||||||
break;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,31 +97,34 @@ static int map_browser__search(struct map_browser *self)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int map_browser__run(struct map_browser *self, struct newtExitStruct *es)
|
static int map_browser__run(struct map_browser *self)
|
||||||
{
|
{
|
||||||
|
int key;
|
||||||
|
|
||||||
if (ui_browser__show(&self->b, self->map->dso->long_name,
|
if (ui_browser__show(&self->b, self->map->dso->long_name,
|
||||||
"Press <- or ESC to exit, %s / to search",
|
"Press <- or ESC to exit, %s / to search",
|
||||||
verbose ? "" : "restart with -v to use") < 0)
|
verbose ? "" : "restart with -v to use") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
|
newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
|
||||||
newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER);
|
newtFormAddHotKey(self->b.form, NEWT_KEY_ESCAPE);
|
||||||
|
newtFormAddHotKey(self->b.form, 'Q');
|
||||||
|
newtFormAddHotKey(self->b.form, 'q');
|
||||||
|
newtFormAddHotKey(self->b.form, CTRL('c'));
|
||||||
if (verbose)
|
if (verbose)
|
||||||
newtFormAddHotKey(self->b.form, '/');
|
newtFormAddHotKey(self->b.form, '/');
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ui_browser__run(&self->b, es);
|
key = ui_browser__run(&self->b);
|
||||||
|
|
||||||
if (es->reason != NEWT_EXIT_HOTKEY)
|
if (verbose && key == '/')
|
||||||
break;
|
|
||||||
if (verbose && es->u.key == '/')
|
|
||||||
map_browser__search(self);
|
map_browser__search(self);
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_browser__hide(&self->b);
|
ui_browser__hide(&self->b);
|
||||||
return 0;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int map__browse(struct map *self)
|
int map__browse(struct map *self)
|
||||||
@ -135,7 +138,6 @@ int map__browse(struct map *self)
|
|||||||
},
|
},
|
||||||
.map = self,
|
.map = self,
|
||||||
};
|
};
|
||||||
struct newtExitStruct es;
|
|
||||||
struct rb_node *nd;
|
struct rb_node *nd;
|
||||||
char tmp[BITS_PER_LONG / 4];
|
char tmp[BITS_PER_LONG / 4];
|
||||||
u64 maxaddr = 0;
|
u64 maxaddr = 0;
|
||||||
@ -156,5 +158,5 @@ int map__browse(struct map *self)
|
|||||||
|
|
||||||
mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr);
|
mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr);
|
||||||
mb.b.width += mb.addrlen * 2 + 4 + mb.namelen;
|
mb.b.width += mb.addrlen * 2 + 4 + mb.namelen;
|
||||||
return map_browser__run(&mb, &es);
|
return map_browser__run(&mb);
|
||||||
}
|
}
|
||||||
|
@ -266,19 +266,6 @@ bool strglobmatch(const char *str, const char *pat);
|
|||||||
bool strlazymatch(const char *str, const char *pat);
|
bool strlazymatch(const char *str, const char *pat);
|
||||||
unsigned long convert_unit(unsigned long value, char *unit);
|
unsigned long convert_unit(unsigned long value, char *unit);
|
||||||
|
|
||||||
#ifndef ESC
|
|
||||||
#define ESC 27
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool is_exit_key(int key)
|
|
||||||
{
|
|
||||||
char up;
|
|
||||||
if (key == CTRL('c') || key == ESC)
|
|
||||||
return true;
|
|
||||||
up = toupper(key);
|
|
||||||
return up == 'Q';
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _STR(x) #x
|
#define _STR(x) #x
|
||||||
#define STR(x) _STR(x)
|
#define STR(x) _STR(x)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user