add_proc now takes hostname param
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 29 Aug 2012 02:04:46 +0000 (22:04 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Sat, 19 Oct 2013 16:02:38 +0000 (12:02 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
src/common.c
src/common.h
src/cputop.c
src/cursesdisplay.c
src/iostreamtop.c
src/lttngtop.c

index 500c80d674f9056ced114e75a54af1e04fc51fc2..02d72bb6e023b252da6be57af4330d138baa9a3b 100644 (file)
@@ -175,7 +175,7 @@ struct processtop *find_process_tid(struct lttngtop *ctx, int tid, char *comm)
 }
 
 struct processtop* add_proc(struct lttngtop *ctx, int tid, char *comm,
 }
 
 struct processtop* add_proc(struct lttngtop *ctx, int tid, char *comm,
-               unsigned long timestamp)
+               unsigned long timestamp, char *hostname)
 {
        struct processtop *newproc;
 
 {
        struct processtop *newproc;
 
@@ -207,6 +207,15 @@ struct processtop* add_proc(struct lttngtop *ctx, int tid, char *comm,
                ctx->nbthreads++;
        }
        newproc->comm = strdup(comm);
                ctx->nbthreads++;
        }
        newproc->comm = strdup(comm);
+       if (hostname) {
+               if (newproc->hostname && strcmp(newproc->hostname, hostname) != 0) {
+                       free(newproc->hostname);
+               }
+               newproc->hostname = strdup(hostname);
+               if (lookup_hostname_list(hostname)) {
+                       add_filter_tid_list(tid, newproc);
+               }
+       }
 
        return newproc;
 }
 
        return newproc;
 }
@@ -225,15 +234,6 @@ struct processtop* update_proc(struct processtop* proc, int pid, int tid,
                        free(proc->comm);
                        proc->comm = strdup(comm);
                }
                        free(proc->comm);
                        proc->comm = strdup(comm);
                }
-               if (hostname) {
-                       if (proc->hostname && strcmp(proc->hostname, hostname) != 0) {
-                               free(proc->hostname);
-                       }
-                       proc->hostname = strdup(hostname);
-                       if (lookup_hostname_list(hostname)) {
-                               add_filter_tid_list(tid, proc);
-                       }
-               }
        }
        return proc;
 }
        }
        return proc;
 }
@@ -258,23 +258,23 @@ void death_proc(struct lttngtop *ctx, int tid, char *comm,
 }
 
 struct processtop* get_proc(struct lttngtop *ctx, int tid, char *comm,
 }
 
 struct processtop* get_proc(struct lttngtop *ctx, int tid, char *comm,
-               unsigned long timestamp)
+               unsigned long timestamp, char *hostname)
 {
        struct processtop *tmp;
        tmp = find_process_tid(ctx, tid, comm);
        if (tmp && strcmp(tmp->comm, comm) == 0)
                return tmp;
 {
        struct processtop *tmp;
        tmp = find_process_tid(ctx, tid, comm);
        if (tmp && strcmp(tmp->comm, comm) == 0)
                return tmp;
-       return add_proc(ctx, tid, comm, timestamp);
+       return add_proc(ctx, tid, comm, timestamp, hostname);
 }
 
 struct processtop *get_proc_pid(struct lttngtop *ctx, int tid, int pid,
 }
 
 struct processtop *get_proc_pid(struct lttngtop *ctx, int tid, int pid,
-               unsigned long timestamp)
+               unsigned long timestamp, char *hostname)
 {
        struct processtop *tmp;
        tmp = find_process_tid(ctx, tid, NULL);
        if (tmp && tmp->pid == pid)
                return tmp;
 {
        struct processtop *tmp;
        tmp = find_process_tid(ctx, tid, NULL);
        if (tmp && tmp->pid == pid)
                return tmp;
-       return add_proc(ctx, tid, "Unknown", timestamp);
+       return add_proc(ctx, tid, "Unknown", timestamp, hostname);
 }
 
 void add_thread(struct processtop *parent, struct processtop *thread)
 }
 
 void add_thread(struct processtop *parent, struct processtop *thread)
@@ -620,8 +620,9 @@ enum bt_cb_ret handle_statedump_process_state(struct bt_ctf_event *call_data,
        }
 
        proc = find_process_tid(&lttngtop, tid, procname);
        }
 
        proc = find_process_tid(&lttngtop, tid, procname);
+       /* FIXME : hostname NULL */
        if (proc == NULL)
        if (proc == NULL)
-               proc = add_proc(&lttngtop, tid, procname, timestamp);
+               proc = add_proc(&lttngtop, tid, procname, timestamp, NULL);
        update_proc(proc, pid, tid, ppid, vpid, vtid, vppid, procname, NULL);
 
        if (proc) {
        update_proc(proc, pid, tid, ppid, vpid, vtid, vppid, procname, NULL);
 
        if (proc) {
@@ -669,6 +670,14 @@ char *lookup_hostname_list(const char *hostname)
        return g_hash_table_lookup(hostname_list, (gpointer) hostname);
 }
 
        return g_hash_table_lookup(hostname_list, (gpointer) hostname);
 }
 
+void remove_hostname_list(const char *hostname)
+{
+       if (!hostname || !hostname_list)
+               return;
+
+       g_hash_table_remove(hostname_list, (gpointer) hostname);
+}
+
 int *lookup_filter_tid_list(int tid)
 {
        return g_hash_table_lookup(global_filter_list, (gpointer) &tid);
 int *lookup_filter_tid_list(int tid)
 {
        return g_hash_table_lookup(global_filter_list, (gpointer) &tid);
index 59a7a7f93ed9ff6562a247a2c3f1f3ceeec8282e..e0d4f4afc598db8d30a4b4bfd33fafdf3f44b959 100644 (file)
@@ -46,16 +46,16 @@ struct lttngtop *data;
 
 struct processtop *find_process_tid(struct lttngtop *ctx, int pid, char *comm);
 struct processtop* add_proc(struct lttngtop *ctx, int pid, char *comm,
 
 struct processtop *find_process_tid(struct lttngtop *ctx, int pid, char *comm);
 struct processtop* add_proc(struct lttngtop *ctx, int pid, char *comm,
-               unsigned long timestamp);
+               unsigned long timestamp, char *hostname);
 struct processtop* update_proc(struct processtop* proc, int pid, int tid,
                int ppid, int vpid, int vtid, int vppid, char *comm,
                char *hostname);
 void add_thread(struct processtop *parent, struct processtop *thread);
 struct processtop* get_proc(struct lttngtop *ctx, int tid, char *comm,
 struct processtop* update_proc(struct processtop* proc, int pid, int tid,
                int ppid, int vpid, int vtid, int vppid, char *comm,
                char *hostname);
 void add_thread(struct processtop *parent, struct processtop *thread);
 struct processtop* get_proc(struct lttngtop *ctx, int tid, char *comm,
-               unsigned long timestamp);
+               unsigned long timestamp, char *hostname);
 
 struct processtop *get_proc_pid(struct lttngtop *ctx, int tid, int pid,
 
 struct processtop *get_proc_pid(struct lttngtop *ctx, int tid, int pid,
-               unsigned long timestamp);
+               unsigned long timestamp, char *hostname);
 
 void death_proc(struct lttngtop *ctx, int tid, char *comm,
                unsigned long timestamp);
 
 void death_proc(struct lttngtop *ctx, int tid, char *comm,
                unsigned long timestamp);
@@ -87,6 +87,7 @@ struct tm format_timestamp(uint64_t timestamp);
 int *lookup_filter_tid_list(int tid);
 int *lookup_tid_list(int tid);
 char *lookup_hostname_list(const char *hostname);
 int *lookup_filter_tid_list(int tid);
 int *lookup_tid_list(int tid);
 char *lookup_hostname_list(const char *hostname);
+void remove_hostname_list(const char *hostname);
 void add_filter_tid_list(int tid, struct processtop *newproc);
 void remove_filter_tid_list(int tid);
 
 void add_filter_tid_list(int tid, struct processtop *newproc);
 void remove_filter_tid_list(int tid);
 
index 2e0ccddfdc3111dbb0cab02653fd559478818197..7df54696afdcb186159bab40ca6b34ba5b37ec73 100644 (file)
@@ -22,7 +22,7 @@
 #include "cputop.h"
 
 void update_cputop_data(unsigned long timestamp, int64_t cpu, int prev_pid,
 #include "cputop.h"
 
 void update_cputop_data(unsigned long timestamp, int64_t cpu, int prev_pid,
-               int next_pid, char *prev_comm, char *next_comm)
+               int next_pid, char *prev_comm, char *next_comm, char *hostname)
 {
        struct cputime *tmpcpu;
        unsigned long elapsed;
 {
        struct cputime *tmpcpu;
        unsigned long elapsed;
@@ -39,7 +39,8 @@ void update_cputop_data(unsigned long timestamp, int64_t cpu, int prev_pid,
        }
 
        if (next_pid != 0)
        }
 
        if (next_pid != 0)
-               tmpcpu->current_task = get_proc(&lttngtop, next_pid, next_comm, timestamp);
+               tmpcpu->current_task = get_proc(&lttngtop, next_pid, next_comm,
+                               timestamp, hostname);
        else
                tmpcpu->current_task = NULL;
 
        else
                tmpcpu->current_task = NULL;
 
@@ -54,6 +55,7 @@ enum bt_cb_ret handle_sched_switch(struct bt_ctf_event *call_data,
        uint64_t cpu_id;
        char *prev_comm, *next_comm;
        int prev_tid, next_tid;
        uint64_t cpu_id;
        char *prev_comm, *next_comm;
        int prev_tid, next_tid;
+       char *hostname;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
@@ -88,11 +90,12 @@ enum bt_cb_ret handle_sched_switch(struct bt_ctf_event *call_data,
                fprintf(stderr, "Missing next_tid context info\n");
                goto error;
        }
                fprintf(stderr, "Missing next_tid context info\n");
                goto error;
        }
+       hostname = get_context_hostname(call_data);
 
        cpu_id = get_cpu_id(call_data);
 
        update_cputop_data(timestamp, cpu_id, prev_tid, next_tid,
 
        cpu_id = get_cpu_id(call_data);
 
        update_cputop_data(timestamp, cpu_id, prev_tid, next_tid,
-                       prev_comm, next_comm);
+                       prev_comm, next_comm, hostname);
 
        return BT_CB_OK;
 
 
        return BT_CB_OK;
 
index 36951315c52ae6596f4dbe5060414d29d33bdb5b..848703873fe52315aec6ee0d3cb6155330a73c89 100644 (file)
@@ -1494,8 +1494,6 @@ void *handle_keyboard(void *p)
                                update_selected_processes();
                                if (toggle_filter > 0) {
                                        max_elements = g_hash_table_size(global_filter_list);
                                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;
                                }
                                        if (selected_line >= max_elements)
                                                selected_line = max_elements - 1;
                                }
index d3172f0648a3a8f49e1f6107c9e6d8efb0b75f88..367fdee6ef2e281c2cbcbde3bc0019b74872ac08 100644 (file)
@@ -189,13 +189,14 @@ void show_history(struct file_history *history)
 }
 
 int update_iostream_ret(struct lttngtop *ctx, int tid, char *comm,
 }
 
 int update_iostream_ret(struct lttngtop *ctx, int tid, char *comm,
-               unsigned long timestamp, uint64_t cpu_id, int ret)
+               unsigned long timestamp, uint64_t cpu_id, int ret,
+               char *hostname)
 {
        struct processtop *tmp;
        struct files *tmpfile;
        int err = 0;
 
 {
        struct processtop *tmp;
        struct files *tmpfile;
        int err = 0;
 
-       tmp = get_proc(ctx, tid, comm, timestamp);
+       tmp = get_proc(ctx, tid, comm, timestamp, hostname);
 
        if (!tmp) {
                err = -1;
 
        if (!tmp) {
                err = -1;
@@ -271,6 +272,7 @@ enum bt_cb_ret handle_exit_syscall(struct bt_ctf_event *call_data,
        char *comm;
        uint64_t ret, tid;
        uint64_t cpu_id;
        char *comm;
        uint64_t ret, tid;
        uint64_t cpu_id;
+       char *hostname;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
@@ -289,13 +291,15 @@ enum bt_cb_ret handle_exit_syscall(struct bt_ctf_event *call_data,
        }
 
        cpu_id = get_cpu_id(call_data);
        }
 
        cpu_id = get_cpu_id(call_data);
+       hostname = get_context_hostname(call_data);
 
        /*
         * if we encounter an exit_syscall and
         * it is not for a syscall read or write
         * we just abort the execution of this callback
         */
 
        /*
         * if we encounter an exit_syscall and
         * it is not for a syscall read or write
         * we just abort the execution of this callback
         */
-       if ((update_iostream_ret(&lttngtop, tid, comm, timestamp, cpu_id, ret)) < 0)
+       if ((update_iostream_ret(&lttngtop, tid, comm, timestamp, cpu_id,
+                                       ret, hostname)) < 0)
                return BT_CB_ERROR_CONTINUE;
 
        return BT_CB_OK;
                return BT_CB_ERROR_CONTINUE;
 
        return BT_CB_OK;
@@ -313,7 +317,7 @@ enum bt_cb_ret handle_sys_write(struct bt_ctf_event *call_data,
        unsigned long timestamp;
        uint64_t cpu_id;
        int64_t tid;
        unsigned long timestamp;
        uint64_t cpu_id;
        int64_t tid;
-       char *procname;
+       char *procname, *hostname;
        int fd;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        int fd;
 
        timestamp = bt_ctf_get_timestamp(call_data);
@@ -324,6 +328,7 @@ enum bt_cb_ret handle_sys_write(struct bt_ctf_event *call_data,
        cpu_id = get_cpu_id(call_data);
 
        procname = get_context_comm(call_data);
        cpu_id = get_cpu_id(call_data);
 
        procname = get_context_comm(call_data);
+       hostname = get_context_hostname(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -334,7 +339,7 @@ enum bt_cb_ret handle_sys_write(struct bt_ctf_event *call_data,
                goto error;
        }
 
                goto error;
        }
 
-       tmp = get_proc(&lttngtop, tid, procname, timestamp);
+       tmp = get_proc(&lttngtop, tid, procname, timestamp, hostname);
        if (!tmp)
                goto end;
 
        if (!tmp)
                goto end;
 
@@ -359,6 +364,7 @@ enum bt_cb_ret handle_sys_read(struct bt_ctf_event *call_data,
        int64_t tid;
        char *procname;
        int fd;
        int64_t tid;
        char *procname;
        int fd;
+       char *hostname;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
@@ -368,6 +374,7 @@ enum bt_cb_ret handle_sys_read(struct bt_ctf_event *call_data,
        cpu_id = get_cpu_id(call_data);
 
        procname = get_context_comm(call_data);
        cpu_id = get_cpu_id(call_data);
 
        procname = get_context_comm(call_data);
+       hostname = get_context_hostname(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -378,7 +385,7 @@ enum bt_cb_ret handle_sys_read(struct bt_ctf_event *call_data,
                goto error;
        }
 
                goto error;
        }
 
-       tmp = get_proc(&lttngtop, tid, procname, timestamp);
+       tmp = get_proc(&lttngtop, tid, procname, timestamp, hostname);
        if (!tmp)
                goto end;
 
        if (!tmp)
                goto end;
 
@@ -403,7 +410,7 @@ enum bt_cb_ret handle_sys_open(struct bt_ctf_event *call_data,
        unsigned long timestamp;
        uint64_t cpu_id;
        int64_t tid;
        unsigned long timestamp;
        uint64_t cpu_id;
        int64_t tid;
-       char *procname;
+       char *procname, *hostname;
        char *file;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        char *file;
 
        timestamp = bt_ctf_get_timestamp(call_data);
@@ -414,6 +421,7 @@ enum bt_cb_ret handle_sys_open(struct bt_ctf_event *call_data,
        cpu_id = get_cpu_id(call_data);
 
        procname = get_context_comm(call_data);
        cpu_id = get_cpu_id(call_data);
 
        procname = get_context_comm(call_data);
+       hostname = get_context_hostname(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -424,7 +432,7 @@ enum bt_cb_ret handle_sys_open(struct bt_ctf_event *call_data,
                goto error;
        }
 
                goto error;
        }
 
-       tmp = get_proc(&lttngtop, tid, procname, timestamp);
+       tmp = get_proc(&lttngtop, tid, procname, timestamp, hostname);
        if (!tmp)
                goto end;
 
        if (!tmp)
                goto end;
 
@@ -449,6 +457,7 @@ enum bt_cb_ret handle_sys_close(struct bt_ctf_event *call_data,
        int64_t tid;
        char *procname;
        int fd;
        int64_t tid;
        char *procname;
        int fd;
+       char *hostname;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
@@ -457,6 +466,7 @@ enum bt_cb_ret handle_sys_close(struct bt_ctf_event *call_data,
        tid = get_context_tid(call_data);
 
        procname = get_context_comm(call_data);
        tid = get_context_tid(call_data);
 
        procname = get_context_comm(call_data);
+       hostname = get_context_hostname(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -467,7 +477,7 @@ enum bt_cb_ret handle_sys_close(struct bt_ctf_event *call_data,
                goto error;
        }
 
                goto error;
        }
 
-       tmp = get_proc(&lttngtop, tid, procname, timestamp);
+       tmp = get_proc(&lttngtop, tid, procname, timestamp, hostname);
        if (!tmp)
                goto end;
 
        if (!tmp)
                goto end;
 
@@ -488,7 +498,7 @@ enum bt_cb_ret handle_statedump_file_descriptor(struct bt_ctf_event *call_data,
        struct files *file;
        unsigned long timestamp;
        int64_t pid;
        struct files *file;
        unsigned long timestamp;
        int64_t pid;
-       char *file_name;
+       char *file_name, *hostname;
        int fd;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        int fd;
 
        timestamp = bt_ctf_get_timestamp(call_data);
@@ -521,8 +531,9 @@ enum bt_cb_ret handle_statedump_file_descriptor(struct bt_ctf_event *call_data,
                fprintf(stderr, "Missing file name context info\n");
                goto error;
        }
                fprintf(stderr, "Missing file name context info\n");
                goto error;
        }
+       hostname = get_context_hostname(call_data);
 
 
-       parent = get_proc_pid(&lttngtop, pid, pid, timestamp);
+       parent = get_proc_pid(&lttngtop, pid, pid, timestamp, hostname);
        if (!parent)
                goto end;
 
        if (!parent)
                goto end;
 
index 26da96786455021678a80a6fecd50448a9baa49b..2672c8f74bcffd91dac9c58c47eda1ca9239f2a7 100644 (file)
@@ -458,7 +458,7 @@ enum bt_cb_ret fix_process_table(struct bt_ctf_event *call_data,
        /* find or create the current process */
        child = find_process_tid(&lttngtop, tid, comm);
        if (!child)
        /* find or create the current process */
        child = find_process_tid(&lttngtop, tid, comm);
        if (!child)
-               child = add_proc(&lttngtop, tid, comm, timestamp);
+               child = add_proc(&lttngtop, tid, comm, timestamp, hostname);
        if (!child)
                goto end;
        update_proc(child, pid, tid, ppid, vpid, vtid, vppid, comm, hostname);
        if (!child)
                goto end;
        update_proc(child, pid, tid, ppid, vpid, vtid, vppid, comm, hostname);
@@ -467,7 +467,7 @@ enum bt_cb_ret fix_process_table(struct bt_ctf_event *call_data,
                /* find or create the parent */
                parent = find_process_tid(&lttngtop, pid, comm);
                if (!parent) {
                /* find or create the parent */
                parent = find_process_tid(&lttngtop, pid, comm);
                if (!parent) {
-                       parent = add_proc(&lttngtop, pid, comm, timestamp);
+                       parent = add_proc(&lttngtop, pid, comm, timestamp, hostname);
                        if (parent)
                                parent->pid = pid;
                }
                        if (parent)
                                parent->pid = pid;
                }
This page took 0.030044 seconds and 4 git commands to generate.