prepare the 0.3 release
[lttngtop.git] / src / common.c
index 31fa9055ce59548b42e134704d71be77f536638a..a6c2e4c3cfa17a24d833dce601947e14761969a1 100644 (file)
@@ -45,8 +45,12 @@ uint64_t get_context_tid(const struct bt_ctf_event *event)
        tid = bt_ctf_get_int64(bt_ctf_get_field(event,
                                scope, "_tid"));
        if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing tid context info\n");
-               return -1ULL;
+               tid = bt_ctf_get_int64(bt_ctf_get_field(event,
+                                       scope, "_vtid"));
+               if (bt_ctf_field_get_error()) {
+                       fprintf(stderr, "Missing tid context info\n");
+                       return -1ULL;
+               }
        }
 
        return tid;
@@ -61,8 +65,13 @@ uint64_t get_context_pid(const struct bt_ctf_event *event)
        pid = bt_ctf_get_int64(bt_ctf_get_field(event,
                                scope, "_pid"));
        if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing pid context info\n");
-               return -1ULL;
+               /* Try UST pid */
+               pid = bt_ctf_get_int64(bt_ctf_get_field(event,
+                                       scope, "_vpid"));
+               if (bt_ctf_field_get_error()) {
+                       fprintf(stderr, "Missing pid context info\n");
+                       return -1ULL;
+               }
        }
 
        return pid;
@@ -77,7 +86,6 @@ uint64_t get_context_ppid(const struct bt_ctf_event *event)
        ppid = bt_ctf_get_int64(bt_ctf_get_field(event,
                                scope, "_ppid"));
        if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing ppid context info\n");
                return -1ULL;
        }
 
@@ -290,7 +298,7 @@ struct processtop *get_proc_pid(struct lttngtop *ctx, int tid, int pid,
        tmp = find_process_tid(ctx, tid, NULL);
        if (tmp && tmp->pid == pid)
                return tmp;
-       return add_proc(ctx, tid, "Unknown", timestamp, hostname);
+       return add_proc(ctx, tid, NULL, timestamp, hostname);
 }
 
 void add_thread(struct processtop *parent, struct processtop *thread)
@@ -494,7 +502,10 @@ struct lttngtop* get_copy_lttngtop(unsigned long start, unsigned long end)
 
                        if (tmpfile != NULL) {
                                memcpy(newfile, tmpfile, sizeof(struct files));
-                               newfile->name = strdup(tmpfile->name);
+                               if (tmpfile->name)
+                                       newfile->name = strdup(tmpfile->name);
+                               else
+                                       newfile->name = NULL;
                                newfile->ref = new;
                                g_ptr_array_add(new->process_files_table,
                                                newfile);
@@ -582,7 +593,7 @@ enum bt_cb_ret handle_statedump_process_state(struct bt_ctf_event *call_data,
        struct processtop *proc;
        unsigned long timestamp;
        int64_t pid, tid, ppid, vtid, vpid, vppid;
-       char *procname, *hostname = NULL;
+       char *procname = NULL, *hostname = NULL;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
@@ -599,8 +610,7 @@ enum bt_cb_ret handle_statedump_process_state(struct bt_ctf_event *call_data,
        ppid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
                                scope, "_ppid"));
        if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing ppid context info\n");
-               goto error;
+               goto end;
        }
        tid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
                                scope, "_tid"));
@@ -647,6 +657,7 @@ enum bt_cb_ret handle_statedump_process_state(struct bt_ctf_event *call_data,
                proc->pid = pid;
        }
 
+end:
        return BT_CB_OK;
 
 error:
@@ -750,3 +761,26 @@ void update_hostname_filter(struct host *host)
                }
        }
 }
+
+char *lookup_procname(const char *procname)
+{
+       if (!procname || !global_procname_list)
+               return NULL;
+
+       return g_hash_table_lookup(global_procname_list, (gpointer) procname);
+}
+
+char *add_procname_list(char *procname, int filter)
+{
+       char *proc;
+
+       proc = lookup_procname(procname);
+       if (proc)
+               return proc;
+
+       proc = strdup(procname);
+       g_hash_table_insert(global_procname_list,
+                       (gpointer) procname, (gpointer) procname);
+
+       return proc;
+}
This page took 0.023368 seconds and 4 git commands to generate.