aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 3c9ba943aa4..104de9ab314 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -20,6 +20,7 @@
20 20
21#include "perf.h" 21#include "perf.h"
22 22
23#include "util/cache.h"
23#include "util/color.h" 24#include "util/color.h"
24#include "util/evlist.h" 25#include "util/evlist.h"
25#include "util/evsel.h" 26#include "util/evsel.h"
@@ -75,6 +76,8 @@ static struct perf_top top = {
75 76
76static bool system_wide = false; 77static bool system_wide = false;
77 78
79static bool use_tui, use_stdio;
80
78static int default_interval = 0; 81static int default_interval = 0;
79 82
80static bool inherit = false; 83static bool inherit = false;
@@ -96,11 +99,6 @@ static int sym_pcnt_filter = 5;
96 * Source functions 99 * Source functions
97 */ 100 */
98 101
99static inline struct symbol *sym_entry__symbol(struct sym_entry *self)
100{
101 return ((void *)self) + symbol_conf.priv_size;
102}
103
104void get_term_dimensions(struct winsize *ws) 102void get_term_dimensions(struct winsize *ws)
105{ 103{
106 char *s = getenv("LINES"); 104 char *s = getenv("LINES");
@@ -695,6 +693,14 @@ static void handle_keypress(struct perf_session *session, int c)
695 } 693 }
696} 694}
697 695
696static void *display_thread_tui(void *arg __used)
697{
698 perf_top__tui_browser(&top);
699 exit_browser(0);
700 exit(0);
701 return NULL;
702}
703
698static void *display_thread(void *arg __used) 704static void *display_thread(void *arg __used)
699{ 705{
700 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN }; 706 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
@@ -1005,7 +1011,8 @@ static int __cmd_top(void)
1005 1011
1006 perf_session__mmap_read(session); 1012 perf_session__mmap_read(session);
1007 1013
1008 if (pthread_create(&thread, NULL, display_thread, session)) { 1014 if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui :
1015 display_thread), session)) {
1009 printf("Could not create display thread.\n"); 1016 printf("Could not create display thread.\n");
1010 exit(-1); 1017 exit(-1);
1011 } 1018 }
@@ -1078,6 +1085,8 @@ static const struct option options[] = {
1078 "display this many functions"), 1085 "display this many functions"),
1079 OPT_BOOLEAN('U', "hide_user_symbols", &top.hide_user_symbols, 1086 OPT_BOOLEAN('U', "hide_user_symbols", &top.hide_user_symbols,
1080 "hide user symbols"), 1087 "hide user symbols"),
1088 OPT_BOOLEAN(0, "tui", &use_tui, "Use the TUI interface"),
1089 OPT_BOOLEAN(0, "stdio", &use_stdio, "Use the stdio interface"),
1081 OPT_INCR('v', "verbose", &verbose, 1090 OPT_INCR('v', "verbose", &verbose,
1082 "be more verbose (show counter open errors, etc)"), 1091 "be more verbose (show counter open errors, etc)"),
1083 OPT_END() 1092 OPT_END()
@@ -1098,6 +1107,20 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1098 if (argc) 1107 if (argc)
1099 usage_with_options(top_usage, options); 1108 usage_with_options(top_usage, options);
1100 1109
1110 /*
1111 * XXX For now start disabled, only using TUI if explicitely asked for.
1112 * Change that when handle_keys equivalent gets written, live annotation
1113 * done, etc.
1114 */
1115 use_browser = 0;
1116
1117 if (use_stdio)
1118 use_browser = 0;
1119 else if (use_tui)
1120 use_browser = 1;
1121
1122 setup_browser(false);
1123
1101 /* CPU and PID are mutually exclusive */ 1124 /* CPU and PID are mutually exclusive */
1102 if (top.target_tid > 0 && top.cpu_list) { 1125 if (top.target_tid > 0 && top.cpu_list) {
1103 printf("WARNING: PID switch overriding CPU\n"); 1126 printf("WARNING: PID switch overriding CPU\n");