Fix warnings and use right decl instead of definition after API change
authorYannick Brosseau <yannick.brosseau@gmail.com>
Mon, 5 Nov 2012 22:03:45 +0000 (17:03 -0500)
committerYannick Brosseau <yannick.brosseau@gmail.com>
Mon, 5 Nov 2012 22:03:45 +0000 (17:03 -0500)
Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
lttv/lttv/event.c
lttv/lttv/print.c

index 8c1b6d8021e359af29ccba2d1c3f15b932324325..2f26274ca83e8f351e7688e1cebdb736a62e6755 100644 (file)
@@ -13,7 +13,7 @@ LttTime lttv_event_get_timestamp(LttvEvent *event)
 //TODO ybrosseau find a way to return an error code
 unsigned long lttv_event_get_long_unsigned(LttvEvent *event, const char* field)
 {
-       struct definition *scope;
+       const struct definition *scope;
        unsigned long timestamp;
        unsigned long data;
        struct bt_ctf_event *ctf_event = event->bt_event;
@@ -38,30 +38,44 @@ unsigned long lttv_event_get_long_unsigned(LttvEvent *event, const char* field)
 
 char* lttv_event_get_string(LttvEvent *event, const char* field)
 {
-       struct definition *scope;
+       const struct definition *scope;
        unsigned long timestamp;
        char* data;
        struct bt_ctf_event *ctf_event = event->bt_event;
 
        timestamp = bt_ctf_get_timestamp(ctf_event);
        if (timestamp == -1ULL) {
+               printf("ERROR: lttv_event_get_string - cannot read timestamps");
                return 0;
        }
        //scope = bt_ctf_get_top_level_scope(ctf_event, BT_STREAM_PACKET_CONTEXT);
        scope = bt_ctf_get_top_level_scope(ctf_event, BT_EVENT_FIELDS);
        if (bt_ctf_field_get_error()) {
+               printf("ERROR: lttv_event_get_string - cannot get field scope");
                return 0;
        }
        data = bt_ctf_get_char_array(bt_ctf_get_field(ctf_event, scope, field));
        if (bt_ctf_field_get_error()) {
-               return 0;
+               // Try get_string if we fail on char_array
+               // TODO ybrosseau: properly detect right type
+               data = bt_ctf_get_string(bt_ctf_get_field(ctf_event, scope, field));
+               if (bt_ctf_field_get_error()) {
+                       
+
+                       printf("ERROR: lttv_event_get_string - cannot get field data %s", field);
+
+                       return 0;
+               } else {
+                       return data;
+               }
+               
        } else {
                return data;
        }
 }
 long lttv_event_get_long(LttvEvent *event, const char* field)
 {
-       struct definition *scope;
+       const struct definition *scope;
        unsigned long timestamp;
        long data;
        struct bt_ctf_event *ctf_event = event->bt_event;
index 758f7af30a51930f2d6f6b54a0e67346447a3b1a..a8de92df4b286cca517e130637cc56052de01e5f 100644 (file)
@@ -264,8 +264,8 @@ void lttv_print_field(LttEvent *e, struct marker_field *f, GString *s,
 int getProcessInfosFromEvent(LttvEvent *event, GString* processInfos)
 {
        int pid=0, tid=0, ppid=0;
-       char *procname;
-       struct definition *scope;
+       const char *procname;
+
        unsigned long timestamp;
 
        int ret = 0;
@@ -347,12 +347,12 @@ int getCPUIdFromEvent(LttvEvent *event, GString* cpuId_str)
 
 int getFields(struct bt_ctf_event *ctf_event, struct definition const *fields, GString* fieldsStr)
 {
-       enum ctf_type_id fieldType = bt_ctf_field_type(fields);
+       enum ctf_type_id fieldType = bt_ctf_field_type(bt_ctf_get_decl_from_def(fields));
        int ret = 0, isSigned = -1, len = 0, i = 0;
-       struct definition *index_def;
+       const struct definition *index_def; 
        switch (fieldType) {
        case CTF_TYPE_INTEGER:
-               isSigned = bt_ctf_get_int_signedness(fields);
+               isSigned = bt_ctf_get_int_signedness(bt_ctf_get_decl_from_def(fields));
                if (isSigned == 1) {
                        g_string_append_printf(fieldsStr, "%lu", bt_ctf_get_int64(fields));
                }
@@ -366,15 +366,15 @@ int getFields(struct bt_ctf_event *ctf_event, struct definition const *fields, G
 
        case CTF_TYPE_ARRAY:
                g_string_append_printf(fieldsStr, "[ ");
-               len = bt_ctf_get_array_len(fields);
-               if (index_def = bt_ctf_get_index(ctf_event, fields, i)) {
+               len = bt_ctf_get_array_len(bt_ctf_get_decl_from_def(fields));
+               if ((index_def = bt_ctf_get_index(ctf_event, fields, i))) {
                        for (i = 0; i < len; i++) {
                                if (i > 0) {
                                        g_string_append_printf(fieldsStr, ", ");
                                }
-                               bt_ctf_field_type(bt_ctf_get_index(ctf_event, fields, i));
+                               //bt_ctf_field_type( bt_ctf_get_index(ctf_event, fields, i));
                                g_string_append_printf(fieldsStr, " ");
-                               g_string_append_printf(fieldsStr, "[%d] = ");
+                               g_string_append_printf(fieldsStr, "[%d] = ",i);
                                getFields(ctf_event, bt_ctf_get_index(ctf_event, fields, i), fieldsStr);
                        }
                }
@@ -385,7 +385,9 @@ int getFields(struct bt_ctf_event *ctf_event, struct definition const *fields, G
 
                break;
        case CTF_TYPE_UNKNOWN:
+               g_string_append_printf(fieldsStr, "TYPE UNKNOWN");
        default:
+               g_string_append_printf(fieldsStr, "TYPE UNIMP %i",fieldType );
                break;
        }
        return ret;
@@ -395,9 +397,9 @@ int getFieldsFromEvent(struct bt_ctf_event *ctf_event, GString* fields, gboolean
 {
        struct definition const * const *list = NULL;
        unsigned int count;
-       int i = 0, j = 0, ret = 0;
+       int i = 0, ret = 0;
        gboolean noError = TRUE;
-       struct definition *scope;
+       const struct definition *scope;
        scope = bt_ctf_get_top_level_scope(ctf_event, BT_EVENT_FIELDS);
 
        if (!scope) {
This page took 0.026241 seconds and 4 git commands to generate.