return dst;
}
+
+enum bt_cb_ret handle_statedump_process_state(struct bt_ctf_event *call_data,
+ void *private_data)
+{
+ const struct definition *scope;
+ struct processtop *proc;
+ unsigned long timestamp;
+ int64_t pid, tid;
+ char *procname;
+
+ timestamp = bt_ctf_get_timestamp(call_data);
+ if (timestamp == -1ULL)
+ goto error;
+
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_EVENT_FIELDS);
+ pid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
+ scope, "_pid"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing pid context info\n");
+ goto error;
+ }
+
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_EVENT_FIELDS);
+ tid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
+ scope, "_tid"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing tid context info\n");
+ goto error;
+ }
+
+ /*
+ * FIXME
+ * I first tried with bt_ctf_get_string but doesn`t work at all
+ * It couldn`t find the field _name because it is an integer in
+ * the metadata and not a string like _filename for the
+ * statedump_file_descriptor
+ */
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_EVENT_FIELDS);
+ procname = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
+ scope, "_name"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing process name context info\n");
+ goto error;
+ }
+
+ proc = find_process_tid(<tngtop, tid, procname);
+ if (proc == NULL)
+ proc = add_proc(<tngtop, tid, procname, timestamp);
+
+ free(proc->comm);
+ proc->comm = strdup(procname);
+ proc->pid = pid;
+
+ /*
+ * FIXME
+ * I would like to free procname because it is duplicated
+ * when the process is created but it segfaults...
+ *
+ * free(procname);
+ */
+
+ return BT_CB_OK;
+
+error:
+ return BT_CB_ERROR_STOP;
+}
struct processtop *tmp;
unsigned long timestamp;
uint64_t cpu_id;
- int64_t tid, pid;
+ int64_t tid;
+ char *procname;
int fd;
timestamp = bt_ctf_get_timestamp(call_data);
tid = get_context_tid(call_data);
cpu_id = get_cpu_id(call_data);
- pid = get_context_pid(call_data);
+ procname = get_context_comm(call_data);
scope = bt_ctf_get_top_level_scope(call_data,
BT_EVENT_FIELDS);
goto error;
}
- tmp = get_proc_pid(<tngtop, tid, pid, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp);
tmp->syscall_info = create_syscall_info(__NR_write, cpu_id, tid, fd);
insert_file(tmp, fd);
const struct definition *scope;
unsigned long timestamp;
uint64_t cpu_id;
- int64_t tid, pid;
+ int64_t tid;
+ char *procname;
int fd;
timestamp = bt_ctf_get_timestamp(call_data);
tid = get_context_tid(call_data);
cpu_id = get_cpu_id(call_data);
- pid = get_context_pid(call_data);
+ procname = get_context_comm(call_data);
scope = bt_ctf_get_top_level_scope(call_data,
BT_EVENT_FIELDS);
goto error;
}
- tmp = get_proc_pid(<tngtop, tid, pid, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp);
tmp->syscall_info = create_syscall_info(__NR_read, cpu_id, tid, fd);
insert_file(tmp, fd);
const struct definition *scope;
unsigned long timestamp;
uint64_t cpu_id;
- int64_t tid, pid;
+ int64_t tid;
+ char *procname;
char *file;
timestamp = bt_ctf_get_timestamp(call_data);
tid = get_context_tid(call_data);
cpu_id = get_cpu_id(call_data);
- pid = get_context_pid(call_data);
+ procname = get_context_comm(call_data);
scope = bt_ctf_get_top_level_scope(call_data,
BT_EVENT_FIELDS);
goto error;
}
- tmp = get_proc_pid(<tngtop, tid, pid, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp);
tmp->syscall_info = create_syscall_info(__NR_open, cpu_id, tid, -1);
tmp->files_history = create_file(tmp->files_history, file);
void *private_data)
{
const struct definition *scope;
- unsigned long timestamp;
- int64_t tid, pid;
struct processtop *tmp;
+ unsigned long timestamp;
+ int64_t tid;
+ char *procname;
int fd;
timestamp = bt_ctf_get_timestamp(call_data);
tid = get_context_tid(call_data);
- pid = get_context_pid(call_data);
+ procname = get_context_comm(call_data);
scope = bt_ctf_get_top_level_scope(call_data,
BT_EVENT_FIELDS);
goto error;
}
- tmp = get_proc_pid(<tngtop, tid, pid, timestamp);
+ tmp = get_proc(<tngtop, tid, procname, timestamp);
close_file(tmp, fd);
bt_ctf_iter_add_callback(iter,
g_quark_from_static_string("sched_process_free"),
NULL, 0, handle_sched_process_free, NULL, NULL, NULL);
+ /* to get all the process from the statedumps */
+ bt_ctf_iter_add_callback(iter,
+ g_quark_from_static_string(
+ "lttng_statedump_process_state"),
+ NULL, 0, handle_statedump_process_state,
+ NULL, NULL, NULL);
/* for IO top */
bt_ctf_iter_add_callback(iter,