Print this page
10816 ctf_dwarf_convert_type() relies on un-initialized id
10817 ctfconvert -i option is mis-handled
10818 Improve ctfconvert error messages
10819 ctfconvert should handle empty dies
10820 ctfconvert -i never converts
10821 bad free in ctf_dwarf_init_die
10815 shouldn't build gcore.c as part of kmdb
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

*** 8,18 **** * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* ! * Copyright (c) 2015, Joyent, Inc. */ /* * Create CTF from extant debugging information */ --- 8,18 ---- * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* ! * Copyright (c) 2019, Joyent, Inc. */ /* * Create CTF from extant debugging information */
*** 67,82 **** va_start(ap, fmt); (void) vfprintf(stderr, fmt, ap); va_end(ap); } ! (void) fprintf(stderr, "Usage: %s [-is] [-j nthrs] [-l label | " "-L labelenv] [-o outfile] input\n" "\n" "\t-i ignore files not built partially from C sources\n" "\t-j use nthrs threads to perform the merge\n" "\t-k keep around original input file on failure\n" "\t-o copy input to outfile and add CTF\n" "\t-l set output container's label to specified value\n" "\t-L set output container's label to value from environment\n", ctfconvert_progname); } --- 67,83 ---- va_start(ap, fmt); (void) vfprintf(stderr, fmt, ap); va_end(ap); } ! (void) fprintf(stderr, "Usage: %s [-ims] [-j nthrs] [-l label | " "-L labelenv] [-o outfile] input\n" "\n" "\t-i ignore files not built partially from C sources\n" "\t-j use nthrs threads to perform the merge\n" "\t-k keep around original input file on failure\n" + "\t-m allow input to have missing debug info\n" "\t-o copy input to outfile and add CTF\n" "\t-l set output container's label to specified value\n" "\t-L set output container's label to value from environment\n", ctfconvert_progname); }
*** 257,282 **** ctf_file_t *ofp; long argj; char *eptr; char buf[4096]; boolean_t optx = B_FALSE; ctfconvert_progname = basename(argv[0]); ctfconvert_altexec(argv); ! while ((c = getopt(argc, argv, ":j:kl:L:o:iX")) != -1) { switch (c) { ! case 'k': ! keep = B_TRUE; break; - case 'l': - label = optarg; - break; - case 'L': - label = getenv(optarg); - break; case 'j': errno = 0; argj = strtol(optarg, &eptr, 10); if (errno != 0 || argj == LONG_MAX || argj > 1024 || *eptr != '\0') { --- 258,278 ---- ctf_file_t *ofp; long argj; char *eptr; char buf[4096]; boolean_t optx = B_FALSE; + boolean_t ignore_non_c = B_FALSE; ctfconvert_progname = basename(argv[0]); ctfconvert_altexec(argv); ! while ((c = getopt(argc, argv, ":ij:kl:L:mo:X")) != -1) { switch (c) { ! case 'i': ! ignore_non_c = B_TRUE; break; case 'j': errno = 0; argj = strtol(optarg, &eptr, 10); if (errno != 0 || argj == LONG_MAX || argj > 1024 || *eptr != '\0') {
*** 283,298 **** ctfconvert_fatal("invalid argument for -j: " "%s\n", optarg); } nthreads = (uint_t)argj; break; case 'o': outfile = optarg; break; - case 'i': - flags |= CTF_CONVERT_F_IGNNONC; - break; case 'X': optx = B_TRUE; break; case ':': ctfconvert_usage("Option -%c requires an operand\n", --- 279,303 ---- ctfconvert_fatal("invalid argument for -j: " "%s\n", optarg); } nthreads = (uint_t)argj; break; + case 'k': + keep = B_TRUE; + break; + case 'l': + label = optarg; + break; + case 'L': + label = getenv(optarg); + break; + case 'm': + flags |= CTF_ALLOW_MISSING_DEBUG; + break; case 'o': outfile = optarg; break; case 'X': optx = B_TRUE; break; case ':': ctfconvert_usage("Option -%c requires an operand\n",
*** 305,316 **** } argv += optind; argc -= optind; ! if (argc < 1) { ! ctfconvert_usage("Missing required input file\n"); return (CTFCONVERT_USAGE); } infile = argv[0]; if (elf_version(EV_CURRENT) == EV_NONE) --- 310,321 ---- } argv += optind; argc -= optind; ! if (argc != 1) { ! ctfconvert_usage("Exactly one input file is required\n"); return (CTFCONVERT_USAGE); } infile = argv[0]; if (elf_version(EV_CURRENT) == EV_NONE)
*** 332,355 **** ofp = ctf_fdconvert(ifd, label, nthreads, flags, &err, buf, sizeof (buf)); if (ofp == NULL) { /* ! * -i says that we shouldn't concern ourselves with source files ! * that weren't built from C source code in part. Because this ! * has been traditionally used across all of illumos, we still ! * honor it. */ ! if ((flags & CTF_CONVERT_F_IGNNONC) != 0 && ! err == ECTF_CONVNOCSRC) { exit(CTFCONVERT_OK); } if (keep == B_FALSE) (void) unlink(infile); ctfconvert_fatal("CTF conversion failed: %s\n", ! err == ECTF_CONVBKERR ? buf : ctf_errmsg(err)); } if (optx == B_TRUE) ctfconvert_fixup_genunix(ofp); tmpfile = NULL; --- 337,373 ---- ofp = ctf_fdconvert(ifd, label, nthreads, flags, &err, buf, sizeof (buf)); if (ofp == NULL) { /* ! * Normally, ctfconvert requires that its input file has at ! * least one C-source compilation unit, and that every C-source ! * compilation unit has DWARF. This is to avoid accidentally ! * leaving out useful CTF. ! * ! * However, for the benefit of intransigent build environments, ! * the -i and -m options can be used to relax this. */ ! if (err == ECTF_CONVNOCSRC && ignore_non_c) { exit(CTFCONVERT_OK); } + + if (err == ECTF_CONVNODEBUG && + (flags & CTF_ALLOW_MISSING_DEBUG) != 0) { + exit(CTFCONVERT_OK); + } + if (keep == B_FALSE) (void) unlink(infile); + + if (err == ECTF_CONVBKERR || err == ECTF_CONVNODEBUG) { + ctfconvert_fatal("%s", buf); + } else { ctfconvert_fatal("CTF conversion failed: %s\n", ! ctf_errmsg(err)); } + } if (optx == B_TRUE) ctfconvert_fixup_genunix(ofp); tmpfile = NULL;