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>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/util-tests/tests/ctf/check-reference.c
          +++ new/usr/src/test/util-tests/tests/ctf/check-reference.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright (c) 2019, Joyent, Inc.
       13 + * Copyright 2019, Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * Check that we properly understand reference types and can walk through them
  18   18   * as well as generate them.
  19   19   */
  20   20  
  21   21  #include "check-common.h"
  22   22  
  23   23  static check_number_t check_base[] = {
↓ open down ↓ 100 lines elided ↑ open up ↑
 124  124  };
 125  125  
 126  126  static check_descent_t check_descent_g[] = {
 127  127          { "const char *const", CTF_K_CONST },
 128  128          { "const char *", CTF_K_POINTER },
 129  129          { "const char", CTF_K_CONST },
 130  130          { "char", CTF_K_INTEGER },
 131  131          { NULL }
 132  132  };
 133  133  
 134      -static check_descent_t check_descent_cvh[] = {
 135      -        { "const volatile foo_t *", CTF_K_POINTER },
 136      -        { "const volatile foo_t", CTF_K_CONST },
 137      -        { "volatile foo_t", CTF_K_VOLATILE },
 138      -        { "foo_t", CTF_K_TYPEDEF },
 139      -        { "int *const *", CTF_K_POINTER },
 140      -        { "int *const", CTF_K_CONST },
 141      -        { "int *", CTF_K_POINTER },
 142      -        { "int", CTF_K_INTEGER },
 143      -        { NULL }
 144      -};
 145      -
 146  134  static check_descent_test_t descents[] = {
 147  135          { "aa", check_descent_aa },
 148  136          { "b", check_descent_b },
 149  137          { "c", check_descent_c },
 150  138          { "d", check_descent_d },
 151  139          { "dd", check_descent_dd },
 152  140          { "ddd", check_descent_ddd },
 153  141          { "e", check_descent_e },
 154  142          { "ce", check_descent_ce },
 155  143          { "ve", check_descent_ve },
 156  144          { "cve", check_descent_cve },
 157  145          { "f", check_descent_f },
 158  146          { "g", check_descent_g },
 159      -        { "cvh", check_descent_cvh },
 160  147          { NULL }
 161  148  };
 162  149  
      150 +static check_descent_t check_descent_cvh_gcc4[] = {
      151 +        { "const volatile foo_t *", CTF_K_POINTER },
      152 +        { "const volatile foo_t", CTF_K_CONST },
      153 +        { "volatile foo_t", CTF_K_VOLATILE },
      154 +        { "foo_t", CTF_K_TYPEDEF },
      155 +        { "int *const *", CTF_K_POINTER },
      156 +        { "int *const", CTF_K_CONST },
      157 +        { "int *", CTF_K_POINTER },
      158 +        { "int", CTF_K_INTEGER },
      159 +        { NULL }
      160 +};
      161 +
      162 +static check_descent_t check_descent_cvh_gcc7[] = {
      163 +        { "volatile const foo_t *", CTF_K_POINTER },
      164 +        { "volatile const foo_t", CTF_K_VOLATILE },
      165 +        { "const foo_t", CTF_K_CONST },
      166 +        { "foo_t", CTF_K_TYPEDEF },
      167 +        { "int *const *", CTF_K_POINTER },
      168 +        { "int *const", CTF_K_CONST },
      169 +        { "int *", CTF_K_POINTER },
      170 +        { "int", CTF_K_INTEGER },
      171 +        { NULL }
      172 +};
      173 +
      174 +/*
      175 + * GCC versions differ in how they order qualifiers, which is a shame for
      176 + * round-tripping; but as they're clearly both valid, we should cope.  We'll
      177 + * just insist that at least one of these checks passes.
      178 + */
      179 +static check_descent_test_t alt_descents[] = {
      180 +        { "cvh", check_descent_cvh_gcc4 },
      181 +        { "cvh", check_descent_cvh_gcc7 },
      182 +};
      183 +
 163  184  int
 164  185  main(int argc, char *argv[])
 165  186  {
 166  187          int i, ret = 0;
 167  188  
 168  189          if (argc < 2) {
 169  190                  errx(EXIT_FAILURE, "missing test files");
 170  191          }
 171  192  
 172  193          for (i = 1; i < argc; i++) {
 173  194                  ctf_file_t *fp;
      195 +                int alt_ok = 0;
 174  196                  uint_t d;
 175  197  
 176  198                  if ((fp = ctf_open(argv[i], &ret)) == NULL) {
 177  199                          warnx("failed to open %s: %s", argv[i],
 178  200                              ctf_errmsg(ret));
 179  201                          ret = EXIT_FAILURE;
 180  202                          continue;
 181  203                  }
 182  204  
 183  205                  if (!ctftest_check_numbers(fp, check_base))
 184  206                          ret = EXIT_FAILURE;
 185  207                  if (!ctftest_check_symbols(fp, check_syms))
 186  208                          ret = EXIT_FAILURE;
 187  209                  for (d = 0; descents[d].cdt_sym != NULL; d++) {
 188  210                          if (!ctftest_check_descent(descents[d].cdt_sym, fp,
 189      -                            descents[d].cdt_tests)) {
      211 +                            descents[d].cdt_tests, B_FALSE)) {
 190  212                                  ret = EXIT_FAILURE;
 191  213                          }
 192  214                  }
      215 +
      216 +                for (d = 0; alt_descents[d].cdt_sym != NULL; d++) {
      217 +                        if (ctftest_check_descent(alt_descents[d].cdt_sym, fp,
      218 +                            alt_descents[d].cdt_tests, B_TRUE)) {
      219 +                                alt_ok = 1;
      220 +                                break;
      221 +                        }
      222 +                }
      223 +
      224 +                if (!alt_ok) {
      225 +                        warnx("all descents failed for %s",
      226 +                            alt_descents[0].cdt_sym);
      227 +                        ret = EXIT_FAILURE;
      228 +                }
      229 +
 193  230                  ctf_close(fp);
 194  231          }
 195  232  
 196  233          return (ret);
 197  234  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX