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, "%d", 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
, "F4", "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, "Threads");
258 mvwprintw(header
, 3, 4, "FDs");
259 wattroff(header
, A_BOLD
);
263 struct tm
format_timestamp(uint64_t timestamp
)
266 uint64_t ts_sec
= 0, ts_nsec
;
270 ts_sec
+= ts_nsec
/ NSEC_PER_SEC
;
271 ts_nsec
= ts_nsec
% NSEC_PER_SEC
;
273 time_s
= (time_t) ts_sec
;
275 localtime_r(&time_s
, &tm
);
282 struct tm start
, end
;
283 uint64_t ts_nsec_start
, ts_nsec_end
;
285 ts_nsec_start
= data
->start
% NSEC_PER_SEC
;
286 start
= format_timestamp(data
->start
);
288 ts_nsec_end
= data
->end
% NSEC_PER_SEC
;
289 end
= format_timestamp(data
->end
);
293 set_window_title(header
, "Statistics for interval ");
294 wattron(header
, A_BOLD
);
296 wprintw(header
, "[%02d:%02d:%02d.%09" PRIu64
", %02d:%02d:%02d.%09" PRIu64
"[",
297 start
.tm_hour
, start
.tm_min
, start
.tm_sec
, ts_nsec_start
,
298 end
.tm_hour
, end
.tm_min
, end
.tm_sec
, ts_nsec_end
);
299 mvwprintw(header
, 1, 4, "CPUs");
300 wattroff(header
, A_BOLD
);
301 wprintw(header
, "\t%d\t(max/cpu : %0.2f%)", data
->cpu_table
->len
,
302 100.0/data
->cpu_table
->len
);
303 print_headers(2, "Threads", data
->nbthreads
, data
->nbnewthreads
,
304 -1*(data
->nbdeadthreads
));
305 print_headers(3, "FDs", data
->nbfiles
, data
->nbnewfiles
,
306 -1*(data
->nbclosedfiles
));
307 mvwprintw(header
, 3, 43, "N/A kbytes/sec");
311 gint
sort_by_cpu_desc(gconstpointer p1
, gconstpointer p2
)
313 struct processtop
*n1
= *(struct processtop
**)p1
;
314 struct processtop
*n2
= *(struct processtop
**)p2
;
315 unsigned long totaln1
= n1
->totalcpunsec
;
316 unsigned long totaln2
= n2
->totalcpunsec
;
318 if (totaln1
< totaln2
)
320 if (totaln1
== totaln2
)
325 gint
sort_by_cpu_group_by_threads_desc(gconstpointer p1
, gconstpointer p2
)
327 struct processtop
*n1
= *(struct processtop
**)p1
;
328 struct processtop
*n2
= *(struct processtop
**)p2
;
329 unsigned long totaln1
= n1
->threadstotalcpunsec
;
330 unsigned long totaln2
= n2
->threadstotalcpunsec
;
332 if (totaln1
< totaln2
)
334 if (totaln1
== totaln2
)
339 void update_cputop_display()
342 int header_offset
= 2;
343 struct processtop
*tmp
;
344 unsigned long elapsed
;
346 int nblinedisplayed
= 0;
347 int current_line
= 0;
349 elapsed
= data
->end
- data
->start
;
350 maxcputime
= elapsed
* data
->cpu_table
->len
/ 100.0;
352 g_ptr_array_sort(data
->process_table
, sort_by_cpu_desc
);
354 set_window_title(center
, "CPU Top");
355 wattron(center
, A_BOLD
);
356 mvwprintw(center
, 1, 1, "CPU(%)");
357 mvwprintw(center
, 1, 12, "TGID");
358 mvwprintw(center
, 1, 22, "PID");
359 mvwprintw(center
, 1, 32, "NAME");
360 wattroff(center
, A_BOLD
);
362 max_center_lines
= LINES
- 5 - 7 - 1 - header_offset
;
364 /* iterate the process (thread) list */
365 for (i
= list_offset
; i
< data
->process_table
->len
&&
366 nblinedisplayed
< max_center_lines
; i
++) {
367 tmp
= g_ptr_array_index(data
->process_table
, i
);
369 if (current_line
== selected_line
) {
370 selected_process
= tmp
;
371 selected_tid
= tmp
->tid
;
372 selected_comm
= tmp
->comm
;
373 wattron(center
, COLOR_PAIR(5));
374 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
377 mvwprintw(center
, current_line
+ header_offset
, 1, "%1.2f",
378 tmp
->totalcpunsec
/ maxcputime
);
380 mvwprintw(center
, current_line
+ header_offset
, 12, "%d", tmp
->pid
);
382 mvwprintw(center
, current_line
+ header_offset
, 22, "%d", tmp
->tid
);
384 mvwprintw(center
, current_line
+ header_offset
, 32, "%s", tmp
->comm
);
385 wattroff(center
, COLOR_PAIR(5));
391 gint
sort_perf(gconstpointer p1
, gconstpointer p2
, gpointer key
)
393 struct processtop
*n1
= *(struct processtop
**) p1
;
394 struct processtop
*n2
= *(struct processtop
**) p2
;
396 struct perfcounter
*tmp1
, *tmp2
;
397 unsigned long totaln2
= 0;
398 unsigned long totaln1
= 0;
403 tmp1
= g_hash_table_lookup(n1
->perf
, key
);
407 totaln1
= tmp1
->count
;
409 tmp2
= g_hash_table_lookup(n2
->perf
, key
);
413 totaln2
= tmp2
->count
;
415 if (totaln1
< totaln2
)
417 if (totaln1
== totaln2
) {
420 if (totaln1
< totaln2
)
427 void print_key_title(char *key
, int line
)
429 wattron(center
, A_BOLD
);
430 mvwprintw(center
, line
, 1, "%s\t", key
);
431 wattroff(center
, A_BOLD
);
434 void update_process_details()
436 unsigned long elapsed
;
438 struct processtop
*tmp
= find_process_tid(data
, selected_tid
, selected_comm
);
439 struct files
*file_tmp
;
442 set_window_title(center
, "Process details");
445 elapsed
= data
->end
- data
->start
;
446 maxcputime
= elapsed
* data
->cpu_table
->len
/ 100.0;
448 print_key_title("Name", 1);
449 wprintw(center
, "%s", selected_comm
);
450 print_key_title("TID", 2);
451 wprintw(center
, "%d", selected_tid
);
453 print_key_title("Does not exit at this time", 3);
457 print_key_title("PID", 3);
458 wprintw(center
, "%d", tmp
->pid
);
459 print_key_title("PPID", 4);
460 wprintw(center
, "%d", tmp
->ppid
);
461 print_key_title("CPU", 5);
462 wprintw(center
, "%1.2f %%", tmp
->totalcpunsec
/maxcputime
);
464 print_key_title("READ B/s", 6);
465 wprintw(center
, "%d", tmp
->fileread
);
467 print_key_title("WRITE B/s", 7);
468 wprintw(center
, "%d", tmp
->filewrite
);
470 wattron(center
, A_BOLD
);
471 mvwprintw(center
, 8, 1, "FD");
472 mvwprintw(center
, 8, 12, "READ");
473 mvwprintw(center
, 8, 22, "WRITE");
474 mvwprintw(center
, 8, 32, "FILENAME");
475 wattroff(center
, A_BOLD
);
477 for (i
= 0; i
< tmp
->process_files_table
->len
; i
++) {
478 file_tmp
= get_file(tmp
, i
);
479 if (file_tmp
!= NULL
) {
480 mvwprintw(center
, 9 + j
, 1, "%d", i
);
481 mvwprintw(center
, 9 + j
, 12, "%d", file_tmp
->read
);
482 mvwprintw(center
, 9 + j
, 22, "%d", file_tmp
->write
);
483 mvwprintw(center
, 9 + j
, 32, "%s", file_tmp
->name
);
492 int nblinedisplayed
= 0;
493 int current_line
= 0;
494 struct processtop
*tmp
;
495 int header_offset
= 2;
497 struct perfcounter
*perfn1
, *perfn2
;
498 char *perf_key
= NULL
;
503 set_window_title(center
, "Perf Top");
504 wattron(center
, A_BOLD
);
505 mvwprintw(center
, 1, 1, "PID");
506 mvwprintw(center
, 1, 11, "TID");
507 mvwprintw(center
, 1, 22, "NAME");
510 g_hash_table_iter_init(&iter
, data
->perf_list
);
511 while (g_hash_table_iter_next (&iter
, &key
, (gpointer
) &perfn1
)) {
512 if (perfn1
->visible
) {
513 /* + 5 to strip the "perf_" prefix */
514 mvwprintw(center
, 1, perf_row
, "%s",
519 perf_key
= (char *) key
;
523 wattroff(center
, A_BOLD
);
525 g_ptr_array_sort_with_data(data
->process_table
, sort_perf
, perf_key
);
527 for (i
= 0; i
< data
->process_table
->len
&&
528 nblinedisplayed
< max_center_lines
; i
++) {
529 tmp
= g_ptr_array_index(data
->process_table
, i
);
531 if (current_line
== selected_line
) {
532 selected_process
= tmp
;
533 wattron(center
, COLOR_PAIR(5));
534 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
537 mvwprintw(center
, current_line
+ header_offset
, 1, "%d", tmp
->pid
);
538 mvwprintw(center
, current_line
+ header_offset
, 11, "%d", tmp
->tid
);
539 mvwprintw(center
, current_line
+ header_offset
, 22, "%s", tmp
->comm
);
541 g_hash_table_iter_init(&iter
, data
->perf_list
);
544 while (g_hash_table_iter_next (&iter
, &key
, (gpointer
) &perfn1
)) {
545 if (perfn1
->visible
) {
546 perfn2
= g_hash_table_lookup(tmp
->perf
, (char *) key
);
548 value
= perfn2
->count
;
551 mvwprintw(center
, current_line
+ header_offset
,
552 perf_row
, "%d", value
);
557 wattroff(center
, COLOR_PAIR(5));
563 gint
sort_by_ret_desc(gconstpointer p1
, gconstpointer p2
)
565 struct processtop
*n1
= *(struct processtop
**)p1
;
566 struct processtop
*n2
= *(struct processtop
**)p2
;
568 unsigned long totaln1
= n1
->totalfileread
+ n1
->totalfilewrite
;
569 unsigned long totaln2
= n2
->totalfileread
+ n2
->totalfilewrite
;
571 if (totaln1
< totaln2
)
573 if (totaln1
== totaln2
)
578 void update_iostream()
581 int header_offset
= 2;
582 struct processtop
*tmp
;
583 int nblinedisplayed
= 0;
584 int current_line
= 0;
587 set_window_title(center
, "IO Top");
588 wattron(center
, A_BOLD
);
589 mvwprintw(center
, 1, 1, "READ (B/s)");
590 mvwprintw(center
, 1, 20, "WRITE (B/s)");
592 mvwprintw(center
, 1, 40, "TOTAL STREAM");
594 mvwprintw(center
, 1, 60, "TGID");
595 mvwprintw(center
, 1, 80, "PID");
597 mvwprintw(center
, 1, 92, "NAME");
598 wattroff(center
, A_BOLD
);
600 g_ptr_array_sort(data
->process_table
, sort_by_ret_desc
);
602 for (i
= list_offset
; i
< data
->process_table
->len
&&
603 nblinedisplayed
< max_center_lines
; i
++) {
604 tmp
= g_ptr_array_index(data
->process_table
, i
);
606 if (current_line
== selected_line
) {
607 selected_process
= tmp
;
608 selected_tid
= tmp
->tid
;
609 selected_comm
= tmp
->comm
;
610 wattron(center
, COLOR_PAIR(5));
611 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
614 /* READ (bytes/sec) */
615 mvwprintw(center
, current_line
+ header_offset
, 1, "%lu",
618 /* WRITE (bytes/sec) */
619 mvwprintw(center
, current_line
+ header_offset
, 20, "%lu",
623 total
= tmp
->totalfileread
+ tmp
->totalfilewrite
;
625 if (total
>= 1000000)
626 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu MB",
628 else if (total
>= 1000)
629 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu KB",
632 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu B",
636 mvwprintw(center
, current_line
+ header_offset
, 60, "%d", tmp
->pid
);
638 mvwprintw(center
, current_line
+ header_offset
, 80, "%d", tmp
->tid
);
640 mvwprintw(center
, current_line
+ header_offset
, 92, "%s", tmp
->comm
);
641 wattroff(center
, COLOR_PAIR(5));
647 void update_current_view()
649 sem_wait(&update_display_sem
);
656 switch (current_view
) {
658 update_cputop_display();
663 case process_details
:
664 update_process_details();
670 update_cputop_display();
677 sem_post(&update_display_sem
);
680 void setup_perf_panel()
685 if (perf_panel_window
) {
686 del_panel(perf_panel
);
687 delwin(perf_panel_window
);
689 size
= g_hash_table_size(data
->perf_list
);
690 perf_panel_window
= create_window(size
+ 2, 30, 10, 10);
691 perf_panel
= new_panel(perf_panel_window
);
692 perf_panel_visible
= 0;
693 hide_panel(perf_panel
);
696 void update_perf_panel(int line_selected
, int toggle_view
, int toggle_sort
)
699 struct perfcounter
*perf
;
705 werase(perf_panel_window
);
706 box(perf_panel_window
, 0 , 0);
707 set_window_title(perf_panel_window
, "Perf Preferences ");
708 wattron(perf_panel_window
, A_BOLD
);
709 mvwprintw(perf_panel_window
, g_hash_table_size(data
->perf_list
) + 1, 1,
711 wattroff(perf_panel_window
, A_BOLD
);
713 if (toggle_sort
== 1) {
715 perflist
= g_list_first(g_hash_table_get_keys(data
->perf_list
));
717 perf
= g_hash_table_lookup(data
->perf_list
, perflist
->data
);
718 if (i
!= line_selected
)
723 perflist
= g_list_next(perflist
);
725 update_current_view();
729 perflist
= g_list_first(g_hash_table_get_keys(data
->perf_list
));
731 perf
= g_hash_table_lookup(data
->perf_list
, perflist
->data
);
732 if (i
== line_selected
&& toggle_view
== 1) {
733 perf
->visible
= perf
->visible
== 1 ? 0:1;
734 update_current_view();
736 if (i
== line_selected
) {
737 wattron(perf_panel_window
, COLOR_PAIR(5));
738 mvwhline(perf_panel_window
, i
+ 1, 1, ' ', 30 - 2);
741 wattron(perf_panel_window
, A_BOLD
);
742 mvwprintw(perf_panel_window
, i
+ 1, 1, "[%c] %s",
743 perf
->visible
== 1 ? 'x' : ' ',
744 (char *) perflist
->data
+ 5);
745 wattroff(perf_panel_window
, A_BOLD
);
746 wattroff(perf_panel_window
, COLOR_PAIR(5));
748 perflist
= g_list_next(perflist
);
755 void toggle_perf_panel(void)
757 if (perf_panel_visible
) {
758 hide_panel(perf_panel
);
759 perf_panel_visible
= 0;
762 update_perf_panel(perf_line_selected
, 0, 0);
763 show_panel(perf_panel
);
764 perf_panel_visible
= 1;
770 void display(unsigned int index
)
772 last_display_index
= index
;
773 currently_displayed_index
= index
;
774 data
= g_ptr_array_index(copies
, index
);
777 max_elements
= data
->process_table
->len
;
778 update_current_view();
788 sem_wait(&pause_sem
);
791 void resume_display()
795 sem_post(&pause_sem
);
798 void *handle_keyboard(void *p
)
801 while((ch
= getch())) {
803 /* Move the cursor and scroll */
805 if (perf_panel_visible
) {
806 if (perf_line_selected
< g_hash_table_size(data
->perf_list
) - 1)
807 perf_line_selected
++;
808 update_perf_panel(perf_line_selected
, 0, 0);
810 if (selected_line
< (max_center_lines
- 1) &&
811 selected_line
< max_elements
- 1) {
814 } else if (selected_in_list
< (max_elements
- 1)
815 && (list_offset
< (max_elements
- max_center_lines
))) {
819 update_current_view();
823 if ((selected_line
+ 10 < max_center_lines
- 1) &&
824 ((selected_line
+ 10) < max_elements
- 1)) {
826 selected_in_list
+= 10;
827 } else if (max_elements
> max_center_lines
) {
828 selected_line
= max_center_lines
- 1;
829 if (selected_in_list
+ 10 < max_elements
- 1) {
830 selected_in_list
+= 10;
831 list_offset
+= (selected_in_list
- max_center_lines
+ 1);
833 } else if (selected_line
+ 10 > max_elements
) {
834 selected_line
= max_elements
- 1;
836 update_current_view();
839 if (perf_panel_visible
) {
840 if (perf_line_selected
> 0)
841 perf_line_selected
--;
842 update_perf_panel(perf_line_selected
, 0, 0);
844 if (selected_line
> 0) {
847 } else if (selected_in_list
> 0 && list_offset
> 0) {
851 update_current_view();
855 if (selected_line
- 10 > 0)
859 update_current_view();
862 /* Navigate the history with arrows */
864 if (currently_displayed_index
> 0) {
865 currently_displayed_index
--;
866 print_log("Going back in time");
868 print_log("Cannot rewind, last data is already displayed");
870 data
= g_ptr_array_index(copies
, currently_displayed_index
);
871 max_elements
= data
->process_table
->len
;
873 /* we force to pause the display when moving in time */
874 if (toggle_pause
< 0)
877 update_current_view();
881 if (currently_displayed_index
< last_display_index
) {
882 currently_displayed_index
++;
883 print_log("Going forward in time");
884 data
= g_ptr_array_index(copies
, currently_displayed_index
);
885 max_elements
= data
->process_table
->len
;
886 update_current_view();
889 print_log("Manually moving forward");
891 /* we force to resume the refresh when moving forward */
892 if (toggle_pause
> 0)
898 if (perf_panel_visible
)
899 update_perf_panel(perf_line_selected
, 1, 0);
902 if (perf_panel_visible
)
903 update_perf_panel(perf_line_selected
, 0, 1);
906 case 13: /* FIXME : KEY_ENTER ?? */
907 if (current_view
== cpu
) {
908 current_view
= process_details
;
910 update_current_view();
916 update_current_view();
920 update_current_view();
925 update_current_view();
928 current_view
= iostream
;
930 update_current_view();
937 toggle_threads
*= -1;
938 update_current_view();
941 if (toggle_pause
< 0) {
952 update_current_view();
962 sem_init(&update_display_sem
, 0, 1);
965 header
= create_window(5, COLS
- 1, 0, 0);
966 center
= create_window(LINES
- 5 - 7, COLS
- 1, 5, 0);
967 status
= create_window(MAX_LOG_LINES
+ 2, COLS
- 1, LINES
- 7, 0);
968 footer
= create_window(1, COLS
- 1, LINES
- 1, 0);
970 print_log("Starting display");
972 main_panel
= new_panel(center
);
980 pthread_create(&keyboard_thread
, NULL
, handle_keyboard
, (void *)NULL
);