2 * Copyright (C) 2011 Julien Desfossez
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <semaphore.h>
27 #include "cursesdisplay.h"
28 #include "lttngtoptypes.h"
29 #include "iostreamtop.h"
32 #define DEFAULT_DELAY 15
33 #define MAX_LINE_LENGTH 50
34 #define MAX_LOG_LINES 4
36 /* to prevent concurrent updates of the different windows */
37 sem_t update_display_sem
;
40 WINDOW
*footer
, *header
, *center
, *status
;
41 WINDOW
*perf_panel_window
= NULL
;
42 PANEL
*perf_panel
, *main_panel
;
44 int perf_panel_visible
= 0;
45 int perf_line_selected
= 0;
47 int last_display_index
, currently_displayed_index
;
49 struct processtop
*selected_process
= NULL
;
54 int selected_line
= 0; /* select bar position */
55 int selected_in_list
= 0; /* selection relative to the whole list */
56 int list_offset
= 0; /* first index in the list to display (scroll) */
58 char log_lines
[MAX_LINE_LENGTH
* MAX_LOG_LINES
+ MAX_LOG_LINES
];
60 int max_elements
= 80;
62 int toggle_threads
= -1;
63 int toggle_pause
= -1;
68 pthread_t keyboard_thread
;
77 static void handle_sigterm(int signal
)
86 halfdelay(DEFAULT_DELAY
);
88 intrflush(stdscr
, false);
94 init_pair(1, COLOR_RED
, COLOR_BLACK
); /* - */
95 init_pair(2, COLOR_GREEN
, COLOR_BLACK
); /* + */
96 init_pair(3, COLOR_BLACK
, COLOR_WHITE
); /* keys */
97 init_pair(4, COLOR_WHITE
, COLOR_GREEN
); /* keys activated */
98 init_pair(5, COLOR_WHITE
, COLOR_BLUE
); /* select line */
100 termtype
= getenv("TERM");
101 if (!strcmp(termtype
, "xterm") || !strcmp(termtype
, "xterm-color") ||
102 !strcmp(termtype
, "vt220")) {
103 define_key("\033[H", KEY_HOME
);
104 define_key("\033[F", KEY_END
);
105 define_key("\033OP", KEY_F(1));
106 define_key("\033OQ", KEY_F(2));
107 define_key("\033OR", KEY_F(3));
108 define_key("\033OS", KEY_F(4));
109 define_key("\0330U", KEY_F(6));
110 define_key("\033[11~", KEY_F(1));
111 define_key("\033[12~", KEY_F(2));
112 define_key("\033[13~", KEY_F(3));
113 define_key("\033[14~", KEY_F(4));
114 define_key("\033[16~", KEY_F(6));
115 define_key("\033[17;2~", KEY_F(18));
117 signal(SIGTERM
, handle_sigterm
);
118 mousemask(BUTTON1_CLICKED
, NULL
);
122 WINDOW
*create_window(int height
, int width
, int startx
, int starty
)
125 win
= newwin(height
, width
, startx
, starty
);
131 WINDOW
*create_window_no_border(int height
, int width
, int startx
, int starty
)
134 win
= newwin(height
, width
, startx
, starty
);
139 void print_digit(WINDOW
*win
, int digit
)
142 wattron(win
, COLOR_PAIR(1));
143 wprintw(win
, "%d", digit
);
144 wattroff(win
, COLOR_PAIR(1));
145 } else if (digit
> 0) {
146 wattron(win
, COLOR_PAIR(2));
147 wprintw(win
, "+%d", digit
);
148 wattroff(win
, COLOR_PAIR(2));
154 void print_digits(WINDOW
*win
, int first
, int second
)
157 print_digit(win
, first
);
159 print_digit(win
, second
);
163 void print_headers(int line
, char *desc
, int value
, int first
, int second
)
165 wattron(header
, A_BOLD
);
166 mvwprintw(header
, line
, 4, "%s", desc
);
167 wattroff(header
, A_BOLD
);
168 mvwprintw(header
, line
, 16, "N/A", value
);
169 wmove(header
, line
, 24);
170 print_digits(header
, first
, second
);
171 wmove(header
, line
, 40);
174 void set_window_title(WINDOW
*win
, char *title
)
176 wattron(win
, A_BOLD
);
177 mvwprintw(win
, 0, 1, title
);
178 wattroff(win
, A_BOLD
);
181 void print_log(char *str
)
184 int current_line
= 1;
185 int current_char
= 1;
187 /* rotate the line buffer */
188 if (nb_log_lines
>= MAX_LOG_LINES
) {
189 tmp
= strndup(log_lines
, MAX_LINE_LENGTH
* MAX_LOG_LINES
+ MAX_LOG_LINES
);
190 tmp2
= strchr(tmp
, '\n');
191 memset(log_lines
, '\0', strlen(log_lines
));
192 strncat(log_lines
, tmp2
+ 1, strlen(tmp2
) - 1);
193 log_lines
[strlen(log_lines
)] = '\n';
194 log_lines
[strlen(log_lines
)] = '\0';
199 strncat(log_lines
, str
, MAX_LINE_LENGTH
- 1);
201 if (nb_log_lines
< MAX_LOG_LINES
)
202 log_lines
[strlen(log_lines
)] = '\n';
203 log_lines
[strlen(log_lines
)] = '\0';
207 set_window_title(status
, "Status");
208 for (i
= 0; i
< strlen(log_lines
); i
++) {
209 if (log_lines
[i
] == '\n') {
210 wmove(status
, ++current_line
, 1);
213 mvwprintw(status
, current_line
, current_char
++, "%c",
220 void print_key(WINDOW
*win
, char *key
, char *desc
, int toggle
)
227 wattron(win
, COLOR_PAIR(pair
));
228 wprintw(footer
, "%s", key
);
229 wattroff(win
, COLOR_PAIR(pair
));
230 wprintw(footer
, ":%s", desc
);
235 sem_wait(&update_display_sem
);
238 print_key(footer
, "F2", "CPUtop ", current_view
== cpu
);
239 print_key(footer
, "F3", "PerfTop ", current_view
== perf
);
240 print_key(footer
, "F6", "IOTop ", current_view
== iostream
);
241 print_key(footer
, "Enter", "Details ", current_view
== process_details
);
242 print_key(footer
, "q", "Quit | ", 0);
243 print_key(footer
, "P", "Perf Pref ", 0);
244 print_key(footer
, "p", "Pause ", toggle_pause
);
247 sem_post(&update_display_sem
);
254 set_window_title(header
, "Statistics for interval [gathering data...[");
255 wattron(header
, A_BOLD
);
256 mvwprintw(header
, 1, 4, "CPUs");
257 mvwprintw(header
, 2, 4, "Processes");
258 mvwprintw(header
, 3, 4, "Threads");
259 mvwprintw(header
, 4, 4, "Files");
260 mvwprintw(header
, 5, 4, "Network");
261 mvwprintw(header
, 6, 4, "IO");
262 wattroff(header
, A_BOLD
);
270 set_window_title(header
, "Statistics for interval ");
271 wattron(header
, A_BOLD
);
273 wprintw(header, "[%lu.%lu, %lu.%lu[",
274 data->start.tv_sec, data->start.tv_nsec,
275 data->end.tv_sec, data->end.tv_nsec);
277 wprintw(header
, "[%lu, %lu[",
280 mvwprintw(header
, 1, 4, "CPUs");
281 wattroff(header
, A_BOLD
);
282 wprintw(header
, "\t%d\t(max/cpu : %0.2f%)", data
->cpu_table
->len
,
283 100.0/data
->cpu_table
->len
);
284 print_headers(2, "Processes", data
->nbproc
, data
->nbnewproc
,
285 -1*(data
->nbdeadproc
));
286 print_headers(3, "Threads", data
->nbthreads
, data
->nbnewthreads
,
287 -1*(data
->nbdeadthreads
));
288 print_headers(4, "Files", data
->nbfiles
, data
->nbnewfiles
,
289 -1*(data
->nbclosedfiles
));
290 mvwprintw(header
, 4, 43, "N/A kbytes/sec");
291 print_headers(5, "Network", 114, 0, 0);
292 mvwprintw(header
, 5, 43, "N/A Mbytes/sec");
296 gint
sort_by_cpu_desc(gconstpointer p1
, gconstpointer p2
)
298 struct processtop
*n1
= *(struct processtop
**)p1
;
299 struct processtop
*n2
= *(struct processtop
**)p2
;
300 unsigned long totaln1
= n1
->totalcpunsec
;
301 unsigned long totaln2
= n2
->totalcpunsec
;
303 if (totaln1
< totaln2
)
305 if (totaln1
== totaln2
)
310 gint
sort_by_cpu_group_by_threads_desc(gconstpointer p1
, gconstpointer p2
)
312 struct processtop
*n1
= *(struct processtop
**)p1
;
313 struct processtop
*n2
= *(struct processtop
**)p2
;
314 unsigned long totaln1
= n1
->threadstotalcpunsec
;
315 unsigned long totaln2
= n2
->threadstotalcpunsec
;
317 if (totaln1
< totaln2
)
319 if (totaln1
== totaln2
)
324 void update_cputop_display()
327 int header_offset
= 2;
328 struct processtop
*tmp
;
329 unsigned long elapsed
;
331 int nblinedisplayed
= 0;
332 int current_line
= 0;
334 elapsed
= data
->end
- data
->start
;
335 maxcputime
= elapsed
* data
->cpu_table
->len
/ 100.0;
337 g_ptr_array_sort(data
->process_table
, sort_by_cpu_desc
);
339 set_window_title(center
, "CPU Top");
340 wattron(center
, A_BOLD
);
341 mvwprintw(center
, 1, 1, "CPU(%)");
342 mvwprintw(center
, 1, 12, "TGID");
343 mvwprintw(center
, 1, 22, "PID");
344 mvwprintw(center
, 1, 32, "NAME");
345 wattroff(center
, A_BOLD
);
347 max_center_lines
= LINES
- 7 - 7 - 1 - header_offset
;
349 /* iterate the process (thread) list */
350 for (i
= list_offset
; i
< data
->process_table
->len
&&
351 nblinedisplayed
< max_center_lines
; i
++) {
352 tmp
= g_ptr_array_index(data
->process_table
, i
);
354 if (current_line
== selected_line
) {
355 selected_process
= tmp
;
356 selected_tid
= tmp
->tid
;
357 selected_comm
= tmp
->comm
;
358 wattron(center
, COLOR_PAIR(5));
359 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
362 mvwprintw(center
, current_line
+ header_offset
, 1, "%1.2f",
363 tmp
->totalcpunsec
/ maxcputime
);
365 mvwprintw(center
, current_line
+ header_offset
, 12, "%d", tmp
->pid
);
367 mvwprintw(center
, current_line
+ header_offset
, 22, "%d", tmp
->tid
);
369 mvwprintw(center
, current_line
+ header_offset
, 32, "%s", tmp
->comm
);
370 wattroff(center
, COLOR_PAIR(5));
376 gint
sort_perf(gconstpointer p1
, gconstpointer p2
, gpointer key
)
378 struct processtop
*n1
= *(struct processtop
**) p1
;
379 struct processtop
*n2
= *(struct processtop
**) p2
;
381 struct perfcounter
*tmp1
, *tmp2
;
382 unsigned long totaln2
= 0;
383 unsigned long totaln1
= 0;
388 tmp1
= g_hash_table_lookup(n1
->perf
, key
);
392 totaln1
= tmp1
->count
;
394 tmp2
= g_hash_table_lookup(n2
->perf
, key
);
398 totaln2
= tmp2
->count
;
400 if (totaln1
< totaln2
)
402 if (totaln1
== totaln2
) {
405 if (totaln1
< totaln2
)
412 void print_key_title(char *key
, int line
)
414 wattron(center
, A_BOLD
);
415 mvwprintw(center
, line
, 1, "%s\t", key
);
416 wattroff(center
, A_BOLD
);
419 void update_process_details()
421 unsigned long elapsed
;
423 struct processtop
*tmp
= find_process_tid(data
, selected_tid
, selected_comm
);
424 struct files
*file_tmp
;
427 set_window_title(center
, "Process details");
430 elapsed
= data
->end
- data
->start
;
431 maxcputime
= elapsed
* data
->cpu_table
->len
/ 100.0;
433 print_key_title("Name", 1);
434 wprintw(center
, "%s", selected_comm
);
435 print_key_title("TID", 2);
436 wprintw(center
, "%d", selected_tid
);
438 print_key_title("Does not exit at this time", 3);
442 print_key_title("PID", 3);
443 wprintw(center
, "%d", tmp
->pid
);
444 print_key_title("PPID", 4);
445 wprintw(center
, "%d", tmp
->ppid
);
446 print_key_title("CPU", 5);
447 wprintw(center
, "%1.2f %%", tmp
->totalcpunsec
/maxcputime
);
449 print_key_title("READ B/s", 6);
450 wprintw(center
, "%d", tmp
->fileread
);
452 print_key_title("WRITE B/s", 7);
453 wprintw(center
, "%d", tmp
->filewrite
);
455 for (i
= 0; i
< tmp
->process_files_table
->len
; i
++) {
456 file_tmp
= get_file(tmp
, i
);
457 if (file_tmp
!= NULL
) {
458 print_key_title("file", 8+j
);
459 wprintw(center
, "%s fd = %d", file_tmp
->name
, i
);
460 wprintw(center
, " read = %d", file_tmp
->read
);
461 wprintw(center
, " write = %d", file_tmp
->write
);
470 int nblinedisplayed
= 0;
471 int current_line
= 0;
472 struct processtop
*tmp
;
473 int header_offset
= 2;
475 struct perfcounter
*perfn1
, *perfn2
;
476 char *perf_key
= NULL
;
481 set_window_title(center
, "Perf Top");
482 wattron(center
, A_BOLD
);
483 mvwprintw(center
, 1, 1, "PID");
484 mvwprintw(center
, 1, 11, "TID");
485 mvwprintw(center
, 1, 22, "NAME");
488 g_hash_table_iter_init(&iter
, data
->perf_list
);
489 while (g_hash_table_iter_next (&iter
, &key
, (gpointer
) &perfn1
)) {
490 if (perfn1
->visible
) {
491 /* + 5 to strip the "perf_" prefix */
492 mvwprintw(center
, 1, perf_row
, "%s",
497 perf_key
= (char *) key
;
501 wattroff(center
, A_BOLD
);
503 g_ptr_array_sort_with_data(data
->process_table
, sort_perf
, perf_key
);
505 for (i
= 0; i
< data
->process_table
->len
&&
506 nblinedisplayed
< max_center_lines
; i
++) {
507 tmp
= g_ptr_array_index(data
->process_table
, i
);
509 if (current_line
== selected_line
) {
510 selected_process
= tmp
;
511 wattron(center
, COLOR_PAIR(5));
512 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
515 mvwprintw(center
, current_line
+ header_offset
, 1, "%d", tmp
->pid
);
516 mvwprintw(center
, current_line
+ header_offset
, 11, "%d", tmp
->tid
);
517 mvwprintw(center
, current_line
+ header_offset
, 22, "%s", tmp
->comm
);
519 g_hash_table_iter_init(&iter
, data
->perf_list
);
522 while (g_hash_table_iter_next (&iter
, &key
, (gpointer
) &perfn1
)) {
523 if (perfn1
->visible
) {
524 perfn2
= g_hash_table_lookup(tmp
->perf
, (char *) key
);
526 value
= perfn2
->count
;
529 mvwprintw(center
, current_line
+ header_offset
,
530 perf_row
, "%d", value
);
535 wattroff(center
, COLOR_PAIR(5));
546 set_window_title(center
, "IO Top");
547 wattron(center
, A_BOLD
);
548 mvwprintw(center
, 1, 10, "READ");
549 mvwprintw(center
, 2, 1, "bytes");
550 mvwprintw(center
, 2, 15, "bytes/sec");
552 mvwprintw(center
, 1, 39, "WRITE");
553 mvwprintw(center
, 2, 33, "bytes");
554 mvwprintw(center
, 2, 45, "bytes/sec");
556 if (toggle_threads
> 0) {
557 mvwprintw(center
, 1, 60, "TGID");
558 mvwprintw(center
, 1, 70, "PID");
561 mvwprintw(center
, 1, 60, "PID(TGID)");
564 mvwprintw(center
, 1, 72 + offset
, "NAME");
565 wattroff(center
, A_BOLD
);
567 for (i
= 3; i
< LINES
- 3 - 8 - 1; i
++) {
568 mvwprintw(center
, i
, 1, "%d", i
*1000);
569 mvwprintw(center
, i
, 15, "%dk", i
);
570 mvwprintw(center
, i
, 28, "| %d", i
*2000);
571 mvwprintw(center
, i
, 45, "%dk", i
*2);
572 if (toggle_threads
> 0) {
573 mvwprintw(center
, i
, 57, "| %d", i
);
574 mvwprintw(center
, i
, 70, "%d", i
);
576 mvwprintw(center
, i
, 57, "| %d", i
);
578 mvwprintw(center
, i
, 72 + offset
, "process_%d", i
);
582 gint
sort_by_ret_desc(gconstpointer p1
, gconstpointer p2
)
584 struct processtop
*n1
= *(struct processtop
**)p1
;
585 struct processtop
*n2
= *(struct processtop
**)p2
;
587 unsigned long totaln1
= n1
->totalfileread
+ n1
->totalfilewrite
;
588 unsigned long totaln2
= n2
->totalfileread
+ n2
->totalfilewrite
;
590 if (totaln1
< totaln2
)
592 if (totaln1
== totaln2
)
597 void update_iostream()
600 int header_offset
= 2;
601 struct processtop
*tmp
;
602 int nblinedisplayed
= 0;
603 int current_line
= 0;
606 set_window_title(center
, "IO Top");
607 wattron(center
, A_BOLD
);
608 mvwprintw(center
, 1, 1, "READ (B/s)");
609 mvwprintw(center
, 1, 20, "WRITE (B/s)");
611 mvwprintw(center
, 1, 40, "TOTAL STREAM");
613 mvwprintw(center
, 1, 60, "TGID");
614 mvwprintw(center
, 1, 80, "PID");
616 mvwprintw(center
, 1, 92, "NAME");
617 wattroff(center
, A_BOLD
);
619 g_ptr_array_sort(data
->process_table
, sort_by_ret_desc
);
621 for (i
= list_offset
; i
< data
->process_table
->len
&&
622 nblinedisplayed
< max_center_lines
; i
++) {
623 tmp
= g_ptr_array_index(data
->process_table
, i
);
625 if (current_line
== selected_line
) {
626 selected_process
= tmp
;
627 selected_tid
= tmp
->tid
;
628 selected_comm
= tmp
->comm
;
629 wattron(center
, COLOR_PAIR(5));
630 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
633 /* READ (bytes/sec) */
634 mvwprintw(center
, current_line
+ header_offset
, 1, "%lu",
637 /* WRITE (bytes/sec) */
638 mvwprintw(center
, current_line
+ header_offset
, 20, "%lu",
642 total
= tmp
->totalfileread
+ tmp
->totalfilewrite
;
644 if (total
>= 1000000)
645 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu MB",
647 else if (total
>= 1000)
648 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu KB",
651 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu B",
655 mvwprintw(center
, current_line
+ header_offset
, 60, "%d", tmp
->pid
);
657 mvwprintw(center
, current_line
+ header_offset
, 80, "%d", tmp
->tid
);
659 mvwprintw(center
, current_line
+ header_offset
, 92, "%s", tmp
->comm
);
660 wattroff(center
, COLOR_PAIR(5));
666 void update_current_view()
668 sem_wait(&update_display_sem
);
675 switch (current_view
) {
677 update_cputop_display();
682 case process_details
:
683 update_process_details();
692 update_cputop_display();
699 sem_post(&update_display_sem
);
702 void setup_perf_panel()
707 if (perf_panel_window
) {
708 del_panel(perf_panel
);
709 delwin(perf_panel_window
);
711 size
= g_hash_table_size(data
->perf_list
);
712 perf_panel_window
= create_window(size
+ 2, 30, 10, 10);
713 perf_panel
= new_panel(perf_panel_window
);
714 perf_panel_visible
= 0;
715 hide_panel(perf_panel
);
718 void update_perf_panel(int line_selected
, int toggle_view
, int toggle_sort
)
721 struct perfcounter
*perf
;
727 werase(perf_panel_window
);
728 box(perf_panel_window
, 0 , 0);
729 set_window_title(perf_panel_window
, "Perf Preferences ");
730 wattron(perf_panel_window
, A_BOLD
);
731 mvwprintw(perf_panel_window
, g_hash_table_size(data
->perf_list
) + 1, 1,
733 wattroff(perf_panel_window
, A_BOLD
);
735 if (toggle_sort
== 1) {
737 perflist
= g_list_first(g_hash_table_get_keys(data
->perf_list
));
739 perf
= g_hash_table_lookup(data
->perf_list
, perflist
->data
);
740 if (i
!= line_selected
)
745 perflist
= g_list_next(perflist
);
747 update_current_view();
751 perflist
= g_list_first(g_hash_table_get_keys(data
->perf_list
));
753 perf
= g_hash_table_lookup(data
->perf_list
, perflist
->data
);
754 if (i
== line_selected
&& toggle_view
== 1) {
755 perf
->visible
= perf
->visible
== 1 ? 0:1;
756 update_current_view();
758 if (i
== line_selected
) {
759 wattron(perf_panel_window
, COLOR_PAIR(5));
760 mvwhline(perf_panel_window
, i
+ 1, 1, ' ', 30 - 2);
763 wattron(perf_panel_window
, A_BOLD
);
764 mvwprintw(perf_panel_window
, i
+ 1, 1, "[%c] %s",
765 perf
->visible
== 1 ? 'x' : ' ',
766 (char *) perflist
->data
+ 6);
767 wattroff(perf_panel_window
, A_BOLD
);
768 wattroff(perf_panel_window
, COLOR_PAIR(5));
770 perflist
= g_list_next(perflist
);
777 void toggle_perf_panel(void)
779 if (perf_panel_visible
) {
780 hide_panel(perf_panel
);
781 perf_panel_visible
= 0;
784 update_perf_panel(perf_line_selected
, 0, 0);
785 show_panel(perf_panel
);
786 perf_panel_visible
= 1;
792 void display(unsigned int index
)
794 last_display_index
= index
;
795 currently_displayed_index
= index
;
796 data
= g_ptr_array_index(copies
, index
);
799 max_elements
= data
->process_table
->len
;
800 update_current_view();
810 sem_wait(&pause_sem
);
813 void resume_display()
817 sem_post(&pause_sem
);
820 void *handle_keyboard(void *p
)
823 while((ch
= getch())) {
825 /* Move the cursor and scroll */
827 if (perf_panel_visible
) {
828 if (perf_line_selected
< g_hash_table_size(data
->perf_list
) - 1)
829 perf_line_selected
++;
830 update_perf_panel(perf_line_selected
, 0, 0);
832 if (selected_line
< (max_center_lines
- 1) &&
833 selected_line
< max_elements
- 1) {
836 } else if (selected_in_list
< (max_elements
- 1)
837 && (list_offset
< (max_elements
- max_center_lines
))) {
841 update_current_view();
845 if ((selected_line
+ 10 < max_center_lines
- 1) &&
846 ((selected_line
+ 10) < max_elements
- 1)) {
848 selected_in_list
+= 10;
849 } else if (max_elements
> max_center_lines
) {
850 selected_line
= max_center_lines
- 1;
851 if (selected_in_list
+ 10 < max_elements
- 1) {
852 selected_in_list
+= 10;
853 list_offset
+= (selected_in_list
- max_center_lines
+ 1);
855 } else if (selected_line
+ 10 > max_elements
) {
856 selected_line
= max_elements
- 1;
858 update_current_view();
861 if (perf_panel_visible
) {
862 if (perf_line_selected
> 0)
863 perf_line_selected
--;
864 update_perf_panel(perf_line_selected
, 0, 0);
866 if (selected_line
> 0) {
869 } else if (selected_in_list
> 0 && list_offset
> 0) {
873 update_current_view();
877 if (selected_line
- 10 > 0)
881 update_current_view();
884 /* Navigate the history with arrows */
886 if (currently_displayed_index
> 0) {
887 currently_displayed_index
--;
888 print_log("Going back in time");
890 print_log("Cannot rewind, last data is already displayed");
892 data
= g_ptr_array_index(copies
, currently_displayed_index
);
893 max_elements
= data
->process_table
->len
;
895 /* we force to pause the display when moving in time */
896 if (toggle_pause
< 0)
899 update_current_view();
903 if (currently_displayed_index
< last_display_index
) {
904 currently_displayed_index
++;
905 print_log("Going forward in time");
906 data
= g_ptr_array_index(copies
, currently_displayed_index
);
907 max_elements
= data
->process_table
->len
;
908 update_current_view();
911 print_log("Manually moving forward");
913 /* we force to resume the refresh when moving forward */
914 if (toggle_pause
> 0)
920 if (perf_panel_visible
)
921 update_perf_panel(perf_line_selected
, 1, 0);
924 if (perf_panel_visible
)
925 update_perf_panel(perf_line_selected
, 0, 1);
928 case 13: /* FIXME : KEY_ENTER ?? */
929 if (current_view
== cpu
) {
930 current_view
= process_details
;
932 update_current_view();
938 update_current_view();
942 update_current_view();
947 update_current_view();
950 current_view
= fileio
;
952 update_current_view();
955 current_view
= netio
;
957 update_current_view();
960 current_view
= iostream
;
962 update_current_view();
969 toggle_threads
*= -1;
970 update_current_view();
973 if (toggle_pause
< 0) {
984 update_current_view();
994 sem_init(&update_display_sem
, 0, 1);
997 header
= create_window(7, COLS
- 1, 0, 0);
998 center
= create_window(LINES
- 7 - 7, COLS
- 1, 7, 0);
999 status
= create_window(MAX_LOG_LINES
+ 2, COLS
- 1, LINES
- 7, 0);
1000 footer
= create_window(1, COLS
- 1, LINES
- 1, 0);
1002 print_log("Starting display");
1004 main_panel
= new_panel(center
);
1012 pthread_create(&keyboard_thread
, NULL
, handle_keyboard
, (void *)NULL
);