X-Git-Url: http://git.lttng.org/?p=lttngtop.git;a=blobdiff_plain;f=src%2Fcursesdisplay.c;h=36951315c52ae6596f4dbe5060414d29d33bdb5b;hp=5ef175248e781ad11a749cfa13a6086744f94512;hb=da4353bbbb28c19bd28447018edb94845ae71673;hpb=c8d75a13bc5c025053b0c2c14fa1a7dfdaa1b448 diff --git a/src/cursesdisplay.c b/src/cursesdisplay.c index 5ef1752..3695131 100644 --- a/src/cursesdisplay.c +++ b/src/cursesdisplay.c @@ -63,13 +63,13 @@ int toggle_virt = -1; int toggle_pause = -1; int max_center_lines; -GPtrArray *selected_processes; pthread_t keyboard_thread; struct header_view cputopview[6]; struct header_view iostreamtopview[3]; struct header_view fileview[3]; +struct header_view kprobeview[2]; void reset_ncurses() { @@ -105,8 +105,9 @@ void init_screen() init_pair(2, COLOR_GREEN, COLOR_BLACK); /* + */ init_pair(3, COLOR_BLACK, COLOR_WHITE); /* keys */ init_pair(4, COLOR_WHITE, COLOR_GREEN); /* keys activated */ - init_pair(5, COLOR_WHITE, COLOR_BLUE); /* select line */ - init_pair(6, COLOR_WHITE, COLOR_GREEN); /* selected process */ + init_pair(5, COLOR_BLACK, COLOR_YELLOW); /* select line */ + init_pair(6, COLOR_GREEN, COLOR_BLACK); /* selected process */ + init_pair(7, COLOR_RED, COLOR_YELLOW); /* selected process + line*/ } termtype = getenv("TERM"); if (!strcmp(termtype, "xterm") || !strcmp(termtype, "xterm-color") || @@ -231,37 +232,17 @@ void print_log(char *str) int process_selected(struct processtop *process) { - int i; - struct processtop *stored_process; - - for (i = 0; i < selected_processes->len; i++) { - stored_process = g_ptr_array_index(selected_processes, i); - if (!stored_process) - return 0; - if (stored_process->tid == process->tid) - return 1; - } + if (lookup_filter_tid_list(process->tid)) + return 1; return 0; } void update_selected_processes() { - int i; - struct processtop *stored_process; - if (process_selected(selected_process)) { - for (i = 0; i < selected_processes->len; i++) { - stored_process = g_ptr_array_index(selected_processes, i); - if (!stored_process) - return; - if (stored_process->tid == selected_process->tid) - g_ptr_array_remove(selected_processes, - stored_process); - print_log("Process removed"); - } + remove_filter_tid_list(selected_process->tid); } else { - g_ptr_array_add(selected_processes, selected_process); - print_log("Process added"); + add_filter_tid_list(selected_process->tid, selected_process); } } @@ -520,6 +501,39 @@ gint sort_by_cpu_group_by_threads_desc(gconstpointer p1, gconstpointer p2) return -1; } +void update_kprobes_display() +{ + int i, column; + struct kprobes *probe; + int header_offset = 2; + int current_line = 0; + + set_window_title(center, "Kprobes Top "); + wattron(center, A_BOLD); + column = 1; + for (i = 0; i < 2; i++) { + if (kprobeview[i].sort) { + wattron(center, A_UNDERLINE); + pref_current_sort = i; + } + mvwprintw(center, 1, column, "%s", kprobeview[i].title); + wattroff(center, A_UNDERLINE); + column += 30; + } + wattroff(center, A_BOLD); + + for (i = 0; i < data->kprobes_table->len; i++) { + column = 1; + probe = g_ptr_array_index(data->kprobes_table, i); + mvwprintw(center, current_line + header_offset, column, + "%s", probe->probe_name + 6); + column += 30; + mvwprintw(center, current_line + header_offset, column, + "%d", probe->count); + current_line++; + } +} + void update_cputop_display() { int i; @@ -570,27 +584,26 @@ void update_cputop_display() 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))) + if (toggle_filter > 0 && !lookup_filter_tid_list(tmp->tid)) continue; if (tmp->pid != tmp->tid) if (toggle_threads == -1) continue; - if (process_selected(tmp)) { - wattron(center, COLOR_PAIR(6)); - mvwhline(center, current_line + header_offset, 1, ' ', COLS-3); - } + /* line */ if (current_line == selected_line) { selected_process = tmp; wattron(center, COLOR_PAIR(5)); mvwhline(center, current_line + header_offset, 1, ' ', COLS-3); } + /* filtered process */ + if (process_selected(tmp)) { + if (current_line == selected_line) + wattron(center, COLOR_PAIR(7)); + else + wattron(center, COLOR_PAIR(6)); + } /* CPU(%) */ mvwprintw(center, current_line + header_offset, current_row_offset, "%1.2f", @@ -617,6 +630,7 @@ void update_cputop_display() /* NAME */ mvwprintw(center, current_line + header_offset, current_row_offset, "%s", tmp->comm); + wattroff(center, COLOR_PAIR(7)); wattroff(center, COLOR_PAIR(6)); wattroff(center, COLOR_PAIR(5)); nblinedisplayed++; @@ -828,12 +842,7 @@ void update_perf() 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))) + if (toggle_filter > 0 && !lookup_filter_tid_list(tmp->tid)) continue; if (tmp->pid != tmp->tid) @@ -841,8 +850,10 @@ void update_perf() continue; if (process_selected(tmp)) { - wattron(center, COLOR_PAIR(6)); - mvwhline(center, current_line + header_offset, 1, ' ', COLS-3); + if (current_line == selected_line) + wattron(center, COLOR_PAIR(7)); + else + wattron(center, COLOR_PAIR(6)); } if (current_line == selected_line) { selected_process = tmp; @@ -919,12 +930,7 @@ void update_iostream() 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))) + if (toggle_filter > 0 && !lookup_filter_tid_list(tmp->tid)) continue; if (tmp->pid != tmp->tid) @@ -932,8 +938,10 @@ void update_iostream() continue; if (process_selected(tmp)) { - wattron(center, COLOR_PAIR(6)); - mvwhline(center, current_line + header_offset, 1, ' ', COLS-3); + if (current_line == selected_line) + wattron(center, COLOR_PAIR(7)); + else + wattron(center, COLOR_PAIR(6)); } if (current_line == selected_line) { selected_process = tmp; @@ -993,6 +1001,9 @@ void update_current_view() case tree: update_cputop_display(); break; + case kprobes: + update_kprobes_display(); + break; default: break; } @@ -1481,6 +1492,13 @@ void *handle_keyboard(void *p) update_preference_panel(&pref_line_selected, 1, 0); } else { update_selected_processes(); + if (toggle_filter > 0) { + max_elements = g_hash_table_size(global_filter_list); + fprintf(stderr, "select : %d, max : %d\n", + selected_line, max_elements); + if (selected_line >= max_elements) + selected_line = max_elements - 1; + } update_current_view(); } break; @@ -1551,12 +1569,28 @@ void *handle_keyboard(void *p) selected_line = 0; update_current_view(); break; + case KEY_F(5): + if (pref_panel_visible) + toggle_pref_panel(); + current_view = kprobes; + selected_line = 0; + update_current_view(); + break; case KEY_F(10): case 'q': reset_ncurses(); /* exit keyboard thread */ pthread_exit(0); break; + case 'f': + toggle_filter *= -1; + selected_line = 0; + if (toggle_filter > 0) + max_elements = g_hash_table_size(global_filter_list); + else + max_elements = data->process_table->len; + update_current_view(); + break; case 't': toggle_threads *= -1; update_current_view(); @@ -1614,11 +1648,14 @@ void init_view_headers() fileview[1].title = strdup("READ"); fileview[1].sort = 1; fileview[2].title = strdup("WRITE"); + + kprobeview[0].title = strdup("NAME"); + kprobeview[1].title = strdup("HIT"); + kprobeview[1].sort = 1; } void init_ncurses() { - selected_processes = g_ptr_array_new(); sem_init(&update_display_sem, 0, 1); init_view_headers(); init_screen();