1 .\" " CDDL HEADER START
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.
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.
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]
20 .\" "Copyright 2008 Sun Microsystems, Inc. All rights reserved.
21 .\" "Use is subject to license terms.
22 .TH LINTDUMP 1ONBLD "Mar 28, 2008"
24 \- dump the contents of one or more lint objects
26 \fBlintdump [-i] [-p 1|2|3] [-r] \fIlintobj\fP [ \fIlintobj\fP ... ]
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.
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.
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.
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
62 Do not output structure tag IDs (see EXAMPLES).
65 Just output the PASS1, PASS2, or PASS3 section.
68 Output records using relative paths (see EXAMPLES).
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.
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:
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.
94 .B FUNCTION AND VARIABLE RECORDS
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
108 .B STRUCTURE AND UNION RECORDS
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> {".
117 To illustrate each of the common record formats, suppose the following
118 lint library is built:
132 Then lintdump will produce the following output:
136 LINTMOD: 6484: 268+24+130+9 = 431 bytes
137 SECTION: PASS1: 268 bytes
138 FILE: /home/meem/hacks/liba.c
146 SECTION: PASS2: 24 bytes
147 SECTION: PASS3: 130 bytes
148 FILE: /home/meem/hacks/liba.c
150 int af(void) <returns value>;
152 .SH RECORD PROPERTIES
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:
158 .B <PRINTFLIKE\fIn\fP>
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
165 .B <SCANFLIKE\fIn\fP>
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
174 Indicates to lint that this record represents the definition of the given
175 variable or function (rather than a declaration).
178 .B <use: side-effects context>
180 Indicates to lint that the associated function is called in a context that
181 suggests it has side effects.
184 .B <use: return value context>
186 Indicates to lint that the associated function is called in a context where
187 its return value is used.
190 .B <use: unspecified context>
192 Indicates to lint that the associated function is used in an unspecified
198 Indicates to lint that the function returns a value.
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:
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 *
214 By using lintdump, we can pinpoint the problem by examining both
215 definitions for \fIstruct msghdr\fP:
218 $ lintdump /lib/llib-lsocket.ln
220 FILE: llib-lsocket:socket.h
221 struct msghdr <tag 4532> {
223 unsigned int msg_namelen;
224 struct iovec *msg_iov;
226 \fBchar *msg_accrights;\fP
227 \fBint msg_accrightslen;\fP
232 $ lint -omsghdr msghdr.c -lsocket
233 $ lintdump llib-lmsghdr.ln
236 struct msghdr <tag 1315> {
238 unsigned int msg_namelen;
239 struct iovec *msg_iov;
241 \fBvoid *msg_control;\fP
242 \fBunsigned int msg_controllen;\fP
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:
254 socklen_t msg_namelen;
255 struct iovec *msg_iov;
258 #if defined(_XPG4_2) || defined(_KERNEL)
260 socklen_t msg_controllen;
263 caddr_t msg_accrights;
264 int msg_accrightslen;
265 #endif /* defined(_XPG4_2) || defined(_KERNEL) */
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:
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
285 $ diff /tmp/patch-kstat.out /tmp/proj-kstat.out
287 < LINTMOD: 3675: 4995+26812+1045+9 = 32861 bytes
288 < SECTION: PASS1: 4995 bytes
290 > LINTMOD: 39982: 5144+27302+1057+9 = 33512 bytes
291 > SECTION: PASS1: 5144 bytes
293 < unsigned char _file;
295 > unsigned char _magic;
297 > unsigned int __extendedfd;
298 > unsigned int __xf_nocheck;
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.
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
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.