6 #include <linux/kernel.h>
7 #ifdef HAVE_BACKTRACE_SUPPORT
11 #include "../../util/debug.h"
12 #include "../../perf.h"
13 #include "../browser.h"
14 #include "../helpline.h"
17 #include "../libslang.h"
18 #include "../keysyms.h"
21 static volatile int ui__need_resize
;
23 extern struct perf_error_ops perf_tui_eops
;
24 extern bool tui_helpline__set
;
26 extern void hist_browser__init_hpp(void);
28 void ui__refresh_dimensions(bool force
)
30 if (force
|| ui__need_resize
) {
32 pthread_mutex_lock(&ui__lock
);
33 SLtt_get_screen_size();
35 pthread_mutex_unlock(&ui__lock
);
39 static void ui__sigwinch(int sig __maybe_unused
)
44 static void ui__setup_sigwinch(void)
52 pthread__unblock_sigwinch();
53 signal(SIGWINCH
, ui__sigwinch
);
56 int ui__getch(int delay_secs
)
58 struct timeval timeout
, *ptimeout
= delay_secs
? &timeout
: NULL
;
68 timeout
.tv_sec
= delay_secs
;
72 err
= select(1, &read_set
, NULL
, NULL
, ptimeout
);
91 err
= select(1, &read_set
, NULL
, NULL
, &timeout
);
99 #ifdef HAVE_BACKTRACE_SUPPORT
100 static void ui__signal_backtrace(int sig
)
106 psignal(sig
, "perf");
108 printf("-------- backtrace --------\n");
109 size
= backtrace(stackdump
, ARRAY_SIZE(stackdump
));
110 backtrace_symbols_fd(stackdump
, size
, STDOUT_FILENO
);
115 # define ui__signal_backtrace ui__signal
118 static void ui__signal(int sig
)
121 psignal(sig
, "perf");
131 SLtt_get_screen_size();
133 err
= SLsmg_init_smg();
136 err
= SLang_init_tty(-1, 0, 0);
142 pr_err("TUI initialization failed.\n");
146 SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB
);
148 signal(SIGSEGV
, ui__signal_backtrace
);
149 signal(SIGFPE
, ui__signal_backtrace
);
150 signal(SIGINT
, ui__signal
);
151 signal(SIGQUIT
, ui__signal
);
152 signal(SIGTERM
, ui__signal
);
154 perf_error__register(&perf_tui_eops
);
158 tui_progress__init();
160 hist_browser__init_hpp();
165 void ui__exit(bool wait_for_ok
)
167 if (wait_for_ok
&& tui_helpline__set
)
168 ui__question_window("Fatal Error",
169 ui_helpline__last_msg
,
170 "Press any key...", 0);
172 SLtt_set_cursor_visibility(1);
177 perf_error__unregister(&perf_tui_eops
);