/*
* To get the parent process, put the pid in the tid field
* because the parent process gets pid = tid
- *
- * FIXME : char *comm useful ???
*/
struct processtop *find_process_tid(struct lttngtop *ctx, int tid, char *comm)
{
- gint i;
struct processtop *tmp;
- for (i = 0; i < ctx->process_table->len; i++) {
- tmp = g_ptr_array_index(ctx->process_table, i);
- if (tmp && tmp->tid == tid)
- return tmp;
- }
- return NULL;
+ tmp = g_hash_table_lookup(ctx->process_hash_table,
+ (gconstpointer) (unsigned long) tid);
+
+ return tmp;
}
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);
+ g_hash_table_insert(ctx->process_hash_table,
+ (gpointer) (unsigned long) tid, newproc);
ctx->nbnewthreads++;
ctx->nbthreads++;
{
struct processtop *tmp;
tmp = find_process_tid(ctx, tid, comm);
+
+ g_hash_table_remove(ctx->process_hash_table,
+ (gpointer) (unsigned long) tid);
if (tmp && strcmp(tmp->comm, comm) == 0) {
tmp->death = timestamp;
ctx->nbdeadthreads++;
g_hash_table_insert((GHashTable *) new_table, strdup(key), newperf);
}
+void copy_process_table(gpointer key, gpointer value, gpointer new_table)
+{
+ g_hash_table_insert((GHashTable *) new_table, key, value);
+}
+
void rotate_perfcounter() {
int i;
struct processtop *tmp;
dst->process_table = g_ptr_array_new();
dst->files_table = g_ptr_array_new();
dst->cpu_table = g_ptr_array_new();
+ dst->process_hash_table = g_hash_table_new(g_direct_hash, g_direct_equal);
+ g_hash_table_foreach(lttngtop.process_hash_table, copy_process_table,
+ dst->process_hash_table);
rotate_cputime(end);
copies = g_ptr_array_new();
global_perf_liszt = g_hash_table_new(g_str_hash, g_str_equal);
+
sem_init(&goodtodisplay, 0, 0);
sem_init(&goodtoupdate, 0, 1);
sem_init(&timer, 0, 1);
lttngtop.nbthreads = 0;
lttngtop.nbfiles = 0;
+ lttngtop.process_hash_table = g_hash_table_new(g_direct_hash,
+ g_direct_equal);
lttngtop.process_table = g_ptr_array_new();
lttngtop.files_table = g_ptr_array_new();
lttngtop.cpu_table = g_ptr_array_new();
if (!metadata_ready) {
sem_wait(&metadata_available);
- if (access("/tmp/livesession/kernel/metadata", F_OK) != 0) {
+ if (access("/tmp/livesession/metadata", F_OK) != 0) {
fprintf(stderr,"no metadata\n");
return NULL;
}
metadata_ready = 1;
- metadata_fp = fopen("/tmp/livesession/kernel/metadata", "r");
+ metadata_fp = fopen("/tmp/livesession/metadata", "r");
}
if (!trace_opened) {