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>
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2019, Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Check that we properly handle structures and unions.
  18  */
  19 
  20 #include "check-common.h"
  21 
  22 static check_number_t check_bitfields[] = {
  23 #ifdef  TARGET_LP64
  24         { "unsigned long:1", CTF_K_INTEGER, 0, 0, 1 },
  25         { "unsigned long:2", CTF_K_INTEGER,  0, 0, 2 },
  26         { "unsigned long:4", CTF_K_INTEGER,  0, 0, 4 },
  27         { "unsigned long:5", CTF_K_INTEGER,  0, 0, 5 },
  28         { "unsigned long:8", CTF_K_INTEGER,  0, 0, 8 },
  29         { "unsigned long:16", CTF_K_INTEGER,  0, 0, 16 },
  30         { "unsigned long:19", CTF_K_INTEGER,  0, 0, 19 },
  31         { "unsigned long:32", CTF_K_INTEGER,  0, 0, 32 },
  32 #else
  33         { "unsigned long long:1", CTF_K_INTEGER, 0, 0, 1 },


 328 #else
 329         { "struct trigger", CTF_K_STRUCT, 28, check_member_trigger },
 330         { "union regress", CTF_K_UNION, 12, check_member_regress },
 331 #endif
 332         { NULL }
 333 };
 334 
 335 static check_descent_t check_descent_head[] = {
 336         { "nlist_t", CTF_K_TYPEDEF },
 337         { "struct nlist", CTF_K_STRUCT },
 338         { NULL }
 339 };
 340 
 341 static check_descent_t check_descent_forward[] = {
 342         { "const forward_t", CTF_K_CONST },
 343         { "forward_t", CTF_K_TYPEDEF },
 344         { "struct forward", CTF_K_STRUCT },
 345         { NULL }
 346 };
 347 
 348 static check_descent_t check_descent_regress[] = {






 349         { "const union regress [9]", CTF_K_CONST },
 350         { "union regress [9]", CTF_K_ARRAY, "union regress", 9 },
 351         { "union regress", CTF_K_UNION },
 352         { NULL }
 353 };
 354 
 355 static check_descent_test_t descents[] = {
 356         { "head", check_descent_head },
 357         { "forward", check_descent_forward },
 358         { "regress", check_descent_regress },
 359         { NULL }
 360 };
 361 










 362 int
 363 main(int argc, char *argv[])
 364 {
 365         int i, ret = 0;
 366 
 367         if (argc < 2) {
 368                 errx(EXIT_FAILURE, "missing test files");
 369         }
 370 
 371         for (i = 1; i < argc; i++) {
 372                 ctf_file_t *fp;

 373                 uint_t j;
 374 
 375                 if ((fp = ctf_open(argv[i], &ret)) == NULL) {
 376                         warnx("failed to open %s: %s", argv[i],
 377                             ctf_errmsg(ret));
 378                         ret = EXIT_FAILURE;
 379                         continue;
 380                 }
 381 
 382                 if (!ctftest_check_numbers(fp, check_bitfields))
 383                         ret = EXIT_FAILURE;
 384                 if (!ctftest_check_symbols(fp, check_syms))
 385                         ret = EXIT_FAILURE;
 386                 for (j = 0; descents[j].cdt_sym != NULL; j++) {
 387                         if (!ctftest_check_descent(descents[j].cdt_sym, fp,
 388                             descents[j].cdt_tests)) {
 389                                 ret = EXIT_FAILURE;
 390                         }
 391                 }
 392 














 393                 for (j = 0; members[j].cmt_type != NULL; j++) {
 394                         if (!ctftest_check_members(members[j].cmt_type, fp,
 395                             members[j].cmt_kind, members[j].cmt_size,
 396                             members[j].cmt_members)) {
 397                                 ret = EXIT_FAILURE;
 398                         }
 399                 }
 400 
 401                 ctf_close(fp);
 402         }
 403 
 404         return (ret);
 405 }
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2019, Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Check that we properly handle structures and unions.
  18  */
  19 
  20 #include "check-common.h"
  21 
  22 static check_number_t check_bitfields[] = {
  23 #ifdef  TARGET_LP64
  24         { "unsigned long:1", CTF_K_INTEGER, 0, 0, 1 },
  25         { "unsigned long:2", CTF_K_INTEGER,  0, 0, 2 },
  26         { "unsigned long:4", CTF_K_INTEGER,  0, 0, 4 },
  27         { "unsigned long:5", CTF_K_INTEGER,  0, 0, 5 },
  28         { "unsigned long:8", CTF_K_INTEGER,  0, 0, 8 },
  29         { "unsigned long:16", CTF_K_INTEGER,  0, 0, 16 },
  30         { "unsigned long:19", CTF_K_INTEGER,  0, 0, 19 },
  31         { "unsigned long:32", CTF_K_INTEGER,  0, 0, 32 },
  32 #else
  33         { "unsigned long long:1", CTF_K_INTEGER, 0, 0, 1 },


 328 #else
 329         { "struct trigger", CTF_K_STRUCT, 28, check_member_trigger },
 330         { "union regress", CTF_K_UNION, 12, check_member_regress },
 331 #endif
 332         { NULL }
 333 };
 334 
 335 static check_descent_t check_descent_head[] = {
 336         { "nlist_t", CTF_K_TYPEDEF },
 337         { "struct nlist", CTF_K_STRUCT },
 338         { NULL }
 339 };
 340 
 341 static check_descent_t check_descent_forward[] = {
 342         { "const forward_t", CTF_K_CONST },
 343         { "forward_t", CTF_K_TYPEDEF },
 344         { "struct forward", CTF_K_STRUCT },
 345         { NULL }
 346 };
 347 
 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[] = {
 355         { "const union regress [9]", CTF_K_CONST },
 356         { "union regress [9]", CTF_K_ARRAY, "union regress", 9 },
 357         { "union regress", CTF_K_UNION },
 358         { NULL }
 359 };
 360 
 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 },
 365         { NULL }
 366 };
 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 
 378 int
 379 main(int argc, char *argv[])
 380 {
 381         int i, ret = 0;
 382 
 383         if (argc < 2) {
 384                 errx(EXIT_FAILURE, "missing test files");
 385         }
 386 
 387         for (i = 1; i < argc; i++) {
 388                 ctf_file_t *fp;
 389                 int alt_ok = 0;
 390                 uint_t j;
 391 
 392                 if ((fp = ctf_open(argv[i], &ret)) == NULL) {
 393                         warnx("failed to open %s: %s", argv[i],
 394                             ctf_errmsg(ret));
 395                         ret = EXIT_FAILURE;
 396                         continue;
 397                 }
 398 
 399                 if (!ctftest_check_numbers(fp, check_bitfields))
 400                         ret = EXIT_FAILURE;
 401                 if (!ctftest_check_symbols(fp, check_syms))
 402                         ret = EXIT_FAILURE;
 403                 for (j = 0; descents[j].cdt_sym != NULL; j++) {
 404                         if (!ctftest_check_descent(descents[j].cdt_sym, fp,
 405                             descents[j].cdt_tests, B_FALSE)) {
 406                                 ret = EXIT_FAILURE;
 407                         }
 408                 }
 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 
 424                 for (j = 0; members[j].cmt_type != NULL; j++) {
 425                         if (!ctftest_check_members(members[j].cmt_type, fp,
 426                             members[j].cmt_kind, members[j].cmt_size,
 427                             members[j].cmt_members)) {
 428                                 ret = EXIT_FAILURE;
 429                         }
 430                 }
 431 
 432                 ctf_close(fp);
 433         }
 434 
 435         return (ret);
 436 }