Reactivate header counters
authorJulien Desfossez <julien.desfossez@efficios.com>
Fri, 16 Mar 2012 19:01:09 +0000 (15:01 -0400)
committerJulien Desfossez <julien.desfossez@efficios.com>
Fri, 16 Mar 2012 19:01:09 +0000 (15:01 -0400)
This commit reenables the header counters where we display the amount of
processes and files open.

Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
src/common.c
src/common.h
src/cputop.c
src/cursesdisplay.c
src/iostreamtop.c
src/lttngtop.c

index 7c67264ebba1fdc652a1890c82aaee3266260a89..c01aee273aae54f3113a6a44ee6a1894bb9c311d 100644 (file)
@@ -135,6 +135,9 @@ struct processtop* add_proc(struct lttngtop *ctx, int tid, char *comm,
                newproc->threads = g_ptr_array_new();
                newproc->perf = g_hash_table_new(g_str_hash, g_str_equal);
                g_ptr_array_add(ctx->process_table, newproc);
+
+               ctx->nbnewthreads++;
+               ctx->nbthreads++;
        }
        newproc->comm = strdup(comm);
 
@@ -165,8 +168,11 @@ void death_proc(struct lttngtop *ctx, int tid, char *comm,
 {
        struct processtop *tmp;
        tmp = find_process_tid(ctx, tid, comm);
-       if (tmp && strcmp(tmp->comm, comm) == 0)
+       if (tmp && strcmp(tmp->comm, comm) == 0) {
                tmp->death = timestamp;
+               ctx->nbdeadthreads++;
+               ctx->nbthreads--;
+       }
 }
 
 struct processtop* get_proc(struct lttngtop *ctx, int tid, char *comm,
@@ -297,6 +303,30 @@ void cleanup_processtop()
        }
 }
 
+void reset_global_counters()
+{
+       lttngtop.nbnewproc = 0;
+       lttngtop.nbdeadproc = 0;
+       lttngtop.nbnewthreads = 0;
+       lttngtop.nbdeadthreads = 0;
+       lttngtop.nbnewfiles = 0;
+       lttngtop.nbclosedfiles = 0;
+}
+
+void copy_global_counters(struct lttngtop *dst)
+{
+       dst->nbproc = lttngtop.nbproc;
+       dst->nbnewproc = lttngtop.nbnewproc;
+       dst->nbdeadproc = lttngtop.nbdeadproc;
+       dst->nbthreads = lttngtop.nbthreads;
+       dst->nbnewthreads = lttngtop.nbnewthreads;
+       dst->nbdeadthreads = lttngtop.nbdeadthreads;
+       dst->nbfiles = lttngtop.nbfiles;
+       dst->nbnewfiles = lttngtop.nbnewfiles;
+       dst->nbclosedfiles = lttngtop.nbclosedfiles;
+       reset_global_counters();
+}
+
 struct lttngtop* get_copy_lttngtop(unsigned long start, unsigned long end)
 {
        gint i, j;
@@ -309,6 +339,7 @@ struct lttngtop* get_copy_lttngtop(unsigned long start, unsigned long end)
        dst = g_new0(struct lttngtop, 1);
        dst->start = start;
        dst->end = end;
+       copy_global_counters(dst);
        dst->process_table = g_ptr_array_new();
        dst->files_table = g_ptr_array_new();
        dst->cpu_table = g_ptr_array_new();
@@ -357,6 +388,7 @@ struct lttngtop* get_copy_lttngtop(unsigned long start, unsigned long end)
                         * files associated with if after the copy
                         */
                        if (tmp->death > 0 && tmp->death < end) {
+                               /* FIXME : close the files before */
                                g_ptr_array_remove(tmp->process_files_table, tmpfile);
                                g_free(tmpfile);
                        }
@@ -368,6 +400,7 @@ struct lttngtop* get_copy_lttngtop(unsigned long start, unsigned long end)
                 * the current process list after the copy
                 */
                if (tmp->death > 0 && tmp->death < end) {
+                       fprintf(stderr, "removing : %ld : %d %s\n", end, tmp->tid, tmp->comm);
                        g_ptr_array_remove(lttngtop.process_table, tmp);
                        /* FIXME : TRUE does not mean clears the object in it */
                        g_ptr_array_free(tmp->threads, TRUE);
index 6370b77f30afe1bcd14fa71815ebbba2dc77ba47..a9befb0ff1fe7238d573f30f23a029aee45eefaa 100644 (file)
@@ -50,6 +50,7 @@ struct perfcounter *add_perf_counter(GPtrArray *perf, GQuark quark,
                unsigned long count);
 struct perfcounter *get_perf_counter(const char *name, struct processtop *proc,
                struct cputime *cpu);
+void reset_global_counters(void);
 
 /* common field access functions */
 uint64_t get_cpu_id(const struct bt_ctf_event *event);
index c561d47205dd8af3ba8dc192f7da3652c0fe2369..1b9a129c2e34c399048a3005e5264362912f6dee 100644 (file)
@@ -120,7 +120,13 @@ enum bt_cb_ret handle_sched_process_free(struct bt_ctf_event *call_data,
                goto error;
        }
 
-       tid = get_context_tid(call_data);
+       tid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
+                               scope, "_tid"));
+       if (bt_ctf_field_get_error()) {
+               fprintf(stderr, "Missing tid field\n");
+               goto error;
+       }
+
        death_proc(&lttngtop, tid, comm, timestamp);
 
        return BT_CB_OK;
index 2fd69763673acf7fb55c51197a962cd7c5479830..042d45a6feb6bfbfa7a0962f935fd0b1509d8a50 100644 (file)
@@ -165,7 +165,7 @@ void print_headers(int line, char *desc, int value, int first, int second)
        wattron(header, A_BOLD);
        mvwprintw(header, line, 4, "%s", desc);
        wattroff(header, A_BOLD);
-       mvwprintw(header, line, 16, "N/A", value);
+       mvwprintw(header, line, 16, "%d", value);
        wmove(header, line, 24);
        print_digits(header, first, second);
        wmove(header, line, 40);
@@ -254,11 +254,9 @@ void basic_header()
        set_window_title(header, "Statistics for interval [gathering data...[");
        wattron(header, A_BOLD);
        mvwprintw(header, 1, 4, "CPUs");
-       mvwprintw(header, 2, 4, "Processes");
-       mvwprintw(header, 3, 4, "Threads");
-       mvwprintw(header, 4, 4, "Files");
-       mvwprintw(header, 5, 4, "Network");
-       mvwprintw(header, 6, 4, "IO");
+       mvwprintw(header, 2, 4, "Threads");
+       mvwprintw(header, 3, 4, "Files");
+       mvwprintw(header, 4, 4, "Network");
        wattroff(header, A_BOLD);
        wrefresh(header);
 }
@@ -281,15 +279,13 @@ void update_header()
        wattroff(header, A_BOLD);
        wprintw(header, "\t%d\t(max/cpu : %0.2f%)", data->cpu_table->len,
                        100.0/data->cpu_table->len);
-       print_headers(2, "Processes", data->nbproc, data->nbnewproc,
-                       -1*(data->nbdeadproc));
-       print_headers(3, "Threads", data->nbthreads, data->nbnewthreads,
+       print_headers(2, "Threads", data->nbthreads, data->nbnewthreads,
                        -1*(data->nbdeadthreads));
-       print_headers(4, "Files", data->nbfiles, data->nbnewfiles,
+       print_headers(3, "Files", data->nbfiles, data->nbnewfiles,
                        -1*(data->nbclosedfiles));
-       mvwprintw(header, 4, 43, "N/A kbytes/sec");
-       print_headers(5, "Network", 114, 0, 0);
-       mvwprintw(header, 5, 43, "N/A Mbytes/sec");
+       mvwprintw(header, 3, 43, "N/A kbytes/sec");
+       print_headers(4, "Network", 0, 0, 0);
+       mvwprintw(header, 4, 43, "N/A Mbytes/sec");
        wrefresh(header);
 }
 
@@ -940,8 +936,8 @@ void init_ncurses()
        sem_init(&update_display_sem, 0, 1);
        init_screen();
 
-       header = create_window(7, COLS - 1, 0, 0);
-       center = create_window(LINES - 7 - 7, COLS - 1, 7, 0);
+       header = create_window(6, COLS - 1, 0, 0);
+       center = create_window(LINES - 7 - 7, COLS - 1, 6, 0);
        status = create_window(MAX_LOG_LINES + 2, COLS - 1, LINES - 7, 0);
        footer = create_window(1, COLS - 1, LINES - 1, 0);
 
index 71843cb900137a2adb706a5124800c221724f391..35a58a414f8e6274ac7898e9e18d099bb75bb390 100644 (file)
@@ -55,6 +55,8 @@ void add_file(struct processtop *proc, struct files *file, int fd)
        }
        file->fd = fd;
        file->flag = __NR_open;
+       lttngtop.nbfiles++;
+       lttngtop.nbnewfiles++;
 }
 
 /* TODO */
@@ -85,7 +87,6 @@ void insert_file(struct processtop *proc, int fd)
                tmp->fd = fd;
                add_file(proc, tmp, fd);
        } else {
-
                tmp = g_ptr_array_index(proc->process_files_table, fd);
                if (tmp == NULL) {
                        tmp = g_new0(struct files, 1);
@@ -102,10 +103,12 @@ void close_file(struct processtop *proc, int fd)
 {
        struct files *file;
 
-
        file = get_file(proc, fd);
-       if (file != NULL)
+       if (file != NULL) {
                file->flag = __NR_close;
+               lttngtop.nbfiles--;
+       }
+       lttngtop.nbclosedfiles++;
 }
 
 struct files *get_file(struct processtop *proc, int fd)
index e98785a8cfe5e3c06cb65affcc2fa7ff1ecaaf0a..dfa1d14c5502b55a21528555c39a905b4cb2af9b 100644 (file)
@@ -316,6 +316,11 @@ void init_lttngtop()
        sem_init(&pause_sem, 0, 1);
        sem_init(&end_trace_sem, 0, 0);
 
+       reset_global_counters();
+       lttngtop.nbproc = 0;
+       lttngtop.nbthreads = 0;
+       lttngtop.nbfiles = 0;
+
        lttngtop.process_table = g_ptr_array_new();
        lttngtop.files_table = g_ptr_array_new();
        lttngtop.cpu_table = g_ptr_array_new();
This page took 0.026452 seconds and 4 git commands to generate.