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