1 .\" " CDDL HEADER START
   2 .\" "
   3 .\" " The contents of this file are subject to the terms of the
   4 .\" " Common Development and Distribution License (the "License").
   5 .\" " You may not use this file except in compliance with the License.
   6 .\" "
   7 .\" " You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   8 .\" " or http://www.opensolaris.org/os/licensing.
   9 .\" " See the License for the specific language governing permissions
  10 .\" " and limitations under the License.
  11 .\" "
  12 .\" " When distributing Covered Code, include this CDDL HEADER in each
  13 .\" " file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  14 .\" " If applicable, add the following below this CDDL HEADER, with the
  15 .\" " fields enclosed by brackets "[]" replaced with your own identifying
  16 .\" " information: Portions Copyright [yyyy] [name of copyright owner]
  17 .\" "
  18 .\" " CDDL HEADER END
  19 .\" "
  20 .\" "Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  21 .\" "Use is subject to license terms.
  22 .TH LINTDUMP 1ONBLD "Mar 28, 2008"
  23 .I lintdump
  24 \- dump the contents of one or more lint objects
  25 .SH SYNOPSIS
  26 \fBlintdump [-i] [-p 1|2|3] [-r] \fIlintobj\fP [ \fIlintobj\fP ... ]
  27 .SH DESCRIPTION
  28 .LP
  29 The lintdump utility dumps the contents of one or more lint
  30 objects.  This is chiefly useful when trying to understand the cause of
  31 unexpected or obtuse lint warnings (see EXAMPLES), but can also be used to
  32 find differences between lint objects across builds or releases, or to
  33 debug problems in lint itself.
  34 .LP
  35 A lint object is a binary file (typically suffixed with ".ln") constructed
  36 from a C source file via the "-c" option to lint(1).  Multiple lint
  37 objects may be combined into a lint library object (typically prefixed
  38 with "llib-l" and suffixed with ".ln") using the "-o" option to lint.  (As
  39 a convenience, lint "-o" allows a lint library object to be built directly
  40 from C source files). The lintdump utility is capable of dumping both
  41 traditional lint objects and lint library objects.
  42 .LP
  43 The format of a lint object is unstable and subject to change at any time,
  44 but its current structure is summarized here in order to aid in
  45 understanding the current output of lintdump.  A lint object consists of
  46 one or more lint modules (one per C source file).  Each lint module
  47 consists of a header and four sections, called PASS1, PASS2, PASS3, and
  48 STRINGS.  Generally speaking, PASS1 contains definitions, PASS2 contains
  49 declarations, and PASS3 contains information on whether or how functions
  50 or variables are used.  The STRINGS section holds the strings for
  51 printf(3C)/scanf(3C) checking.
  52 .LP
  53 Each PASS section consists of a sequence of binary records of assorted
  54 types.  The sequence of records is further partitioned by FILE records,
  55 which indicate the source or header file that is responsible for the
  56 records that follow.  The remaining record types provide lint with
  57 information about the functions, variables, and structures defined or used
  58 by the object.
  59 .SH OPTIONS
  60 .TP 10
  61 .B -i
  62 Do not output structure tag IDs (see EXAMPLES).
  63 .TP 10
  64 .B -p 1|2|3
  65 Just output the PASS1, PASS2, or PASS3 section.
  66 .TP 10
  67 .B -r
  68 Output records using relative paths (see EXAMPLES).
  69 .SH OUTPUT
  70 .LP
  71 The contents of each specified \fIlintobj\fP is dumped in command-line
  72 order.  For each \fIlintobj\fP, lintdump outputs a single line beginning
  73 with "LINTOBJ:" that provides its name.  For each lint module within that
  74 object, lintdump outputs a single line beginning with "LINTMOD:" that
  75 provides its module ID, the size of its PASS1, PASS2, PASS3, STRING
  76 sections, and its total size, in that order.
  77 .LP
  78 Next, unless the -p option is used, the contents of the PASS1, PASS2, and
  79 PASS3 sections are dumped, in order.  Before each section is dumped,
  80 lintdump outputs a single line beginning with "SECTION:" that
  81 provides the name and size of the section.  For each section,
  82 lintdump outputs each record in order.  The display format of each
  83 record depends on its type:
  84 .LP
  85 .B FILE RECORDS
  86 .RS 4
  87 Each FILE record is displayed on a single line beginning with "FILE:".
  88 Note that FILE records are often found in pairs, the first providing the
  89 absolute path to the file.  FILE records containing absolute paths are
  90 omitted if -r is used.  Other record types following a FILE record are
  91 indented to show their relationship to the FILE record.
  92 .RE
  93 .LP
  94 .B FUNCTION AND VARIABLE RECORDS
  95 .RS 4
  96 Each function or variable record is displayed on a single line using an
  97 extended version of the format used in The C Programming Language, Second
  98 Edition.  In particular, properties contained in the record that cannot be
  99 conveyed in C are displayed in angle brackets following definition or
 100 declaration; a full list of these and their meanings are given below in
 101 RECORD PROPERTIES.  In addition, note that some structures or unions may
 102 only be known by a numeric \fIID\fP, and thus output as "struct <tag
 103 \fIID\fP>".  This ID can be used to pair the structure with its definition
 104 via structure records.  If -i is used, then "struct <anon>" is printed
 105 instead.
 106 .RE
 107 .LP
 108 .B STRUCTURE AND UNION RECORDS
 109 .RS 4
 110 Each structure or union record is displayed using an extended version of
 111 the standard multi-line format used in The C Programming Language, Second
 112 Edition.  In particular, to facilitate problem analysis, unless -i is
 113 used, each structure or union definition includes a numeric ID enclosed in
 114 angle-brackets, such as "struct FILE <tag 1298> {".
 115 .RE
 116 .LP
 117 To illustrate each of the common record formats, suppose the following
 118 lint library is built:
 119 .LP
 120 .nf
 121 $ cat > liba.c
 122 /* LINTLIBRARY */
 123 /* PROTOLIB1 */
 124 int af(int);
 125 struct as {
 126         char as_name[32];
 127         int  as_flag;
 128 } as;
 129 $ lint -oa liba.c
 130 .fi
 131 .LP
 132 Then lintdump will produce the following output:
 133 .LP
 134 .nf
 135 LINTOBJ: llib-la.ln
 136 LINTMOD: 6484: 268+24+130+9 = 431 bytes
 137 SECTION: PASS1: 268 bytes
 138    FILE: /home/meem/hacks/liba.c
 139    FILE: liba.c
 140          extern int af(int);
 141          struct as as;
 142          struct as <tag 98> {
 143              char as_name[];
 144              int as_flag;
 145          };
 146 SECTION: PASS2: 24 bytes
 147 SECTION: PASS3: 130 bytes
 148    FILE: /home/meem/hacks/liba.c
 149    FILE: liba.c
 150          int af(void) <returns value>;
 151 .fi
 152 .SH RECORD PROPERTIES
 153 .LP
 154 As discussed in OUTPUT, some records are displayed using an extended
 155 format to convey information that cannot be expressed in C.  The following
 156 extended information may be displayed:
 157 .LP
 158 .B <PRINTFLIKE\fIn\fP>
 159 .RS 4
 160 Indicates to lint that argument \fIn\fP to the variable-argument function
 161 is a format string in printf(3C) format, which enhances lint's argument
 162 checking.
 163 .RE
 164 .LP
 165 .B <SCANFLIKE\fIn\fP>
 166 .RS 4
 167 Indicates to lint that argument \fIn\fP to the variable-argument function
 168 is a format string in scanf(3C) format, which enhances lint's argument
 169 checking.
 170 .RE
 171 .LP
 172 .B <definition>
 173 .RS 4
 174 Indicates to lint that this record represents the definition of the given
 175 variable or function (rather than a declaration).
 176 .RE
 177 .LP
 178 .B <use: side-effects context>
 179 .RS 4
 180 Indicates to lint that the associated function is called in a context that
 181 suggests it has side effects.
 182 .RE
 183 .LP
 184 .B <use: return value context>
 185 .RS 4
 186 Indicates to lint that the associated function is called in a context where
 187 its return value is used.
 188 .RE
 189 .LP
 190 .B <use: unspecified context>
 191 .RS 4
 192 Indicates to lint that the associated function is used in an unspecified
 193 manner.
 194 .RE
 195 .LP
 196 .B <returns value>
 197 .RS 4
 198 Indicates to lint that the function returns a value.
 199 .RE
 200 .SH EXAMPLES
 201 .LP
 202 One common problem is that lint does not always provide sufficient
 203 information to understand the reason for a type mismatch.  For instance,
 204 sometimes lint will confusingly report a type mismatch between
 205 apparently-identical types:
 206 .LP
 207 .nf
 208 $ lint msghdr.c -lsocket
 209 function argument ( number ) used inconsistently
 210     recvmsg (arg 2) llib-lsocket:socket.h(437) struct msghdr * ::
 211                                  msghdr.c(12)  struct msghdr *
 212 .fi
 213 .LP
 214 By using lintdump, we can pinpoint the problem by examining both
 215 definitions for \fIstruct msghdr\fP:
 216 .LP
 217 .nf
 218 $ lintdump /lib/llib-lsocket.ln
 219    \fI[ ... ]\fP
 220    FILE: llib-lsocket:socket.h
 221          struct msghdr <tag 4532> {
 222              void *msg_name;
 223              unsigned int msg_namelen;
 224              struct iovec *msg_iov;
 225              int msg_iovlen;
 226              \fBchar *msg_accrights;\fP
 227              \fBint msg_accrightslen;\fP
 228          };
 229 .fi
 230 .LP
 231 .nf
 232 $ lint -omsghdr msghdr.c -lsocket
 233 $ lintdump llib-lmsghdr.ln
 234    \fI[ ... ]\fP
 235    FILE: socket.h
 236          struct msghdr <tag 1315> {
 237              void *msg_name;
 238              unsigned int msg_namelen;
 239              struct iovec *msg_iov;
 240              int msg_iovlen;
 241              \fBvoid *msg_control;\fP
 242              \fBunsigned int msg_controllen;\fP
 243              \fBint msg_flags;\fP
 244          };
 245 .fi
 246 .LP
 247 Looking at <sys/socket.h>, the problem becomes apparent: the structure
 248 changes depending on compile-time options, which clearly differ between
 249 the application and the library:
 250 .LP
 251 .nf
 252 struct msghdr {
 253         void            *msg_name;
 254         socklen_t       msg_namelen;
 255         struct iovec    *msg_iov;
 256         int             msg_iovlen;
 257 
 258 #if defined(_XPG4_2) || defined(_KERNEL)
 259         void            *msg_control;
 260         socklen_t       msg_controllen;
 261         int             msg_flags;
 262 #else
 263         caddr_t         msg_accrights;
 264         int             msg_accrightslen;
 265 #endif  /* defined(_XPG4_2) || defined(_KERNEL) */
 266 };
 267 .fi
 268 .LP
 269 Another use of lintdump is to compare two versions of a lint object to
 270 see whether anything of significance has changed.  For instance, lintdump
 271 can be used to understand why a lint library is different between a
 272 project gate and a patch gate, and thus to determine whether the library
 273 will need to be redelivered in the patch including the project:
 274 .LP
 275 .nf
 276 $ PATCHROOT=/ws/on10-patch/proto/root_i386
 277 $ diff llib-lkstat.ln $PATCHROOT/lib/llib-lkstat.ln
 278 Binary files llib-lkstat.ln and
 279              /ws/on10-patch/proto/root_i386/lib/llib-lkstat.ln differ
 280 $ lintdump -ir llib-lkstat.ln > /tmp/proj-kstat.out
 281 $ lintdump -ir $PATCHROOT/lib/llib-lkstat.ln > /tmp/patch-kstat.out
 282 .fi
 283 .LP
 284 .nf
 285 $ diff /tmp/patch-kstat.out /tmp/proj-kstat.out
 286 1,2c1,2
 287 < LINTMOD: 3675: 4995+26812+1045+9 = 32861 bytes
 288 < SECTION: PASS1: 4995 bytes
 289 ---
 290 > LINTMOD: 39982: 5144+27302+1057+9 = 33512 bytes
 291 > SECTION: PASS1: 5144 bytes
 292 19c19
 293 <              unsigned char _file;
 294 ---
 295 >              unsigned char _magic;
 296 22a23,24
 297 >              unsigned int __extendedfd;
 298 >              unsigned int __xf_nocheck;
 299 \fI[ ... ]\fP
 300 .fi
 301 .LP
 302 Note that -r option removes spurious differences that would otherwise
 303 arise from different absolute paths to the same source file, and the -i
 304 option removes spurious differences due to ID generation inside lint.
 305 .SH SEE ALSO
 306 .LP
 307 .IR lint(1),
 308 .IR printf(3C),
 309 .IR scanf(3C)
 310 .SH NOTES
 311 This utility is provided as an interim solution until a stable utility
 312 can be bundled with Sun Studio.  As such, any use of this utility in
 313 scripts or embedded inside programs should be done with knowledge that
 314 subsequent changes will be required in order to transition to the stable
 315 solution.
 316 .LP
 317 The lint object file format does not have a way to represent bitfields. As
 318 such, bitfield size information cannot be displayed by lintdump.