diff options
author | Andy Fiddaman <omnios@citrus-it.co.uk> | 2020-12-04 11:41:39 +0000 |
---|---|---|
committer | Andy Fiddaman <omnios@citrus-it.co.uk> | 2020-12-17 21:18:56 +0000 |
commit | 88a08813800ed7ba7c927986421cee437f7f2233 (patch) | |
tree | 5ee2cc36e4a8aa6c6f35f47268f4912f1ab44b08 /usr/src/cmd/ctfconvert | |
parent | 3dd4cd56e7843e01a8ab147a0d102cd4f6d732c1 (diff) | |
download | illumos-joyent-88a08813800ed7ba7c927986421cee437f7f2233.tar.gz |
13363 ctfconvert could support more granular ignore for missing debug data
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Rich Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/cmd/ctfconvert')
-rw-r--r-- | usr/src/cmd/ctfconvert/ctfconvert.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/usr/src/cmd/ctfconvert/ctfconvert.c b/usr/src/cmd/ctfconvert/ctfconvert.c index 064e665c26..121f1ed875 100644 --- a/usr/src/cmd/ctfconvert/ctfconvert.c +++ b/usr/src/cmd/ctfconvert/ctfconvert.c @@ -82,7 +82,7 @@ ctfconvert_usage(const char *fmt, ...) (void) fprintf(stderr, "Usage: %s [-fikms] [-j nthrs] [-l label | " "-L labelenv] [-b batchsize]\n" - " [-o outfile] input\n" + " [-o outfile] [-M ignorefile] input\n" "\n" "\t-b batch process this many dies at a time (default %d)\n" "\t-f always attempt to convert files\n" @@ -92,6 +92,7 @@ ctfconvert_usage(const char *fmt, ...) "\t-l set output container's label to specified value\n" "\t-L set output container's label to value from environment\n" "\t-m allow input to have missing debug info\n" + "\t-M allow files listed in ignorefile to have missing debug\n" "\t-o copy input to outfile and add CTF\n" "\t-s allow truncation of data that cannot be fully converted\n", ctfconvert_progname, @@ -250,6 +251,7 @@ main(int argc, char *argv[]) const char *outfile = NULL; const char *label = NULL; const char *infile = NULL; + const char *ignorefile = NULL; char *tmpfile; ctf_file_t *ofp; char buf[4096] = ""; @@ -259,7 +261,7 @@ main(int argc, char *argv[]) ctfconvert_progname = basename(argv[0]); - while ((c = getopt(argc, argv, ":b:fij:kl:L:mo:sX")) != -1) { + while ((c = getopt(argc, argv, ":b:fij:kl:L:mM:o:sX")) != -1) { switch (c) { case 'b': { long argno; @@ -303,6 +305,9 @@ main(int argc, char *argv[]) case 'm': flags |= CTF_ALLOW_MISSING_DEBUG; break; + case 'M': + ignorefile = optarg; + break; case 'o': outfile = optarg; break; @@ -370,6 +375,40 @@ main(int argc, char *argv[]) ctfconvert_fatal("Could not set warning callback: %s\n", strerror(err)); + if (ignorefile != NULL) { + char *buf = NULL; + ssize_t cnt; + size_t len = 0; + FILE *fp; + + if ((fp = fopen(ignorefile, "r")) == NULL) { + ctfconvert_fatal("Could not open ignorefile '%s': %s\n", + ignorefile, strerror(errno)); + } + + while ((cnt = getline(&buf, &len, fp)) != -1) { + char *p = buf; + + if (cnt == 0 || *p == '#') + continue; + + (void) strsep(&p, "\n"); + if ((err = ctf_convert_add_ignore(cch, buf)) != 0) { + ctfconvert_fatal( + "Failed to add '%s' to ignore list: %s\n", + buf, strerror(err)); + } + } + free(buf); + if (cnt == -1 && ferror(fp) != 0) { + ctfconvert_fatal( + "Error reading from ignorefile '%s': %s\n", + ignorefile, strerror(errno)); + } + + (void) fclose(fp); + } + ofp = ctf_fdconvert(cch, ifd, &err, buf, sizeof (buf)); ctf_convert_fini(cch); |