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