Print this page
10823 should ignore DW_TAG_subprogram with DW_AT_declaration tags
10824 GCC7-derived CTF can double qualifiers on arrays
10825 ctfdump -c drops last type
10826 ctfdump -c goes off the rails with a missing parent
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Jason King <jason.king@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>

@@ -8,11 +8,11 @@
  * source.  A copy of the CDDL is also available via the Internet at
  * http://www.illumos.org/license/CDDL.
  */
 
 /*
- * Copyright (c) 2019, Joyent, Inc.
+ * Copyright 2019, Joyent, Inc.
  */
 
 /*
  * Check that we properly handle structures and unions.
  */

@@ -343,24 +343,40 @@
         { "forward_t", CTF_K_TYPEDEF },
         { "struct forward", CTF_K_STRUCT },
         { NULL }
 };
 
-static check_descent_t check_descent_regress[] = {
+static check_descent_test_t descents[] = {
+        { "head", check_descent_head },
+        { "forward", check_descent_forward },
+        { NULL }
+};
+
+static check_descent_t check_descent_regress_gcc4[] = {
         { "const union regress [9]", CTF_K_CONST },
         { "union regress [9]", CTF_K_ARRAY, "union regress", 9 },
         { "union regress", CTF_K_UNION },
         { NULL }
 };
 
-static check_descent_test_t descents[] = {
-        { "head", check_descent_head },
-        { "forward", check_descent_forward },
-        { "regress", check_descent_regress },
+static check_descent_t check_descent_regress_gcc7[] = {
+        { "const union regress [9]", CTF_K_ARRAY, "const union regress", 9 },
+        { "const union regress", CTF_K_CONST },
+        { "union regress", CTF_K_UNION },
         { NULL }
 };
 
+/*
+ * See needed_array_qualifier(): applying this fix means the qualifier order is
+ * different between GCC versions. Accept either form.
+ */
+static check_descent_test_t alt_descents[] = {
+        { "regress", check_descent_regress_gcc4 },
+        { "regress", check_descent_regress_gcc7 },
+        { NULL }
+};
+
 int
 main(int argc, char *argv[])
 {
         int i, ret = 0;
 

@@ -368,10 +384,11 @@
                 errx(EXIT_FAILURE, "missing test files");
         }
 
         for (i = 1; i < argc; i++) {
                 ctf_file_t *fp;
+                int alt_ok = 0;
                 uint_t j;
 
                 if ((fp = ctf_open(argv[i], &ret)) == NULL) {
                         warnx("failed to open %s: %s", argv[i],
                             ctf_errmsg(ret));

@@ -383,15 +400,29 @@
                         ret = EXIT_FAILURE;
                 if (!ctftest_check_symbols(fp, check_syms))
                         ret = EXIT_FAILURE;
                 for (j = 0; descents[j].cdt_sym != NULL; j++) {
                         if (!ctftest_check_descent(descents[j].cdt_sym, fp,
-                            descents[j].cdt_tests)) {
+                            descents[j].cdt_tests, B_FALSE)) {
                                 ret = EXIT_FAILURE;
                         }
                 }
 
+                for (j = 0; alt_descents[j].cdt_sym != NULL; j++) {
+                        if (ctftest_check_descent(alt_descents[j].cdt_sym, fp,
+                            alt_descents[j].cdt_tests, B_TRUE)) {
+                                alt_ok = 1;
+                                break;
+                        }
+                }
+
+                if (!alt_ok) {
+                        warnx("all descents failed for %s",
+                            alt_descents[0].cdt_sym);
+                        ret = EXIT_FAILURE;
+                }
+
                 for (j = 0; members[j].cmt_type != NULL; j++) {
                         if (!ctftest_check_members(members[j].cmt_type, fp,
                             members[j].cmt_kind, members[j].cmt_size,
                             members[j].cmt_members)) {
                                 ret = EXIT_FAILURE;