src.ctf.fs: keep empty structures
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 11 Apr 2019 17:10:04 +0000 (13:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:39 +0000 (18:19 -0400)
If there's any empty structure in the original trace, keep it (create
an empty trace IR structure field class too).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
plugins/ctf/common/metadata/ctf-meta-translate.c
plugins/ctf/common/metadata/ctf-meta-update-in-ir.c

index 608db66fd95fd82493b6da8dd38bc0a9c7212b75..b116c0539119ff45840d52dc7a7d7aeda3f4ea63 100644 (file)
@@ -326,6 +326,16 @@ bool ctf_field_class_struct_has_immediate_member_in_ir(
        uint64_t i;
        bool has_immediate_member_in_ir = false;
 
+       /*
+        * If the structure field class has no members at all, then it
+        * was an empty structure in the beginning, so leave it existing
+        * and empty.
+        */
+       if (fc->members->len == 0) {
+               has_immediate_member_in_ir = true;
+               goto end;
+       }
+
        for (i = 0; i < fc->members->len; i++) {
                struct ctf_named_field_class *named_fc =
                        ctf_field_class_struct_borrow_member_by_index(fc, i);
index 0cb95cf7a82a9b1b124cfbd66eab94e59e16a2db..5ad71c85ba9b1fae84248c39df1518a6322e6cdd 100644 (file)
@@ -118,6 +118,14 @@ void update_field_class_in_ir(struct ctf_field_class *fc,
        {
                struct ctf_field_class_struct *struct_fc = (void *) fc;
 
+               /*
+                * Make it part of IR if it's empty because it was
+                * originally empty.
+                */
+               if (struct_fc->members->len == 0) {
+                       fc->in_ir = true;
+               }
+
                /* Reverse order */
                for (i = (int64_t) struct_fc->members->len - 1; i >= 0; i--) {
                        struct ctf_named_field_class *named_fc =
This page took 0.02633 seconds and 4 git commands to generate.