X-Git-Url: https://git.lttng.org/?p=lttngtop.git;a=blobdiff_plain;f=src%2Fcursesdisplay.c;h=5ef175248e781ad11a749cfa13a6086744f94512;hp=2d79d65f99cc0ae53838f0be551641de842a1b99;hb=c8d75a13bc5c025053b0c2c14fa1a7dfdaa1b448;hpb=41ff0645d8cee0c0280edefeff7a161b96ecbf03 diff --git a/src/cursesdisplay.c b/src/cursesdisplay.c index 2d79d65..5ef1752 100644 --- a/src/cursesdisplay.c +++ b/src/cursesdisplay.c @@ -59,6 +59,7 @@ char log_lines[MAX_LINE_LENGTH * MAX_LOG_LINES + MAX_LOG_LINES]; int max_elements = 80; int toggle_threads = 1; +int toggle_virt = -1; int toggle_pause = -1; int max_center_lines; @@ -66,7 +67,7 @@ GPtrArray *selected_processes; pthread_t keyboard_thread; -struct header_view cputopview[4]; +struct header_view cputopview[6]; struct header_view iostreamtopview[3]; struct header_view fileview[3]; @@ -74,11 +75,17 @@ void reset_ncurses() { curs_set(1); endwin(); - exit(0); + quit = 1; + sem_post(&pause_sem); + sem_post(&timer); + sem_post(&goodtodisplay); + sem_post(&end_trace_sem); + sem_post(&goodtoupdate); } static void handle_sigterm(int signal) { + pthread_cancel(keyboard_thread); reset_ncurses(); } @@ -119,6 +126,7 @@ void init_screen() define_key("\033[17;2~", KEY_F(18)); } signal(SIGTERM, handle_sigterm); + signal(SIGINT, handle_sigterm); mousemask(BUTTON1_CLICKED, NULL); refresh(); } @@ -283,6 +291,7 @@ void update_footer() print_key(footer, "q", "Quit ", 0); print_key(footer, "r", "Pref ", 0); print_key(footer, "t", "Threads ", toggle_threads); + print_key(footer, "v", "Virt ", toggle_virt); print_key(footer, "p", "Pause ", toggle_pause); wrefresh(footer); @@ -302,23 +311,6 @@ void basic_header() wrefresh(header); } -struct tm format_timestamp(uint64_t timestamp) -{ - struct tm tm; - uint64_t ts_sec = 0, ts_nsec; - time_t time_s; - - ts_nsec = timestamp; - ts_sec += ts_nsec / NSEC_PER_SEC; - ts_nsec = ts_nsec % NSEC_PER_SEC; - - time_s = (time_t) ts_sec; - - localtime_r(&time_s, &tm); - - return tm; -} - static void scale_unit(uint64_t bytes, char *ret) { if (bytes >= 1000000000) @@ -537,6 +529,7 @@ void update_cputop_display() double maxcputime; int nblinedisplayed = 0; int current_line = 0; + int current_row_offset; int column; elapsed = data->end - data->start; @@ -556,7 +549,10 @@ void update_cputop_display() set_window_title(center, "CPU Top"); wattron(center, A_BOLD); column = 1; - for (i = 0; i < 4; i++) { + for (i = 0; i < 6; i++) { + if (toggle_virt < 0 && (i == 3 || i == 4)) { + continue; + } if (cputopview[i].sort) { wattron(center, A_UNDERLINE); pref_current_sort = i; @@ -573,6 +569,15 @@ void update_cputop_display() for (i = list_offset; i < data->process_table->len && nblinedisplayed < max_center_lines; i++) { tmp = g_ptr_array_index(data->process_table, i); + current_row_offset = 1; + if (!opt_tid && (opt_hostname && !lookup_hostname_list(tmp->hostname))) + continue; + if (!opt_hostname && (opt_tid && !lookup_tid_list(tmp->pid))) + continue; + if ((opt_tid && !lookup_tid_list(tmp->tid)) && + (opt_hostname && !lookup_hostname_list(tmp->hostname))) + continue; + if (tmp->pid != tmp->tid) if (toggle_threads == -1) continue; @@ -587,14 +592,31 @@ void update_cputop_display() mvwhline(center, current_line + header_offset, 1, ' ', COLS-3); } /* CPU(%) */ - mvwprintw(center, current_line + header_offset, 1, "%1.2f", + mvwprintw(center, current_line + header_offset, + current_row_offset, "%1.2f", tmp->totalcpunsec / maxcputime); + current_row_offset += 10; /* PID */ - mvwprintw(center, current_line + header_offset, 11, "%d", tmp->pid); + mvwprintw(center, current_line + header_offset, + current_row_offset, "%d", tmp->pid); + current_row_offset += 10; /* TID */ - mvwprintw(center, current_line + header_offset, 21, "%d", tmp->tid); + mvwprintw(center, current_line + header_offset, + current_row_offset, "%d", tmp->tid); + current_row_offset += 10; + if (toggle_virt > 0) { + /* VPID */ + mvwprintw(center, current_line + header_offset, + current_row_offset, "%d", tmp->vpid); + current_row_offset += 10; + /* VTID */ + mvwprintw(center, current_line + header_offset, + current_row_offset, "%d", tmp->vtid); + current_row_offset += 10; + } /* NAME */ - mvwprintw(center, current_line + header_offset, 31, "%s", tmp->comm); + mvwprintw(center, current_line + header_offset, + current_row_offset, "%s", tmp->comm); wattroff(center, COLOR_PAIR(6)); wattroff(center, COLOR_PAIR(5)); nblinedisplayed++; @@ -684,6 +706,12 @@ void update_process_details() wprintw(center, "%d", tmp->pid); print_key_title("PPID", line++); wprintw(center, "%d", tmp->ppid); + print_key_title("VPID", line++); + wprintw(center, "%d", tmp->vpid); + print_key_title("VTID", line++); + wprintw(center, "%d", tmp->vtid); + print_key_title("VPPID", line++); + wprintw(center, "%d", tmp->vppid); print_key_title("CPU", line++); wprintw(center, "%1.2f %%", tmp->totalcpunsec/maxcputime); @@ -779,8 +807,8 @@ void update_perf() while (g_hash_table_iter_next (&iter, &key, (gpointer) &perfn1)) { if (perfn1->visible) { if (perfn1->sort) { + /* pref_current_sort = i; */ wattron(center, A_UNDERLINE); - /* FIXME : sort in the opposite direction */ } /* + 5 to strip the "perf_" prefix */ mvwprintw(center, 1, perf_row, "%s", @@ -799,6 +827,15 @@ void update_perf() for (i = 0; i < data->process_table->len && nblinedisplayed < max_center_lines; i++) { tmp = g_ptr_array_index(data->process_table, i); + + if (!opt_tid && (opt_hostname && !lookup_hostname_list(tmp->hostname))) + continue; + if (!opt_hostname && (opt_tid && !lookup_tid_list(tmp->pid))) + continue; + if ((opt_tid && !lookup_tid_list(tmp->tid)) && + (opt_hostname && !lookup_hostname_list(tmp->hostname))) + continue; + if (tmp->pid != tmp->tid) if (toggle_threads == -1) continue; @@ -881,6 +918,15 @@ void update_iostream() for (i = list_offset; i < data->process_table->len && nblinedisplayed < max_center_lines; i++) { tmp = g_ptr_array_index(data->process_table, i); + + if (!opt_tid && (opt_hostname && !lookup_hostname_list(tmp->hostname))) + continue; + if (!opt_hostname && (opt_tid && !lookup_tid_list(tmp->pid))) + continue; + if ((opt_tid && !lookup_tid_list(tmp->tid)) && + (opt_hostname && !lookup_hostname_list(tmp->hostname))) + continue; + if (tmp->pid != tmp->tid) if (toggle_threads == -1) continue; @@ -1443,19 +1489,24 @@ void *handle_keyboard(void *p) update_preference_panel(&pref_line_selected, 0, 1); break; case '>': - if (!pref_panel_visible) { + /* perf uses a hashtable, it is ordered backward */ + if (current_view == perf) { + pref_current_sort--; + } else if (!pref_panel_visible) { pref_current_sort++; - update_sort(&pref_current_sort); - update_current_view(); } + update_sort(&pref_current_sort); + update_current_view(); break; case '<': - if (!pref_panel_visible) { - if (pref_current_sort > 0) - pref_current_sort--; - update_sort(&pref_current_sort); - update_current_view(); + /* perf uses a hashtable, it is ordered backward */ + if (current_view == perf) { + pref_current_sort++; + } else if (!pref_panel_visible) { + pref_current_sort--; } + update_sort(&pref_current_sort); + update_current_view(); break; case 13: /* FIXME : KEY_ENTER ?? */ @@ -1468,6 +1519,7 @@ void *handle_keyboard(void *p) current_view = previous_view; previous_view = process_details; } + selected_line = 0; update_current_view(); break; @@ -1502,6 +1554,8 @@ void *handle_keyboard(void *p) case KEY_F(10): case 'q': reset_ncurses(); + /* exit keyboard thread */ + pthread_exit(0); break; case 't': toggle_threads *= -1; @@ -1517,6 +1571,10 @@ void *handle_keyboard(void *p) case 'r': toggle_pref_panel(); break; + case 'v': + toggle_virt *= -1; + update_current_view(); + break; /* ESCAPE, but slow to process, don't know why */ case 27: if (pref_panel_visible) @@ -1543,7 +1601,9 @@ void init_view_headers() cputopview[0].sort = 1; cputopview[1].title = strdup("PID"); cputopview[2].title = strdup("TID"); - cputopview[3].title = strdup("NAME"); + cputopview[3].title = strdup("VPID"); + cputopview[4].title = strdup("VTID"); + cputopview[5].title = strdup("NAME"); iostreamtopview[0].title = strdup("R (B/sec)"); iostreamtopview[1].title = strdup("W (B/sec)");