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-sou.c
          +++ new/usr/src/test/util-tests/tests/ctf/check-sou.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 handle structures and unions.
  18   18   */
  19   19  
  20   20  #include "check-common.h"
  21   21  
  22   22  static check_number_t check_bitfields[] = {
  23   23  #ifdef  TARGET_LP64
↓ open down ↓ 314 lines elided ↑ open up ↑
 338  338          { NULL }
 339  339  };
 340  340  
 341  341  static check_descent_t check_descent_forward[] = {
 342  342          { "const forward_t", CTF_K_CONST },
 343  343          { "forward_t", CTF_K_TYPEDEF },
 344  344          { "struct forward", CTF_K_STRUCT },
 345  345          { NULL }
 346  346  };
 347  347  
 348      -static check_descent_t check_descent_regress[] = {
      348 +static check_descent_test_t descents[] = {
      349 +        { "head", check_descent_head },
      350 +        { "forward", check_descent_forward },
      351 +        { NULL }
      352 +};
      353 +
      354 +static check_descent_t check_descent_regress_gcc4[] = {
 349  355          { "const union regress [9]", CTF_K_CONST },
 350  356          { "union regress [9]", CTF_K_ARRAY, "union regress", 9 },
 351  357          { "union regress", CTF_K_UNION },
 352  358          { NULL }
 353  359  };
 354  360  
 355      -static check_descent_test_t descents[] = {
 356      -        { "head", check_descent_head },
 357      -        { "forward", check_descent_forward },
 358      -        { "regress", check_descent_regress },
      361 +static check_descent_t check_descent_regress_gcc7[] = {
      362 +        { "const union regress [9]", CTF_K_ARRAY, "const union regress", 9 },
      363 +        { "const union regress", CTF_K_CONST },
      364 +        { "union regress", CTF_K_UNION },
 359  365          { NULL }
 360  366  };
 361  367  
      368 +/*
      369 + * See needed_array_qualifier(): applying this fix means the qualifier order is
      370 + * different between GCC versions. Accept either form.
      371 + */
      372 +static check_descent_test_t alt_descents[] = {
      373 +        { "regress", check_descent_regress_gcc4 },
      374 +        { "regress", check_descent_regress_gcc7 },
      375 +        { NULL }
      376 +};
      377 +
 362  378  int
 363  379  main(int argc, char *argv[])
 364  380  {
 365  381          int i, ret = 0;
 366  382  
 367  383          if (argc < 2) {
 368  384                  errx(EXIT_FAILURE, "missing test files");
 369  385          }
 370  386  
 371  387          for (i = 1; i < argc; i++) {
 372  388                  ctf_file_t *fp;
      389 +                int alt_ok = 0;
 373  390                  uint_t j;
 374  391  
 375  392                  if ((fp = ctf_open(argv[i], &ret)) == NULL) {
 376  393                          warnx("failed to open %s: %s", argv[i],
 377  394                              ctf_errmsg(ret));
 378  395                          ret = EXIT_FAILURE;
 379  396                          continue;
 380  397                  }
 381  398  
 382  399                  if (!ctftest_check_numbers(fp, check_bitfields))
 383  400                          ret = EXIT_FAILURE;
 384  401                  if (!ctftest_check_symbols(fp, check_syms))
 385  402                          ret = EXIT_FAILURE;
 386  403                  for (j = 0; descents[j].cdt_sym != NULL; j++) {
 387  404                          if (!ctftest_check_descent(descents[j].cdt_sym, fp,
 388      -                            descents[j].cdt_tests)) {
      405 +                            descents[j].cdt_tests, B_FALSE)) {
 389  406                                  ret = EXIT_FAILURE;
 390  407                          }
 391  408                  }
 392  409  
      410 +                for (j = 0; alt_descents[j].cdt_sym != NULL; j++) {
      411 +                        if (ctftest_check_descent(alt_descents[j].cdt_sym, fp,
      412 +                            alt_descents[j].cdt_tests, B_TRUE)) {
      413 +                                alt_ok = 1;
      414 +                                break;
      415 +                        }
      416 +                }
      417 +
      418 +                if (!alt_ok) {
      419 +                        warnx("all descents failed for %s",
      420 +                            alt_descents[0].cdt_sym);
      421 +                        ret = EXIT_FAILURE;
      422 +                }
      423 +
 393  424                  for (j = 0; members[j].cmt_type != NULL; j++) {
 394  425                          if (!ctftest_check_members(members[j].cmt_type, fp,
 395  426                              members[j].cmt_kind, members[j].cmt_size,
 396  427                              members[j].cmt_members)) {
 397  428                                  ret = EXIT_FAILURE;
 398  429                          }
 399  430                  }
 400  431  
 401  432                  ctf_close(fp);
 402  433          }
 403  434  
 404  435          return (ret);
 405  436  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX