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
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26 #include <semaphore.h>
28 #include "cursesdisplay.h"
29 #include "lttngtoptypes.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", log_lines
[i
]);
219 void print_key(WINDOW
*win
, char *key
, char *desc
, int toggle
)
226 wattron(win
, COLOR_PAIR(pair
));
227 wprintw(footer
, "%s", key
);
228 wattroff(win
, COLOR_PAIR(pair
));
229 wprintw(footer
, ":%s", desc
);
234 sem_wait(&update_display_sem
);
237 print_key(footer
, "F2", "CPUtop ", current_view
== cpu
);
238 print_key(footer
, "F3", "PerfTop ", current_view
== perf
);
239 print_key(footer
, "F6", "IOTop ", current_view
== iostream
);
240 print_key(footer
, "Enter", "Details ", current_view
== process_details
);
241 print_key(footer
, "q", "Quit | ", 0);
242 print_key(footer
, "P", "Perf Pref ", 0);
243 print_key(footer
, "p", "Pause ", toggle_pause
);
246 sem_post(&update_display_sem
);
253 set_window_title(header
, "Statistics for interval [gathering data...[");
254 wattron(header
, A_BOLD
);
255 mvwprintw(header
, 1, 4, "CPUs");
256 mvwprintw(header
, 2, 4, "Processes");
257 mvwprintw(header
, 3, 4, "Threads");
258 mvwprintw(header
, 4, 4, "Files");
259 mvwprintw(header
, 5, 4, "Network");
260 mvwprintw(header
, 6, 4, "IO");
261 wattroff(header
, A_BOLD
);
269 set_window_title(header
, "Statistics for interval ");
270 wattron(header
, A_BOLD
);
272 wprintw(header, "[%lu.%lu, %lu.%lu[",
273 data->start.tv_sec, data->start.tv_nsec,
274 data->end.tv_sec, data->end.tv_nsec);
276 wprintw(header
, "[%lu, %lu[",
279 mvwprintw(header
, 1, 4, "CPUs");
280 wattroff(header
, A_BOLD
);
281 wprintw(header
, "\t%d\t(max/cpu : %0.2f%)", data
->cpu_table
->len
,
282 100.0/data
->cpu_table
->len
);
283 print_headers(2, "Processes", data
->nbproc
, data
->nbnewproc
,
284 -1*(data
->nbdeadproc
));
285 print_headers(3, "Threads", data
->nbthreads
, data
->nbnewthreads
,
286 -1*(data
->nbdeadthreads
));
287 print_headers(4, "Files", data
->nbfiles
, data
->nbnewfiles
,
288 -1*(data
->nbclosedfiles
));
289 mvwprintw(header
, 4, 43, "N/A kbytes/sec");
290 print_headers(5, "Network", 114, 0, 0);
291 mvwprintw(header
, 5, 43, "N/A Mbytes/sec");
295 gint
sort_by_cpu_desc(gconstpointer p1
, gconstpointer p2
)
297 struct processtop
*n1
= *(struct processtop
**)p1
;
298 struct processtop
*n2
= *(struct processtop
**)p2
;
299 unsigned long totaln1
= n1
->totalcpunsec
;
300 unsigned long totaln2
= n2
->totalcpunsec
;
302 if (totaln1
< totaln2
)
304 if (totaln1
== totaln2
)
309 gint
sort_by_cpu_group_by_threads_desc(gconstpointer p1
, gconstpointer p2
)
311 struct processtop
*n1
= *(struct processtop
**)p1
;
312 struct processtop
*n2
= *(struct processtop
**)p2
;
313 unsigned long totaln1
= n1
->threadstotalcpunsec
;
314 unsigned long totaln2
= n2
->threadstotalcpunsec
;
316 if (totaln1
< totaln2
)
318 if (totaln1
== totaln2
)
323 void update_cputop_display()
326 int header_offset
= 2;
327 struct processtop
*tmp
;
328 unsigned long elapsed
;
330 int nblinedisplayed
= 0;
331 int current_line
= 0;
333 elapsed
= data
->end
- data
->start
;
334 maxcputime
= elapsed
* data
->cpu_table
->len
/ 100.0;
336 g_ptr_array_sort(data
->process_table
, sort_by_cpu_desc
);
338 set_window_title(center
, "CPU Top");
339 wattron(center
, A_BOLD
);
340 mvwprintw(center
, 1, 1, "CPU(%)");
341 mvwprintw(center
, 1, 12, "TGID");
342 mvwprintw(center
, 1, 22, "PID");
343 mvwprintw(center
, 1, 32, "NAME");
344 wattroff(center
, A_BOLD
);
346 max_center_lines
= LINES
- 7 - 7 - 1 - header_offset
;
348 /* iterate the process (thread) list */
349 for (i
= list_offset
; i
< data
->process_table
->len
&&
350 nblinedisplayed
< max_center_lines
; i
++) {
351 tmp
= g_ptr_array_index(data
->process_table
, i
);
353 if (current_line
== selected_line
) {
354 selected_process
= tmp
;
355 selected_tid
= tmp
->tid
;
356 selected_comm
= tmp
->comm
;
357 wattron(center
, COLOR_PAIR(5));
358 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
361 mvwprintw(center
, current_line
+ header_offset
, 1, "%1.2f",
362 tmp
->totalcpunsec
/ maxcputime
);
364 mvwprintw(center
, current_line
+ header_offset
, 12, "%d", tmp
->pid
);
366 mvwprintw(center
, current_line
+ header_offset
, 22, "%d", tmp
->tid
);
368 mvwprintw(center
, current_line
+ header_offset
, 32, "%s", tmp
->comm
);
369 wattroff(center
, COLOR_PAIR(5));
375 gint
sort_perf(gconstpointer p1
, gconstpointer p2
, gpointer key
)
377 struct processtop
*n1
= *(struct processtop
**) p1
;
378 struct processtop
*n2
= *(struct processtop
**) p2
;
380 struct perfcounter
*tmp1
, *tmp2
;
381 unsigned long totaln2
= 0;
382 unsigned long totaln1
= 0;
387 tmp1
= g_hash_table_lookup(n1
->perf
, key
);
391 totaln1
= tmp1
->count
;
393 tmp2
= g_hash_table_lookup(n2
->perf
, key
);
397 totaln2
= tmp2
->count
;
399 if (totaln1
< totaln2
)
401 if (totaln1
== totaln2
) {
404 if (totaln1
< totaln2
)
411 void print_key_title(char *key
, int line
)
413 wattron(center
, A_BOLD
);
414 mvwprintw(center
, line
, 1, "%s\t", key
);
415 wattroff(center
, A_BOLD
);
418 void update_process_details()
420 unsigned long elapsed
;
422 struct processtop
*tmp
= find_process_tid(data
, selected_tid
, selected_comm
);
424 set_window_title(center
, "Process details");
427 elapsed
= data
->end
- data
->start
;
428 maxcputime
= elapsed
* data
->cpu_table
->len
/ 100.0;
430 print_key_title("Name", 1);
431 wprintw(center
, "%s", selected_comm
);
432 print_key_title("TID", 2);
433 wprintw(center
, "%d", selected_tid
);
435 print_key_title("Does not exit at this time", 3);
439 print_key_title("PID", 3);
440 wprintw(center
, "%d", tmp
->pid
);
441 print_key_title("PPID", 4);
442 wprintw(center
, "%d", tmp
->ppid
);
443 print_key_title("CPU", 5);
444 wprintw(center
, "%1.2f %%", tmp
->totalcpunsec
/maxcputime
);
450 int nblinedisplayed
= 0;
451 int current_line
= 0;
452 struct processtop
*tmp
;
453 int header_offset
= 2;
455 struct perfcounter
*perfn1
, *perfn2
;
456 char *perf_key
= NULL
;
461 set_window_title(center
, "Perf Top");
462 wattron(center
, A_BOLD
);
463 mvwprintw(center
, 1, 1, "PID");
464 mvwprintw(center
, 1, 11, "TID");
465 mvwprintw(center
, 1, 22, "NAME");
468 g_hash_table_iter_init(&iter
, data
->perf_list
);
469 while (g_hash_table_iter_next (&iter
, &key
, (gpointer
) &perfn1
)) {
470 if (perfn1
->visible
) {
471 /* + 6 to strip the "_perf_" prefix */
472 mvwprintw(center
, 1, perf_row
, "%s",
477 perf_key
= (char *) key
;
481 wattroff(center
, A_BOLD
);
483 g_ptr_array_sort_with_data(data
->process_table
, sort_perf
, perf_key
);
485 for (i
= 0; i
< data
->process_table
->len
&&
486 nblinedisplayed
< max_center_lines
; i
++) {
487 tmp
= g_ptr_array_index(data
->process_table
, i
);
489 if (current_line
== selected_line
) {
490 selected_process
= tmp
;
491 wattron(center
, COLOR_PAIR(5));
492 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
495 mvwprintw(center
, current_line
+ header_offset
, 1, "%d", tmp
->pid
);
496 mvwprintw(center
, current_line
+ header_offset
, 11, "%d", tmp
->tid
);
497 mvwprintw(center
, current_line
+ header_offset
, 22, "%s", tmp
->comm
);
499 g_hash_table_iter_init(&iter
, data
->perf_list
);
502 while (g_hash_table_iter_next (&iter
, &key
, (gpointer
) &perfn1
)) {
503 if (perfn1
->visible
) {
504 perfn2
= g_hash_table_lookup(tmp
->perf
, (char *) key
);
506 value
= perfn2
->count
;
509 mvwprintw(center
, current_line
+ header_offset
, perf_row
, "%d", value
);
514 wattroff(center
, COLOR_PAIR(5));
525 set_window_title(center
, "IO Top");
526 wattron(center
, A_BOLD
);
527 mvwprintw(center
, 1, 10, "READ");
528 mvwprintw(center
, 2, 1, "bytes");
529 mvwprintw(center
, 2, 15, "bytes/sec");
531 mvwprintw(center
, 1, 39, "WRITE");
532 mvwprintw(center
, 2, 33, "bytes");
533 mvwprintw(center
, 2, 45, "bytes/sec");
535 if (toggle_threads
> 0) {
536 mvwprintw(center
, 1, 60, "TGID");
537 mvwprintw(center
, 1, 70, "PID");
540 mvwprintw(center
, 1, 60, "PID(TGID)");
543 mvwprintw(center
, 1, 72 + offset
, "NAME");
544 wattroff(center
, A_BOLD
);
546 for (i
= 3; i
< LINES
- 3 - 8 - 1; i
++) {
547 mvwprintw(center
, i
, 1, "%d", i
*1000);
548 mvwprintw(center
, i
, 15, "%dk", i
);
549 mvwprintw(center
, i
, 28, "| %d", i
*2000);
550 mvwprintw(center
, i
, 45, "%dk", i
*2);
551 if (toggle_threads
> 0) {
552 mvwprintw(center
, i
, 57, "| %d", i
);
553 mvwprintw(center
, i
, 70, "%d", i
);
555 mvwprintw(center
, i
, 57, "| %d", i
);
557 mvwprintw(center
, i
, 72 + offset
, "process_%d", i
);
561 gint
sort_by_ret_desc(gconstpointer p1
, gconstpointer p2
)
563 struct processtop
*n1
= *(struct processtop
**)p1
;
564 struct processtop
*n2
= *(struct processtop
**)p2
;
565 unsigned long totaln1
= n1
->iostream
->ret_total
;
566 unsigned long totaln2
= n2
->iostream
->ret_total
;
568 if (totaln1
< totaln2
)
570 if (totaln1
== totaln2
)
575 void update_iostream()
578 int header_offset
= 2;
579 struct processtop
*tmp
;
580 int nblinedisplayed
= 0;
581 int current_line
= 0;
583 set_window_title(center
, "IO Top");
584 wattron(center
, A_BOLD
);
585 mvwprintw(center
, 1, 1, "READ (B/s)");
586 mvwprintw(center
, 1, 20, "WRITE (B/s)");
588 mvwprintw(center
, 1, 40, "TOTAL STREAM");
590 mvwprintw(center
, 1, 60, "TGID");
591 mvwprintw(center
, 1, 80, "PID");
593 mvwprintw(center
, 1, 92, "NAME");
594 wattroff(center
, A_BOLD
);
596 g_ptr_array_sort(data
->process_table
, sort_by_ret_desc
);
598 for (i
= list_offset
; i
< data
->process_table
->len
&&
599 nblinedisplayed
< max_center_lines
; i
++) {
600 tmp
= g_ptr_array_index(data
->process_table
, i
);
602 if (current_line
== selected_line
) {
603 selected_process
= tmp
;
604 selected_tid
= tmp
->tid
;
605 selected_comm
= tmp
->comm
;
606 wattron(center
, COLOR_PAIR(5));
607 mvwhline(center
, current_line
+ header_offset
, 1, ' ', COLS
-3);
609 /* READ (bytes/sec) */
610 mvwprintw(center
, current_line
+ header_offset
, 1, "%lu",
611 tmp
->iostream
->ret_read
);
613 /* WRITE (bytes/sec) */
614 mvwprintw(center
, current_line
+ header_offset
, 20, "%lu",
615 tmp
->iostream
->ret_write
);
618 if(tmp
->iostream
->ret_total
>= 1000000)
619 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu MB",
620 tmp
->iostream
->ret_total
/1000000);
621 else if(tmp
->iostream
->ret_total
>=1000)
622 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu KB",
623 tmp
->iostream
->ret_total
/1000);
625 mvwprintw(center
, current_line
+ header_offset
, 40, "%lu B",
626 tmp
->iostream
->ret_total
);
628 mvwprintw(center
, current_line
+ header_offset
, 60, "%d", tmp
->pid
);
630 mvwprintw(center
, current_line
+ header_offset
, 80, "%d", tmp
->tid
);
632 mvwprintw(center
, current_line
+ header_offset
, 92, "%s", tmp
->comm
);
633 wattroff(center
, COLOR_PAIR(5));
639 void update_current_view()
641 sem_wait(&update_display_sem
);
648 switch (current_view
) {
650 update_cputop_display();
655 case process_details
:
656 update_process_details();
665 update_cputop_display();
672 sem_post(&update_display_sem
);
675 void setup_perf_panel()
680 if (perf_panel_window
) {
681 del_panel(perf_panel
);
682 delwin(perf_panel_window
);
684 size
= g_hash_table_size(data
->perf_list
);
685 perf_panel_window
= create_window(size
+ 2, 30, 10, 10);
686 perf_panel
= new_panel(perf_panel_window
);
687 perf_panel_visible
= 0;
688 hide_panel(perf_panel
);
691 void update_perf_panel(int line_selected
, int toggle_view
, int toggle_sort
)
694 struct perfcounter
*perf
;
700 werase(perf_panel_window
);
701 box(perf_panel_window
, 0 , 0);
702 set_window_title(perf_panel_window
, "Perf Preferences ");
703 wattron(perf_panel_window
, A_BOLD
);
704 mvwprintw(perf_panel_window
, g_hash_table_size(data
->perf_list
) + 1, 1, " 's' to sort");
705 wattroff(perf_panel_window
, A_BOLD
);
707 if (toggle_sort
== 1) {
709 perflist
= g_list_first(g_hash_table_get_keys(data
->perf_list
));
711 perf
= g_hash_table_lookup(data
->perf_list
, perflist
->data
);
712 if (i
!= line_selected
)
717 perflist
= g_list_next(perflist
);
719 update_current_view();
723 perflist
= g_list_first(g_hash_table_get_keys(data
->perf_list
));
725 perf
= g_hash_table_lookup(data
->perf_list
, perflist
->data
);
726 if (i
== line_selected
&& toggle_view
== 1) {
727 perf
->visible
= perf
->visible
== 1 ? 0:1;
728 update_current_view();
730 if (i
== line_selected
) {
731 wattron(perf_panel_window
, COLOR_PAIR(5));
732 mvwhline(perf_panel_window
, i
+ 1, 1, ' ', 30 - 2);
735 wattron(perf_panel_window
, A_BOLD
);
736 mvwprintw(perf_panel_window
, i
+ 1, 1, "[%c] %s",
737 perf
->visible
== 1 ? 'x' : ' ',
738 (char *) perflist
->data
+ 6);
739 wattroff(perf_panel_window
, A_BOLD
);
740 wattroff(perf_panel_window
, COLOR_PAIR(5));
742 perflist
= g_list_next(perflist
);
749 void toggle_perf_panel(void)
751 if (perf_panel_visible
) {
752 hide_panel(perf_panel
);
753 perf_panel_visible
= 0;
756 update_perf_panel(perf_line_selected
, 0, 0);
757 show_panel(perf_panel
);
758 perf_panel_visible
= 1;
764 void display(unsigned int index
)
766 last_display_index
= index
;
767 currently_displayed_index
= index
;
768 data
= g_ptr_array_index(copies
, index
);
771 max_elements
= data
->process_table
->len
;
772 update_current_view();
782 sem_wait(&pause_sem
);
785 void resume_display()
789 sem_post(&pause_sem
);
792 void *handle_keyboard(void *p
)
795 while((ch
= getch())) {
797 /* Move the cursor and scroll */
799 if (perf_panel_visible
) {
800 if (perf_line_selected
< g_hash_table_size(data
->perf_list
) - 1)
801 perf_line_selected
++;
802 update_perf_panel(perf_line_selected
, 0, 0);
804 if (selected_line
< (max_center_lines
- 1) &&
805 selected_line
< max_elements
- 1) {
808 } else if (selected_in_list
< (max_elements
- 1)
809 && (list_offset
< (max_elements
- max_center_lines
))) {
813 update_current_view();
817 if ((selected_line
+ 10 < max_center_lines
- 1) &&
818 ((selected_line
+ 10) < max_elements
- 1)) {
820 selected_in_list
+= 10;
821 } else if (max_elements
> max_center_lines
) {
822 selected_line
= max_center_lines
- 1;
823 if (selected_in_list
+ 10 < max_elements
- 1) {
824 selected_in_list
+= 10;
825 list_offset
+= (selected_in_list
- max_center_lines
+ 1);
827 } else if (selected_line
+ 10 > max_elements
) {
828 selected_line
= max_elements
- 1;
830 update_current_view();
833 if (perf_panel_visible
) {
834 if (perf_line_selected
> 0)
835 perf_line_selected
--;
836 update_perf_panel(perf_line_selected
, 0, 0);
838 if (selected_line
> 0) {
841 } else if (selected_in_list
> 0 && list_offset
> 0) {
845 update_current_view();
849 if (selected_line
- 10 > 0)
853 update_current_view();
856 /* Navigate the history with arrows */
858 if (currently_displayed_index
> 0) {
859 currently_displayed_index
--;
860 print_log("Going back in time");
862 print_log("Cannot rewind, last data is already displayed");
864 data
= g_ptr_array_index(copies
, currently_displayed_index
);
865 max_elements
= data
->process_table
->len
;
867 /* we force to pause the display when moving in time */
868 if (toggle_pause
< 0)
871 update_current_view();
875 if (currently_displayed_index
< last_display_index
) {
876 currently_displayed_index
++;
877 print_log("Going forward in time");
878 data
= g_ptr_array_index(copies
, currently_displayed_index
);
879 max_elements
= data
->process_table
->len
;
880 update_current_view();
883 print_log("Manually moving forward");
885 /* we force to resume the refresh when moving forward */
886 if (toggle_pause
> 0)
892 if (perf_panel_visible
)
893 update_perf_panel(perf_line_selected
, 1, 0);
896 if (perf_panel_visible
)
897 update_perf_panel(perf_line_selected
, 0, 1);
900 case 13: /* FIXME : KEY_ENTER ?? */
901 if (current_view
== cpu
) {
902 current_view
= process_details
;
904 update_current_view();
910 update_current_view();
914 update_current_view();
919 update_current_view();
922 current_view
= fileio
;
924 update_current_view();
927 current_view
= netio
;
929 update_current_view();
932 current_view
= iostream
;
934 update_current_view();
941 toggle_threads
*= -1;
942 update_current_view();
945 if (toggle_pause
< 0) {
956 * commented because it makes the list refresh in different order
957 * if we sort and there are equal values
959 update_current_view();
970 sem_init(&update_display_sem
, 0, 1);
973 header
= create_window(7, COLS
- 1, 0, 0);
974 center
= create_window(LINES
- 7 - 7, COLS
- 1, 7, 0);
975 status
= create_window(MAX_LOG_LINES
+ 2, COLS
- 1, LINES
- 7, 0);
976 footer
= create_window(1, COLS
- 1, LINES
- 1, 0);
978 print_log("Starting display");
980 main_panel
= new_panel(center
);
988 pthread_create(&keyboard_thread
, NULL
, handle_keyboard
, (void *)NULL
);