kprobe support
[lttngtop.git] / src / cursesdisplay.c
index 02764dd19976996f13fb1f11a580531aa3285b60..4cc97301648296a95c2ad625dded42d02e7aefe0 100644 (file)
@@ -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,9 +67,10 @@ 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];
+struct header_view kprobeview[2];
 
 void reset_ncurses()
 {
@@ -78,6 +80,8 @@ void reset_ncurses()
        sem_post(&pause_sem);
        sem_post(&timer);
        sem_post(&goodtodisplay);
+       sem_post(&end_trace_sem);
+       sem_post(&goodtoupdate);
 }
 
 static void handle_sigterm(int signal)
@@ -288,6 +292,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);
@@ -516,6 +521,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;
@@ -525,6 +563,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;
@@ -544,7 +583,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;
@@ -561,6 +603,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;
@@ -575,14 +626,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++;
@@ -672,6 +740,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);
 
@@ -787,6 +861,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;
@@ -869,6 +952,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;
@@ -935,6 +1027,9 @@ void update_current_view()
        case tree:
                update_cputop_display();
                break;
+       case kprobes:
+               update_kprobes_display();
+               break;
        default:
                break;
        }
@@ -1493,6 +1588,13 @@ 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();
@@ -1513,6 +1615,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)
@@ -1539,7 +1645,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)");
@@ -1550,6 +1658,10 @@ 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()
This page took 0.025147 seconds and 4 git commands to generate.