git: 963f5dc7a306 - main - ctfconvert: Handle arrays of empty structs

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 31 Dec 2021 18:09:18 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=963f5dc7a30624e95d72fb7f87b8892651164e46

commit 963f5dc7a30624e95d72fb7f87b8892651164e46
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-12-31 17:55:01 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-12-31 17:55:01 +0000

    ctfconvert: Handle arrays of empty structs
    
    Members with such a type will legitimately have a size of zero, so don't
    emit a warning.
    
    PR:             260818
    Reviewed by:    bz
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33700
---
 cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
index 32c993e1e524..2d686e53fed1 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
@@ -1123,8 +1123,16 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
 			 */
 			if (mt->t_members == NULL)
 				continue;
-			if (mt->t_type == ARRAY && mt->t_ardef->ad_nelems == 0)
-				continue;
+			if (mt->t_type == ARRAY) {
+				if (mt->t_ardef->ad_nelems == 0)
+					continue;
+				mt = tdesc_basetype(mt->t_ardef->ad_contents);
+				if ((mt->t_flags & TDESC_F_RESOLVED) != 0 &&
+				    (mt->t_type == STRUCT ||
+				    mt->t_type == UNION) &&
+				    mt->t_members == NULL)
+					continue;
+			}
 			if ((mt->t_flags & TDESC_F_RESOLVED) != 0 &&
 			    (mt->t_type == STRUCT || mt->t_type == UNION))
 				continue;