wrapper to access context fields
[lttngtop.git] / src / iostreamtop.c
index a1c78a98a63e13329eaafd0b342727f3b5894cdd..4426d03c27ca243f32c52731114a4fd300018855 100644 (file)
@@ -101,7 +101,7 @@ void show_table(GPtrArray *tab)
 }
 
 int update_iostream_ret(struct lttngtop *ctx, int tid, char *comm,
-               unsigned long timestamp, int cpu_id, int ret)
+               unsigned long timestamp, uint64_t cpu_id, int ret)
 {
        struct processtop *tmp;
        struct files *tmpfile;
@@ -134,7 +134,7 @@ int update_iostream_ret(struct lttngtop *ctx, int tid, char *comm,
        return err;
 }
 
-struct syscalls *create_syscall_info(unsigned int type, unsigned int cpu_id,
+struct syscalls *create_syscall_info(unsigned int type, uint64_t cpu_id,
                unsigned int tid, int fd)
 {
        struct syscalls *syscall_info;
@@ -171,27 +171,14 @@ enum bt_cb_ret handle_exit_syscall(struct bt_ctf_event *call_data,
        unsigned long timestamp;
        char *comm;
        uint64_t ret, tid;
-       int64_t cpu_id;
+       uint64_t cpu_id;
 
        timestamp = bt_ctf_get_timestamp(call_data);
        if (timestamp == -1ULL)
                goto error;
 
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_EVENT_CONTEXT);
-       comm = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
-                               scope, "_procname"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing procname context info\n");
-               goto error;
-       }
-
-       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;
-       }
+       comm = get_context_comm(call_data);
+       tid = get_context_tid(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -202,14 +189,7 @@ enum bt_cb_ret handle_exit_syscall(struct bt_ctf_event *call_data,
                goto error;
        }
 
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_PACKET_CONTEXT);
-       cpu_id = bt_ctf_get_uint64(bt_ctf_get_field(call_data,
-                               scope, "cpu_id"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing cpu_id context info\n");
-               goto error;
-       }
+       cpu_id = get_cpu_id(call_data);
 
        /*
         * if we encounter an exit_syscall and
@@ -241,30 +221,9 @@ enum bt_cb_ret handle_sys_write(struct bt_ctf_event *call_data,
        if (timestamp == -1ULL)
                goto error;
 
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_EVENT_CONTEXT);
-       comm = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
-                               scope, "_procname"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing procname context info\n");
-               goto error;
-       }
-
-       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;
-       }
-
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_PACKET_CONTEXT);
-       cpu_id = bt_ctf_get_uint64(bt_ctf_get_field(call_data,
-                               scope, "cpu_id"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing cpu_id context info\n");
-               goto error;
-       }
+       comm = get_context_comm(call_data);
+       tid = get_context_tid(call_data);
+       cpu_id = get_cpu_id(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -301,30 +260,9 @@ enum bt_cb_ret handle_sys_read(struct bt_ctf_event *call_data,
        if (timestamp == -1ULL)
                goto error;
 
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_EVENT_CONTEXT);
-       comm = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
-                               scope, "_procname"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing procname context info\n");
-               goto error;
-       }
-
-       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;
-       }
-
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_PACKET_CONTEXT);
-       cpu_id = bt_ctf_get_uint64(bt_ctf_get_field(call_data,
-                               scope, "cpu_id"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing cpu_id context info\n");
-               goto error;
-       }
+       comm = get_context_comm(call_data);
+       tid = get_context_tid(call_data);
+       cpu_id = get_cpu_id(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -363,30 +301,9 @@ enum bt_cb_ret handle_sys_open(struct bt_ctf_event *call_data,
        if (timestamp == -1ULL)
                goto error;
 
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_EVENT_CONTEXT);
-       comm = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
-                               scope, "_procname"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing procname context info\n");
-               goto error;
-       }
-
-       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;
-       }
-
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_PACKET_CONTEXT);
-       cpu_id = bt_ctf_get_uint64(bt_ctf_get_field(call_data,
-                               scope, "cpu_id"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing cpu_id context info\n");
-               goto error;
-       }
+       comm = get_context_comm(call_data);
+       tid = get_context_tid(call_data);
+       cpu_id = get_cpu_id(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
@@ -423,21 +340,8 @@ enum bt_cb_ret handle_sys_close(struct bt_ctf_event *call_data,
        if (timestamp == -1ULL)
                goto error;
 
-       scope = bt_ctf_get_top_level_scope(call_data,
-                       BT_STREAM_EVENT_CONTEXT);
-       comm = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
-                               scope, "_procname"));
-       if (bt_ctf_field_get_error()) {
-               fprintf(stderr, "Missing procname context info\n");
-               goto error;
-       }
-
-       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;
-       }
+       comm = get_context_comm(call_data);
+       tid = get_context_tid(call_data);
 
        scope = bt_ctf_get_top_level_scope(call_data,
                        BT_EVENT_FIELDS);
This page took 0.024224 seconds and 4 git commands to generate.