}
struct processtop* add_proc(struct lttngtop *ctx, int tid, char *comm,
- unsigned long timestamp)
+ unsigned long timestamp, char *hostname)
{
struct processtop *newproc;
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;
}
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;
}
}
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;
- 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,
- 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;
- return add_proc(ctx, tid, "Unknown", timestamp);
+ return add_proc(ctx, tid, "Unknown", timestamp, hostname);
}
void add_thread(struct processtop *parent, struct processtop *thread)
}
proc = find_process_tid(<tngtop, tid, procname);
+ /* FIXME : hostname NULL */
if (proc == NULL)
- proc = add_proc(<tngtop, tid, procname, timestamp);
+ proc = add_proc(<tngtop, tid, procname, timestamp, NULL);
update_proc(proc, pid, tid, ppid, vpid, vtid, vppid, procname, NULL);
if (proc) {
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);
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,
- unsigned long timestamp);
+ unsigned long timestamp, char *hostname);
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);
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);
#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;
}
if (next_pid != 0)
- tmpcpu->current_task = get_proc(<tngtop, next_pid, next_comm, timestamp);
+ tmpcpu->current_task = get_proc(<tngtop, next_pid, next_comm,
+ timestamp, hostname);
else
tmpcpu->current_task = NULL;
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)
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,
- prev_comm, next_comm);
+ prev_comm, next_comm, hostname);
return BT_CB_OK;
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;
}
}
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;
- tmp = get_proc(ctx, tid, comm, timestamp);
+ tmp = get_proc(ctx, tid, comm, timestamp, hostname);
if (!tmp) {
err = -1;
char *comm;
uint64_t ret, tid;
uint64_t cpu_id;
+ char *hostname;
timestamp = bt_ctf_get_timestamp(call_data);
if (timestamp == -1ULL)
}
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 ((update_iostream_ret(<tngtop, tid, comm, timestamp, cpu_id, ret)) < 0)
+ if ((update_iostream_ret(<tngtop, tid, comm, timestamp, cpu_id,
+ ret, hostname)) < 0)
return BT_CB_ERROR_CONTINUE;
return BT_CB_OK;
unsigned long timestamp;
uint64_t cpu_id;
int64_t tid;
- char *procname;
+ char *procname, *hostname;
int fd;
timestamp = bt_ctf_get_timestamp(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);
goto error;
}
- tmp = get_proc(<tngtop, tid, procname, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp, hostname);
if (!tmp)
goto end;
int64_t tid;
char *procname;
int fd;
+ char *hostname;
timestamp = bt_ctf_get_timestamp(call_data);
if (timestamp == -1ULL)
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);
goto error;
}
- tmp = get_proc(<tngtop, tid, procname, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp, hostname);
if (!tmp)
goto end;
unsigned long timestamp;
uint64_t cpu_id;
int64_t tid;
- char *procname;
+ char *procname, *hostname;
char *file;
timestamp = bt_ctf_get_timestamp(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);
goto error;
}
- tmp = get_proc(<tngtop, tid, procname, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp, hostname);
if (!tmp)
goto end;
int64_t tid;
char *procname;
int fd;
+ char *hostname;
timestamp = bt_ctf_get_timestamp(call_data);
if (timestamp == -1ULL)
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);
goto error;
}
- tmp = get_proc(<tngtop, tid, procname, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp, hostname);
if (!tmp)
goto end;
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);
fprintf(stderr, "Missing file name context info\n");
goto error;
}
+ hostname = get_context_hostname(call_data);
- parent = get_proc_pid(<tngtop, pid, pid, timestamp);
+ parent = get_proc_pid(<tngtop, pid, pid, timestamp, hostname);
if (!parent)
goto end;
/* find or create the current process */
child = find_process_tid(<tngtop, tid, comm);
if (!child)
- child = add_proc(<tngtop, tid, comm, timestamp);
+ child = add_proc(<tngtop, tid, comm, timestamp, hostname);
if (!child)
goto end;
update_proc(child, pid, tid, ppid, vpid, vtid, vppid, comm, hostname);
/* find or create the parent */
parent = find_process_tid(<tngtop, pid, comm);
if (!parent) {
- parent = add_proc(<tngtop, pid, comm, timestamp);
+ parent = add_proc(<tngtop, pid, comm, timestamp, hostname);
if (parent)
parent->pid = pid;
}