From b2c863b0885b886f0290833848375c48f347e657 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 11 Apr 2019 13:10:04 -0400 Subject: [PATCH] src.ctf.fs: keep empty structures 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 --- plugins/ctf/common/metadata/ctf-meta-translate.c | 10 ++++++++++ plugins/ctf/common/metadata/ctf-meta-update-in-ir.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/plugins/ctf/common/metadata/ctf-meta-translate.c b/plugins/ctf/common/metadata/ctf-meta-translate.c index 608db66f..b116c053 100644 --- a/plugins/ctf/common/metadata/ctf-meta-translate.c +++ b/plugins/ctf/common/metadata/ctf-meta-translate.c @@ -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); diff --git a/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c b/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c index 0cb95cf7..5ad71c85 100644 --- a/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c +++ b/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c @@ -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 = -- 2.34.1