perf tui: Remove annotate from popup menu after failure
[linux-2.6.git] / tools / perf / util / newt.c
index 051022e..c65838c 100644 (file)
@@ -914,6 +914,9 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na
 
                        switch (toupper(es.u.key)) {
                        case 'A':
+                               if (browser->selection->map == NULL &&
+                                   browser->selection->map->dso->annotate_warned)
+                                       continue;
                                goto do_annotate;
                        case 'D':
                                goto zoom_dso;
@@ -957,6 +960,7 @@ do_help:
                }
 
                if (browser->selection->sym != NULL &&
+                   !browser->selection->map->dso->annotate_warned &&
                    asprintf(&options[nr_options], "Annotate %s",
                             browser->selection->sym->name) > 0)
                        annotate = nr_options++;
@@ -991,6 +995,7 @@ do_help:
                        struct hist_entry *he;
 do_annotate:
                        if (browser->selection->map->dso->origin == DSO__ORIG_KERNEL) {
+                               browser->selection->map->dso->annotate_warned = 1;
                                ui_helpline__puts("No vmlinux file found, can't "
                                                 "annotate with just a "
                                                 "kallsyms file");
@@ -1068,10 +1073,13 @@ static struct newtPercentTreeColors {
 void setup_browser(void)
 {
        struct newtPercentTreeColors *c = &defaultPercentTreeColors;
-       if (!isatty(1))
+
+       if (!isatty(1) || !use_browser) {
+               setup_pager();
                return;
+       }
 
-       use_browser = true;
+       use_browser = 1;
        newtInit();
        newtCls();
        ui_helpline__puts(" ");
@@ -1084,7 +1092,7 @@ void setup_browser(void)
 
 void exit_browser(bool wait_for_ok)
 {
-       if (use_browser) {
+       if (use_browser > 0) {
                if (wait_for_ok) {
                        char title[] = "Fatal Error", ok[] = "Ok";
                        newtWinMessage(title, ok, browser__last_msg);