diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/tools/lintdump/lintdump.1 | 50 | ||||
-rw-r--r-- | usr/src/tools/lintdump/lintdump.c | 89 | ||||
-rwxr-xr-x | usr/src/tools/scripts/wsdiff.py | 6 |
3 files changed, 81 insertions, 64 deletions
diff --git a/usr/src/tools/lintdump/lintdump.1 b/usr/src/tools/lintdump/lintdump.1 index 4eaa59ba80..3bbe7d3b07 100644 --- a/usr/src/tools/lintdump/lintdump.1 +++ b/usr/src/tools/lintdump/lintdump.1 @@ -18,29 +18,37 @@ .\" " .\" " CDDL HEADER END .\" " -.\" "Copyright 2007 Sun Microsystems, Inc. All rights reserved. -.\" "Use is subject to license terms." -.TH lintdump 1 "28 Jun 2007" +.\" "Copyright 2008 Sun Microsystems, Inc. All rights reserved. +.\" "Use is subject to license terms. +.TH lintdump 1 "28 Mar 2008" .I lintdump -\- dump the contents of one or more lint libraries +\- dump the contents of one or more lint objects .SH SYNOPSIS -\fBlintdump [-i] [-p 1|2|3] [-r] \fIlintlib\fP [ \fIlintlib\fP ... ] +\fBlintdump [-i] [-p 1|2|3] [-r] \fIlintobj\fP [ \fIlintobj\fP ... ] .LP .SH DESCRIPTION .IX "OS-Net build tools" "lintdump" "" "\fBlintdump\fP" .LP The lintdump utility dumps the contents of one or more lint -libraries. This is chiefly useful when trying to understand the cause of +objects. This is chiefly useful when trying to understand the cause of unexpected or obtuse lint warnings (see EXAMPLES), but can also be used to -find differences between lint libraries across builds or releases, or to +find differences between lint objects across builds or releases, or to debug problems in lint itself. .LP -A lint library is a binary object constructed using the "-o" option to -lint(1). The format of a lint library is unstable and subject to change -at any time, but its current structure is summarized here in order to aid -in understanding the current output of lintdump. A lint library is +A lint object is a binary file (typically suffixed with ".ln") constructed +from a C source file via the "-c" option to lint(1). Multiple lint +objects may be combined into a lint library object (typically prefixed +with "llib-l" and suffixed with ".ln") using the "-o" option to lint. (As +a convenience, lint "-o" allows a lint library object to be built directly +from C source files). The lintdump utility is capable of dumping both +traditional lint objects and lint library objects. +.LP +The format of a lint object is unstable and subject to change at any time, +but its current structure is summarized here in order to aid in +understanding the current output of lintdump. A lint object consists of +one or more lint modules (one per C source file). Each lint module consists of a header and four sections, called PASS1, PASS2, PASS3, and -STRINGS. Generally speaking, PASS1 contains definitions, PASS2 contains +STRINGS. Generally speaking, PASS1 contains definitions, PASS2 contains declarations, and PASS3 contains information on whether or how functions or variables are used. The STRINGS section holds the strings for printf(3C)/scanf(3C) checking. @@ -50,7 +58,7 @@ types. The sequence of records is further partitioned by FILE records, which indicate the source or header file that is responsible for the records that follow. The remaining record types provide lint with information about the functions, variables, and structures defined or used -by the library. +by the object. .SH OPTIONS .TP 10 .B -i @@ -64,10 +72,12 @@ Output records using relative paths (see EXAMPLES). .LP .SH OUTPUT .LP -The contents of each specified \fIlintlib\fP is dumped in command-line -order. For each \fIlintlib\fP, lintdump outputs a single line beginning -with "LINTLIB:" that provides its name, module ID, the size of its PASS1, -PASS2, PASS3, STRING sections, and its total size, in that order. +The contents of each specified \fIlintobj\fP is dumped in command-line +order. For each \fIlintobj\fP, lintdump outputs a single line beginning +with "LINTOBJ:" that provides its name. For each lint module within that +object, lintdump outputs a single line beginning with "LINTMOD:" that +provides its module ID, the size of its PASS1, PASS2, PASS3, STRING +sections, and its total size, in that order. .LP Next, unless the -p option is used, the contents of the PASS1, PASS2, and PASS3 sections are dumped, in order. Before each section is dumped, @@ -262,7 +272,7 @@ struct msghdr { }; .fi .LP -Another use of lintdump is to compare two versions of a lint library to +Another use of lintdump is to compare two versions of a lint object to see whether anything of significance has changed. For instance, lintdump can be used to understand why a lint library is different between a project gate and a patch gate, and thus to determine whether the library @@ -310,4 +320,6 @@ can be bundled with Sun Studio. As such, any use of this utility in scripts or embedded inside programs should be done with knowledge that subsequent changes will be required in order to transition to the stable solution. - +.LP +The lint object file format does not have a way to represent bitfields. As +such, bitfield size information cannot be displayed by lintdump. diff --git a/usr/src/tools/lintdump/lintdump.c b/usr/src/tools/lintdump/lintdump.c index 628ccb1cb0..cf00b76d4e 100644 --- a/usr/src/tools/lintdump/lintdump.c +++ b/usr/src/tools/lintdump/lintdump.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -63,7 +63,7 @@ static void die(const char *, ...); static void usage(void); static void indent(void); static void unindent(void); -static void print_lintlib(const char *, FILE *, FLENS *); +static void print_lintmod(const char *, FILE *, FLENS *); static void print_pass(const char *, FILE *); static void print_atype(ATYPE *, int, ATYPE *, const char *); static void print_mods(const char *, ATYPE *, int, ATYPE *, uint_t); @@ -76,9 +76,10 @@ static lsu_t *lsu_lookup(unsigned long); int main(int argc, char **argv) { - int i, c; - FILE *fp; - FLENS hdr; + int i, c, mod; + FILE *fp; + FLENS hdr; + const char *lnname; progname = strrchr(argv[0], '/'); if (progname == NULL) @@ -114,69 +115,69 @@ main(int argc, char **argv) continue; } - if (fread(&hdr, sizeof (hdr), 1, fp) < 1) { - warn("%s: cannot read lint library header\n", argv[i]); - (void) fclose(fp); - continue; - } - - if (hdr.ver != LINTVER) { - warn("%s: lint library version %d unsupported\n", - argv[i], hdr.ver); - (void) fclose(fp); - continue; - } + lnname = argv[i]; + if (justrelpaths && lnname[0] == '/') + lnname = strrchr(lnname, '/') + 1; /* - * First build the table of structure/union names, then seek - * back to the start and print the lint library. Finally, - * empty the table out before dumping the next library. + * Dump out all of the modules in the lint object. */ - lsu_build(fp); - (void) fseek(fp, sizeof (hdr), SEEK_SET); - print_lintlib(argv[i], fp, &hdr); + for (mod = 1; fread(&hdr, sizeof (hdr), 1, fp) == 1; mod++) { + if (hdr.ver != LINTVER) { + warn("%s: unsupported lint object version " + "%d\n", argv[i], hdr.ver); + break; + } + + if (mod == 1) + infohdr("LINTOBJ", "%s\n", lnname); + + /* + * First build the table of structure/union names, + * then print the lint module. Finally, empty the + * table out before dumping the next module. + */ + lsu_build(fp); + print_lintmod(lnname, fp, &hdr); + lsu_empty(); + } (void) fclose(fp); - lsu_empty(); } return (EXIT_SUCCESS); } /* - * Print a lint library. + * Print a lint module and advance past it in the stream. */ static void -print_lintlib(const char *lnname, FILE *fp, FLENS *hp) +print_lintmod(const char *lnname, FILE *fp, FLENS *hp) { - off_t passoff = 0; - ulong_t psizes[4]; + ulong_t psizes[5]; uint_t pass; psizes[0] = 0; psizes[1] = hp->f1; psizes[2] = hp->f2; psizes[3] = hp->f3; + psizes[4] = hp->f4; - if (justrelpaths && lnname[0] == '/') - lnname = strrchr(lnname, '/') + 1; - - infohdr("LINTLIB", "%s <mid %hu> %lu+%lu+%lu+%lu = %lu bytes\n", lnname, - hp->mno, hp->f1, hp->f2, hp->f3, hp->f4, - hp->f1 + hp->f2 + hp->f3 + hp->f4); + infohdr("LINTMOD", "%hu: %lu+%lu+%lu+%lu = %lu bytes\n", hp->mno, + hp->f1, hp->f2, hp->f3, hp->f4, hp->f1 + hp->f2 + hp->f3 + hp->f4); - for (pass = 1; pass <= 3; pass++) { - if (justpass < 0 || justpass == pass) { + for (pass = 1; pass <= 4; pass++) { + if ((justpass < 0 || justpass == pass) && pass < 4) { infohdr("SECTION", "PASS%u: %lu bytes\n", pass, psizes[pass]); print_pass(lnname, fp); + } else { + (void) fseek(fp, psizes[pass], SEEK_CUR); } - passoff += psizes[pass]; - (void) fseek(fp, passoff, SEEK_SET); } } /* - * Print out a PASS section of a lint library. + * Print out a PASS section of a lint module. */ static void print_pass(const char *lnname, FILE *fp) @@ -451,6 +452,7 @@ lsu_lookup(T1WORD ty) /* * Read all LSU (structure and union definition) records in order to * build a structure and union name table, called the LSU table. + * Although `fp' is read from, the original file offset is preserved. */ static void lsu_build(FILE *fp) @@ -458,10 +460,11 @@ lsu_build(FILE *fp) union rec rec; char name[1024]; int nargs; + off_t curoff = ftello(fp); for (;;) { if (fread(&rec, sizeof (rec), 1, fp) != 1) - return; + break; if (rec.l.decflag & LND) /* end-of-pass marker */ break; @@ -487,6 +490,8 @@ lsu_build(FILE *fp) } } } + + (void) fseek(fp, curoff, SEEK_SET); } /* @@ -542,8 +547,8 @@ unindent(void) static void usage(void) { - (void) fprintf(stderr, "usage: %s [-i] [-p 1|2|3] [-r] lintlib" - " [ lintlib ... ]\n", progname); + (void) fprintf(stderr, "usage: %s [-i] [-p 1|2|3] [-r] lintobj" + " [ lintobj ... ]\n", progname); exit(EXIT_FAILURE); } diff --git a/usr/src/tools/scripts/wsdiff.py b/usr/src/tools/scripts/wsdiff.py index 442727b7f5..f390c038ee 100755 --- a/usr/src/tools/scripts/wsdiff.py +++ b/usr/src/tools/scripts/wsdiff.py @@ -19,7 +19,7 @@ # # CDDL HEADER END # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" @@ -968,9 +968,9 @@ def compareByDumping(base, ptch, quiet, fileType) : if fileType == "Lint Library" : baseCmd = lintdump_cmd + " -ir " + base + \ - " | grep -v LINTLIB:" + " > " + tmpFile1 + " | egrep -v '(LINTOBJ|LINTMOD):'" + " > " + tmpFile1 ptchCmd = lintdump_cmd + " -ir " + ptch + \ - " | grep -v LINTLIB:" + " > " + tmpFile2 + " | egrep -v '(LINTOBJ|LINTMOD):'" + " > " + tmpFile2 elif fileType == "Sqlite Database" : baseCmd = "echo .dump | " + sqlite_cmd + base + " > " + \ tmpFile1 |