function to extract cpu_id
[lttngtop.git] / src / common.c
index f0b7af064d6a6cd4cd954c88aff14f5d38e29e57..f628ed56d5961673017aef03c3f256913b23f080 100644 (file)
 #include <string.h>
 #include "common.h"
 
+uint64_t get_cpu_id(struct bt_ctf_event *event)
+{
+       struct 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;
+}
+
 struct processtop *find_process_tid(struct lttngtop *ctx, int tid, char *comm)
 {
        gint i;
This page took 0.022769 seconds and 4 git commands to generate.