git: ed0748f1a8fa - stable/13 - ctfconvert: Handle arrays of empty structs

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 07 Jan 2022 14:03:26 UTC
The branch stable/13 has been updated by markj:

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

commit ed0748f1a8fa064bea81c0c0068e78aa69ee5b0a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-12-31 17:55:01 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-01-07 14:03:02 +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
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 963f5dc7a30624e95d72fb7f87b8892651164e46)
---
 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;