Add logging to validation and serialization failure paths
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 15 Nov 2016 20:30:29 +0000 (15:30 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:06 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/fields.c

index 55af6d0a5b3c0506e6a7c1be74febd49c48f334a..04fba5cf22492d0d0534668cf325d04edec07740 100644 (file)
@@ -1641,6 +1641,7 @@ int bt_ctf_field_array_validate(struct bt_ctf_field *field)
        for (i = 0; i < array->elements->len; i++) {
                ret = bt_ctf_field_validate(array->elements->pdata[i]);
                if (ret) {
+                       fprintf(stderr, "Failed to validate sequence field #%zu\n", i);
                        goto end;
                }
        }
@@ -1664,7 +1665,7 @@ int bt_ctf_field_sequence_validate(struct bt_ctf_field *field)
        for (i = 0; i < sequence->elements->len; i++) {
                ret = bt_ctf_field_validate(sequence->elements->pdata[i]);
                if (ret) {
-                       fprintf(stderr, "Failed to validate sequence field %zu\n", i);
+                       fprintf(stderr, "Failed to validate sequence field #%zu\n", i);
                        goto end;
                }
        }
@@ -1940,6 +1941,15 @@ int bt_ctf_field_structure_serialize(struct bt_ctf_field *field,
 
                ret = bt_ctf_field_serialize(field, pos);
                if (ret) {
+                       const char *name;
+                       struct bt_ctf_field_type *field_type =
+                                       bt_ctf_field_get_type(field);
+
+                       (void) bt_ctf_field_type_structure_get_field(field_type,
+                                       &name, NULL, i);
+                       fprintf(stderr, "Field %s failed to serialize\n",
+                                       name ? name : "NULL");
+                       bt_put(field_type);
                        break;
                }
        }
@@ -1970,6 +1980,7 @@ int bt_ctf_field_array_serialize(struct bt_ctf_field *field,
                ret = bt_ctf_field_serialize(
                        g_ptr_array_index(array->elements, i), pos);
                if (ret) {
+                       fprintf(stderr, "Failed to serialize array element #%zu\n", i);
                        goto end;
                }
        }
@@ -1990,6 +2001,7 @@ int bt_ctf_field_sequence_serialize(struct bt_ctf_field *field,
                ret = bt_ctf_field_serialize(
                        g_ptr_array_index(sequence->elements, i), pos);
                if (ret) {
+                       fprintf(stderr, "Failed to serialize sequence element #%zu\n", i);
                        goto end;
                }
        }
This page took 0.027348 seconds and 4 git commands to generate.