+uint64_t get_cpu_id(const struct bt_ctf_event *event)
+{
+ const struct bt_definition *scope;
+ uint64_t cpu_id;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_PACKET_CONTEXT);
+ cpu_id = bt_ctf_get_uint64(bt_ctf_get_field(event, scope, "cpu_id"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "[error] get cpu_id\n");
+ return -1ULL;
+ }
+
+ return cpu_id;
+}
+
+uint64_t get_context_tid(const struct bt_ctf_event *event)
+{
+ const struct bt_definition *scope;
+ uint64_t tid;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
+ 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;
+ }
+
+ return tid;
+}
+
+uint64_t get_context_pid(const struct bt_ctf_event *event)
+{
+ const struct bt_definition *scope;
+ uint64_t pid;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
+ 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;
+ }
+
+ return pid;
+}
+
+uint64_t get_context_ppid(const struct bt_ctf_event *event)
+{
+ const struct bt_definition *scope;
+ uint64_t ppid;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
+ 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;
+ }
+
+ return ppid;
+}
+
+uint64_t get_context_vtid(const struct bt_ctf_event *event)
+{
+ const struct definition *scope;
+ uint64_t vtid;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
+ vtid = bt_ctf_get_int64(bt_ctf_get_field(event,
+ scope, "_vtid"));
+ if (bt_ctf_field_get_error()) {
+ return -1ULL;
+ }
+
+ return vtid;
+}
+
+uint64_t get_context_vpid(const struct bt_ctf_event *event)
+{
+ const struct definition *scope;
+ uint64_t vpid;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
+ vpid = bt_ctf_get_int64(bt_ctf_get_field(event,
+ scope, "_vpid"));
+ if (bt_ctf_field_get_error()) {
+ return -1ULL;
+ }
+
+ return vpid;
+}
+
+uint64_t get_context_vppid(const struct bt_ctf_event *event)
+{
+ const struct definition *scope;
+ uint64_t vppid;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
+ vppid = bt_ctf_get_int64(bt_ctf_get_field(event,
+ scope, "_vppid"));
+ if (bt_ctf_field_get_error()) {
+ return -1ULL;
+ }
+
+ return vppid;
+}
+
+char *get_context_comm(const struct bt_ctf_event *event)
+{
+ const struct bt_definition *scope;
+ char *comm;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
+ comm = bt_ctf_get_char_array(bt_ctf_get_field(event,
+ scope, "_procname"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing comm context info\n");
+ return NULL;
+ }
+
+ return comm;
+}
+
+/*
+ * To get the parent process, put the pid in the tid field
+ * because the parent process gets pid = tid
+ */