blob: eaf16dca79b2fe68b3f540ef5839e49f2b70bb40 [file] [log] [blame]
sewardj9829e382005-05-24 14:17:41 +00001
2As of May 2005, Valgrind can produce its output in XML form. The
3intention is to provide an easily parsed, stable format which is
4suitable for GUIs to read.
5
6
7Design goals
8~~~~~~~~~~~~
9
10* Produce XML output which is easily parsed
11
12* Have a stable output format which does not change much over time, so
13 that investments in parser-writing by GUI developers is not lost as
14 new versions of Valgrind appear.
15
16* Have an extensive output format, so that future changes to the
17 format do not break backwards compatibility with existing parsers of
18 it.
19
20* Produce output in a form which suitable for both offline GUIs (run
21 all the way to the end, then examine output) and interactive GUIs
22 (parse XML incrementally, update display as we go).
23
24* Put as much information as possible into the XML and let the GUIs
25 decide what to show the user (a.k.a provide mechanism, not policy).
26
sewardj57d99c52005-06-13 16:44:33 +000027* Make XML which is actually parseable by standard XML tools.
28
sewardj9829e382005-05-24 14:17:41 +000029
30How to use
31~~~~~~~~~~
32
dee6ca7bd2005-08-03 18:58:45 +000033Run with flag --xml=yes. That`s all. Note however several
sewardj9829e382005-05-24 14:17:41 +000034caveats.
35
36* At the present time only Memcheck is supported. The scheme extends
njn1d0825f2006-03-27 11:37:07 +000037 easily enough to cover Helgrind if needed.
sewardj9829e382005-05-24 14:17:41 +000038
39* When XML output is selected, various other settings are made.
40 This is in order that the output format is more controlled.
41 The settings which are changed are:
42
43 - Suppression generation is disabled, as that would require user
44 input.
45
46 - Attaching to GDB is disabled for the same reason.
47
48 - The verbosity level is set to 1 (-v).
49
50 - Error limits are disabled. Usually if the program generates a lot
51 of errors, Valgrind slows down and eventually stops collecting
52 them. When outputting XML this is not the case.
53
54 - VEX emulation warnings are not shown.
55
56 - File descriptor leak checking is disabled. This could be
57 re-enabled at some future point.
58
59 - Maximum-detail leak checking is selected (--leak-check=full).
60
61
62The output format
63~~~~~~~~~~~~~~~~~
sewardj9e7212f2005-05-24 15:00:55 +000064For the most part this should be self descriptive. It is printed in a
65sort-of human-readable way for easy understanding. You may want to
66read the rest of this together with the results of "valgrind --xml=yes
67memcheck/tests/xml1" as an example.
sewardj9829e382005-05-24 14:17:41 +000068
69All tags are balanced: a <foo> tag is always closed by </foo>. Hence
70in the description that follows, mention of a tag <foo> implicitly
71means there is a matching closing tag </foo>.
72
73Symbols in CAPITALS are nonterminals in the grammar and are defined
74somewhere below. The root nonterminal is TOPLEVEL.
75
76The following nonterminals are not described further:
77 INT is a 64-bit signed decimal integer.
78 TEXT is arbitrary text.
sewardj9e7212f2005-05-24 15:00:55 +000079 HEX64 is a 64-bit hexadecimal number, with leading "0x".
sewardj9829e382005-05-24 14:17:41 +000080
sewardj57d99c52005-06-13 16:44:33 +000081Text strings are escaped so as to remove the <, > and & characters
82which would otherwise mess up parsing. They are replaced respectively
83with the standard encodings "&lt;", "&gt;" and "&amp;" respectively.
84Note this is not (yet) done throughout, only for function names in
85<frame>..</frame> tags-pairs.
86
sewardj9829e382005-05-24 14:17:41 +000087
88TOPLEVEL
89--------
sewardj57d99c52005-06-13 16:44:33 +000090
91The first line output is always this:
92
93 <?xml version="1.0"?>
94
95All remaining output is contained within the tag-pair
96<valgrindoutput>.
sewardj9829e382005-05-24 14:17:41 +000097
98Inside that, the first entity is an indication of the protocol
99version. This is provided so that existing parsers can identify XML
100created by future versions of Valgrind merely by observing that the
dee6ca7bd2005-08-03 18:58:45 +0000101protocol version is one they don`t understand. Hence TOPLEVEL is:
sewardj9829e382005-05-24 14:17:41 +0000102
sewardj8665d8e2005-06-01 17:35:23 +0000103 <?xml version="1.0"?>
sewardj9829e382005-05-24 14:17:41 +0000104 <valgrindoutput>
105 <protocolversion>INT<protocolversion>
sewardj6a5a69c2005-11-17 00:51:36 +0000106 PROTOCOL
sewardj9829e382005-05-24 14:17:41 +0000107 </valgrindoutput>
108
sewardj6a5a69c2005-11-17 00:51:36 +0000109Valgrind versions 3.0.0 and 3.0.1 emit protocol version 1. Version
1103.1.0 emits protocol version 2.
sewardj9829e382005-05-24 14:17:41 +0000111
112
sewardj6a5a69c2005-11-17 00:51:36 +0000113PROTOCOL for version 2
114----------------------
115Version 2 is identical in every way to version 1, except that the time
116string in
117
118 <time>human-readable-time-string</time>
119
120has changed format, and is also elapsed wallclock time since process
121start, and not local time or any such. In fact version 1 does not
122define the format of the string so in some ways this revision is
123irrelevant.
124
125
126PROTOCOL for version 1
127----------------------
sewardj9829e382005-05-24 14:17:41 +0000128This is the main top-level construction. Roughly speaking, it
129contains a load of preamble, the errors from the run of the
130program, and the result of the final leak check. Hence the
131following in sequence:
132
133* Various preamble lines which give version info for the various
134 components. The text in them can be anything; it is not intended
135 for interpretation by the GUI:
136
sewardj57d99c52005-06-13 16:44:33 +0000137 <preamble>
138 <line>Misc version/copyright text</line> (zero or more of)
139 </preamble>
sewardj9829e382005-05-24 14:17:41 +0000140
141* The PID of this process and of its parent:
142
143 <pid>INT</pid>
144 <ppid>INT</ppid>
145
146* The name of the tool being used:
147
148 <tool>TEXT</tool>
149
sewardjad311162005-07-19 11:25:02 +0000150* OPTIONALLY, if --log-file-qualifier=VAR flag was given:
151
152 <logfilequalifier> <var>VAR</var> <value>$VAR</value>
153 </logfilequalifier>
154
155 That is, both the name of the environment variable and its value
156 are given.
157
sewardje5e1f822005-07-19 14:59:41 +0000158* OPTIONALLY, if --xml-user-comment=STRING was given:
159
160 <usercomment>STRING</usercomment>
161
162 STRING is not escaped in any way, so that it itself may be a piece
163 of XML with arbitrary tags etc.
164
sewardjb8a3dac2005-07-19 12:39:11 +0000165* The program and args: first those pertaining to Valgrind itself, and
166 then those pertaining to the program to be run under Valgrind (the
167 client):
sewardj9829e382005-05-24 14:17:41 +0000168
sewardjb8a3dac2005-07-19 12:39:11 +0000169 <args>
170 <vargv>
171 <exe>TEXT</exe>
172 <arg>TEXT</arg> (zero or more of)
173 </vargv>
174 <argv>
175 <exe>TEXT</exe>
176 <arg>TEXT</arg> (zero or more of)
177 </argv>
178 </args>
sewardj9829e382005-05-24 14:17:41 +0000179
180* The following, indicating that the program has now started:
181
sewardj33e60422005-07-24 07:33:15 +0000182 <status> <state>RUNNING</state>
183 <time>human-readable-time-string</time>
sewardj68cde6f2005-07-19 12:17:51 +0000184 </status>
sewardj9829e382005-05-24 14:17:41 +0000185
186* Zero or more of (either ERROR or ERRORCOUNTS).
187
188* The following, indicating that the program has now finished, and
189 that the wrapup (leak checking) is happening.
190
sewardj33e60422005-07-24 07:33:15 +0000191 <status> <state>FINISHED</state>
192 <time>human-readable-time-string</time>
sewardj68cde6f2005-07-19 12:17:51 +0000193 </status>
sewardj9829e382005-05-24 14:17:41 +0000194
195* SUPPCOUNTS, indicating how many times each suppression was used.
196
197* Zero or more ERRORs, each of which is a complaint from the
198 leak checker.
199
sewardj6a5a69c2005-11-17 00:51:36 +0000200That's it.
sewardj9829e382005-05-24 14:17:41 +0000201
202
203ERROR
204-----
205This shows an error, and is the most complex nonterminal. The format
206is as follows:
207
208 <error>
209 <unique>HEX64</unique>
210 <tid>INT</tid>
211 <kind>KIND</kind>
212 <what>TEXT</what>
213
214 optionally: <leakedbytes>INT</leakedbytes>
215 optionally: <leakedblocks>INT</leakedblocks>
216
217 STACK
218
219 optionally: <auxwhat>TEXT</auxwhat>
220 optionally: STACK
221
222 </error>
223
224* Each error contains a unique, arbitrary 64-bit hex number. This is
225 used to refer to the error in ERRORCOUNTS nonterminals (see below).
226
227* The <tid> tag indicates the Valgrind thread number. This value
228 is arbitrary but may be used to determine which threads produced
229 which errors (at least, the first instance of each error).
230
231* The <kind> tag specifies one of a small number of fixed error
232 types (enumerated below), so that GUIs may roughly categorise
233 errors by type if they want.
234
235* The <what> tag gives a human-understandable description of the
236 error.
237
238* For <kind> tags specifying a KIND of the form "Leak_*", the
239 optional <leakedbytes> and <leakedblocks> indicate the number of
240 bytes and blocks leaked by this error.
241
242* The primary STACK for this error, indicating where it occurred.
243
244* Some error types may have auxiliary information attached:
245
246 <auxwhat>TEXT</auxwhat> gives an auxiliary human-readable
247 description (usually of invalid addresses)
248
249 STACK gives an auxiliary stack (usually the allocation/free
250 point of a block). If this STACK is present then
251 <auxwhat>TEXT</auxwhat> will precede it.
252
253
254KIND
255----
256This is a small enumeration indicating roughly the nature of an error.
257The possible values are:
258
259 InvalidFree
260
261 free/delete/delete[] on an invalid pointer
262
263 MismatchedFree
264
265 free/delete/delete[] does not match allocation function
266 (eg doing new[] then free on the result)
267
268 InvalidRead
269
270 read of an invalid address
271
272 InvalidWrite
273
274 write of an invalid address
275
276 InvalidJump
277
278 jump to an invalid address
279
280 Overlap
281
282 args overlap other otherwise bogus in eg memcpy
283
284 InvalidMemPool
285
286 invalid mem pool specified in client request
287
288 UninitCondition
289
290 conditional jump/move depends on undefined value
291
292 UninitValue
293
294 other use of undefined value (primarily memory addresses)
295
296 SyscallParam
297
298 system call params are undefined or point to
299 undefined/unaddressible memory
300
301 ClientCheck
302
303 "error" resulting from a client check request
304
305 Leak_DefinitelyLost
306
307 memory leak; the referenced blocks are definitely lost
308
309 Leak_IndirectlyLost
310
311 memory leak; the referenced blocks are lost because all pointers
312 to them are also in leaked blocks
313
314 Leak_PossiblyLost
315
316 memory leak; only interior pointers to referenced blocks were
317 found
318
319 Leak_StillReachable
320
321 memory leak; pointers to un-freed blocks are still available
322
323
324STACK
325-----
326STACK indicates locations in the program being debugged. A STACK
327is one or more FRAMEs. The first is the innermost frame, the
328next its caller, etc.
329
330 <stack>
331 one or more FRAME
332 </stack>
333
334
335FRAME
336-----
337FRAME records a single program location:
338
339 <frame>
340 <ip>HEX64</ip>
341 optionally <obj>TEXT</obj>
342 optionally <fn>TEXT</fn>
sewardj57d99c52005-06-13 16:44:33 +0000343 optionally <dir>TEXT</dir>
sewardj9829e382005-05-24 14:17:41 +0000344 optionally <file>TEXT</file>
345 optionally <line>INT</line>
346 </frame>
347
348Only the <ip> field is guaranteed to be present. It indicates a
349code ("instruction pointer") address.
350
351The optional fields, if present, appear in the order stated:
352
353* obj: gives the name of the ELF object containing the code address
354
355* fn: gives the name of the function containing the code address
356
sewardj57d99c52005-06-13 16:44:33 +0000357* dir: gives the source directory associated with the name specified
358 by <file>. Note the current implementation often does not
359 put anything useful in this field.
360
sewardj9829e382005-05-24 14:17:41 +0000361* file: gives the name of the source file containing the code address
362
363* line: gives the line number in the source file
364
365
366ERRORCOUNTS
367-----------
368This specifies, for each error that has been so far presented,
369the number of occurrences of that error.
370
371 <errorcounts>
372 zero or more of
373 <pair> <count>INT</count> <unique>HEX64</unique> </pair>
374 </errorcounts>
375
376Each <pair> gives the current error count <count> for the error with
377unique tag </unique>. The counts do not have to give a count for each
378error so far presented - partial information is allowable.
379
sewardj9e7212f2005-05-24 15:00:55 +0000380As at Valgrind rev 3793, error counts are only emitted at program
sewardj9829e382005-05-24 14:17:41 +0000381termination. However, it is perfectly acceptable to periodically emit
382error counts as the program is running. Doing so would facilitate a
383GUI to dynamically update its error-count display as the program runs.
384
385
386SUPPCOUNTS
387----------
388A SUPPCOUNTS block appears exactly once, after the program terminates.
389It specifies the number of times each error-suppression was used.
390Suppressions not mentioned were used zero times.
391
392 <suppcounts>
393 zero or more of
sewardj7c9e57c2005-05-24 14:21:45 +0000394 <pair> <count>INT</count> <name>TEXT</name> </pair>
sewardj9829e382005-05-24 14:17:41 +0000395 </suppcounts>
396
397The <name> is as specified in the suppression name fields in .supp
398files.
sewardj57d99c52005-06-13 16:44:33 +0000399