blob: 136c962441b1d7fed17024be9cf7af1f93c1af15 [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
27
28How to use
29~~~~~~~~~~
30
31Run with flag --xml=yes. That's all. Note however several
32caveats.
33
34* At the present time only Memcheck is supported. The scheme extends
35 easily enough to cover Addrcheck and Helgrind if needed.
36
37* When XML output is selected, various other settings are made.
38 This is in order that the output format is more controlled.
39 The settings which are changed are:
40
41 - Suppression generation is disabled, as that would require user
42 input.
43
44 - Attaching to GDB is disabled for the same reason.
45
46 - The verbosity level is set to 1 (-v).
47
48 - Error limits are disabled. Usually if the program generates a lot
49 of errors, Valgrind slows down and eventually stops collecting
50 them. When outputting XML this is not the case.
51
52 - VEX emulation warnings are not shown.
53
54 - File descriptor leak checking is disabled. This could be
55 re-enabled at some future point.
56
57 - Maximum-detail leak checking is selected (--leak-check=full).
58
59
60The output format
61~~~~~~~~~~~~~~~~~
sewardj9e7212f2005-05-24 15:00:55 +000062For the most part this should be self descriptive. It is printed in a
63sort-of human-readable way for easy understanding. You may want to
64read the rest of this together with the results of "valgrind --xml=yes
65memcheck/tests/xml1" as an example.
sewardj9829e382005-05-24 14:17:41 +000066
67All tags are balanced: a <foo> tag is always closed by </foo>. Hence
68in the description that follows, mention of a tag <foo> implicitly
69means there is a matching closing tag </foo>.
70
71Symbols in CAPITALS are nonterminals in the grammar and are defined
72somewhere below. The root nonterminal is TOPLEVEL.
73
74The following nonterminals are not described further:
75 INT is a 64-bit signed decimal integer.
76 TEXT is arbitrary text.
sewardj9e7212f2005-05-24 15:00:55 +000077 HEX64 is a 64-bit hexadecimal number, with leading "0x".
sewardj9829e382005-05-24 14:17:41 +000078
79
80TOPLEVEL
81--------
82All output is contained within the tag-pair <valgrindoutput>.
83
84Inside that, the first entity is an indication of the protocol
85version. This is provided so that existing parsers can identify XML
86created by future versions of Valgrind merely by observing that the
87protocol version is one they don't understand. Hence TOPLEVEL is:
88
sewardj8665d8e2005-06-01 17:35:23 +000089 <?xml version="1.0"?>
sewardj9829e382005-05-24 14:17:41 +000090 <valgrindoutput>
91 <protocolversion>INT<protocolversion>
92 VERSION1STUFF
93 </valgrindoutput>
94
95The only currently defined protocol version number is 1. This
96document only defines protocol version 1.
97
98
99VERSION1STUFF
100-------------
101This is the main top-level construction. Roughly speaking, it
102contains a load of preamble, the errors from the run of the
103program, and the result of the final leak check. Hence the
104following in sequence:
105
106* Various preamble lines which give version info for the various
107 components. The text in them can be anything; it is not intended
108 for interpretation by the GUI:
109
110 <preamble>Misc version/copyright text</preamble>
111
112* The PID of this process and of its parent:
113
114 <pid>INT</pid>
115 <ppid>INT</ppid>
116
117* The name of the tool being used:
118
119 <tool>TEXT</tool>
120
sewardj8665d8e2005-06-01 17:35:23 +0000121* The program and args being run.
sewardj9829e382005-05-24 14:17:41 +0000122
123 <argv>
sewardj8665d8e2005-06-01 17:35:23 +0000124 <exe>TEXT</exe>
125 <arg>TEXT</arg> (zero or more of)
sewardj9829e382005-05-24 14:17:41 +0000126 </argv>
127
128* The following, indicating that the program has now started:
129
130 <status>RUNNING</status>
131
132* Zero or more of (either ERROR or ERRORCOUNTS).
133
134* The following, indicating that the program has now finished, and
135 that the wrapup (leak checking) is happening.
136
137 <status>FINISHED</status>
138
139* SUPPCOUNTS, indicating how many times each suppression was used.
140
141* Zero or more ERRORs, each of which is a complaint from the
142 leak checker.
143
144That's it.
145
146
147ERROR
148-----
149This shows an error, and is the most complex nonterminal. The format
150is as follows:
151
152 <error>
153 <unique>HEX64</unique>
154 <tid>INT</tid>
155 <kind>KIND</kind>
156 <what>TEXT</what>
157
158 optionally: <leakedbytes>INT</leakedbytes>
159 optionally: <leakedblocks>INT</leakedblocks>
160
161 STACK
162
163 optionally: <auxwhat>TEXT</auxwhat>
164 optionally: STACK
165
166 </error>
167
168* Each error contains a unique, arbitrary 64-bit hex number. This is
169 used to refer to the error in ERRORCOUNTS nonterminals (see below).
170
171* The <tid> tag indicates the Valgrind thread number. This value
172 is arbitrary but may be used to determine which threads produced
173 which errors (at least, the first instance of each error).
174
175* The <kind> tag specifies one of a small number of fixed error
176 types (enumerated below), so that GUIs may roughly categorise
177 errors by type if they want.
178
179* The <what> tag gives a human-understandable description of the
180 error.
181
182* For <kind> tags specifying a KIND of the form "Leak_*", the
183 optional <leakedbytes> and <leakedblocks> indicate the number of
184 bytes and blocks leaked by this error.
185
186* The primary STACK for this error, indicating where it occurred.
187
188* Some error types may have auxiliary information attached:
189
190 <auxwhat>TEXT</auxwhat> gives an auxiliary human-readable
191 description (usually of invalid addresses)
192
193 STACK gives an auxiliary stack (usually the allocation/free
194 point of a block). If this STACK is present then
195 <auxwhat>TEXT</auxwhat> will precede it.
196
197
198KIND
199----
200This is a small enumeration indicating roughly the nature of an error.
201The possible values are:
202
203 InvalidFree
204
205 free/delete/delete[] on an invalid pointer
206
207 MismatchedFree
208
209 free/delete/delete[] does not match allocation function
210 (eg doing new[] then free on the result)
211
212 InvalidRead
213
214 read of an invalid address
215
216 InvalidWrite
217
218 write of an invalid address
219
220 InvalidJump
221
222 jump to an invalid address
223
224 Overlap
225
226 args overlap other otherwise bogus in eg memcpy
227
228 InvalidMemPool
229
230 invalid mem pool specified in client request
231
232 UninitCondition
233
234 conditional jump/move depends on undefined value
235
236 UninitValue
237
238 other use of undefined value (primarily memory addresses)
239
240 SyscallParam
241
242 system call params are undefined or point to
243 undefined/unaddressible memory
244
245 ClientCheck
246
247 "error" resulting from a client check request
248
249 Leak_DefinitelyLost
250
251 memory leak; the referenced blocks are definitely lost
252
253 Leak_IndirectlyLost
254
255 memory leak; the referenced blocks are lost because all pointers
256 to them are also in leaked blocks
257
258 Leak_PossiblyLost
259
260 memory leak; only interior pointers to referenced blocks were
261 found
262
263 Leak_StillReachable
264
265 memory leak; pointers to un-freed blocks are still available
266
267
268STACK
269-----
270STACK indicates locations in the program being debugged. A STACK
271is one or more FRAMEs. The first is the innermost frame, the
272next its caller, etc.
273
274 <stack>
275 one or more FRAME
276 </stack>
277
278
279FRAME
280-----
281FRAME records a single program location:
282
283 <frame>
284 <ip>HEX64</ip>
285 optionally <obj>TEXT</obj>
286 optionally <fn>TEXT</fn>
287 optionally <file>TEXT</file>
288 optionally <line>INT</line>
289 </frame>
290
291Only the <ip> field is guaranteed to be present. It indicates a
292code ("instruction pointer") address.
293
294The optional fields, if present, appear in the order stated:
295
296* obj: gives the name of the ELF object containing the code address
297
298* fn: gives the name of the function containing the code address
299
300* file: gives the name of the source file containing the code address
301
302* line: gives the line number in the source file
303
304
305ERRORCOUNTS
306-----------
307This specifies, for each error that has been so far presented,
308the number of occurrences of that error.
309
310 <errorcounts>
311 zero or more of
312 <pair> <count>INT</count> <unique>HEX64</unique> </pair>
313 </errorcounts>
314
315Each <pair> gives the current error count <count> for the error with
316unique tag </unique>. The counts do not have to give a count for each
317error so far presented - partial information is allowable.
318
sewardj9e7212f2005-05-24 15:00:55 +0000319As at Valgrind rev 3793, error counts are only emitted at program
sewardj9829e382005-05-24 14:17:41 +0000320termination. However, it is perfectly acceptable to periodically emit
321error counts as the program is running. Doing so would facilitate a
322GUI to dynamically update its error-count display as the program runs.
323
324
325SUPPCOUNTS
326----------
327A SUPPCOUNTS block appears exactly once, after the program terminates.
328It specifies the number of times each error-suppression was used.
329Suppressions not mentioned were used zero times.
330
331 <suppcounts>
332 zero or more of
sewardj7c9e57c2005-05-24 14:21:45 +0000333 <pair> <count>INT</count> <name>TEXT</name> </pair>
sewardj9829e382005-05-24 14:17:41 +0000334 </suppcounts>
335
336The <name> is as specified in the suppression name fields in .supp
337files.