3 #ifdef HAVE_BACKTRACE_SUPPORT
7 #include "../../util/cache.h"
8 #include "../../util/debug.h"
9 #include "../browser.h"
10 #include "../helpline.h"
13 #include "../libslang.h"
14 #include "../keysyms.h"
17 static volatile int ui__need_resize
;
19 extern struct perf_error_ops perf_tui_eops
;
20 extern bool tui_helpline__set
;
22 extern void hist_browser__init_hpp(void);
24 void ui__refresh_dimensions(bool force
)
26 if (force
|| ui__need_resize
) {
28 pthread_mutex_lock(&ui__lock
);
29 SLtt_get_screen_size();
31 pthread_mutex_unlock(&ui__lock
);
35 static void ui__sigwinch(int sig __maybe_unused
)
40 static void ui__setup_sigwinch(void)
48 pthread__unblock_sigwinch();
49 signal(SIGWINCH
, ui__sigwinch
);
52 int ui__getch(int delay_secs
)
54 struct timeval timeout
, *ptimeout
= delay_secs
? &timeout
: NULL
;
64 timeout
.tv_sec
= delay_secs
;
68 err
= select(1, &read_set
, NULL
, NULL
, ptimeout
);
87 err
= select(1, &read_set
, NULL
, NULL
, &timeout
);
95 #ifdef HAVE_BACKTRACE_SUPPORT
96 static void ui__signal_backtrace(int sig
)
102 psignal(sig
, "perf");
104 printf("-------- backtrace --------\n");
105 size
= backtrace(stackdump
, ARRAY_SIZE(stackdump
));
106 backtrace_symbols_fd(stackdump
, size
, STDOUT_FILENO
);
111 # define ui__signal_backtrace ui__signal
114 static void ui__signal(int sig
)
117 psignal(sig
, "perf");
127 SLtt_get_screen_size();
129 err
= SLsmg_init_smg();
132 err
= SLang_init_tty(-1, 0, 0);
138 pr_err("TUI initialization failed.\n");
142 SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB
);
144 signal(SIGSEGV
, ui__signal_backtrace
);
145 signal(SIGFPE
, ui__signal_backtrace
);
146 signal(SIGINT
, ui__signal
);
147 signal(SIGQUIT
, ui__signal
);
148 signal(SIGTERM
, ui__signal
);
150 perf_error__register(&perf_tui_eops
);
154 tui_progress__init();
156 hist_browser__init_hpp();
161 void ui__exit(bool wait_for_ok
)
163 if (wait_for_ok
&& tui_helpline__set
)
164 ui__question_window("Fatal Error",
165 ui_helpline__last_msg
,
166 "Press any key...", 0);
168 SLtt_set_cursor_visibility(1);
173 perf_error__unregister(&perf_tui_eops
);