|
From: Ashley P. <as...@qu...> - 2006-03-03 14:42:11
Attachments:
xml-putout.patch
xml2raw.pl
|
Hi, I've been looking at writing a program to help with viewing large numbers of memcheck output files simultaneously, the basic idea is to take outs of output files and find errors that are common between all of them and just display these errors once (in exactly the same way that memcheck only reports each error once if it happens within the same process). The first step to doing this is to be able to parse and understand the xml from a single process and I've found some inconsistencies whilst doing this, the good news is that the xml is simple enough that you can slurp up the xml files in perl using the XMLin($filename) function which is a good start, the bad news is that valgrind/memcheck doesn't always produce good xml and it's missing some of the information that is in the normal output :( I've written a perl script which loads the xml and tries to re-create what the non-xml output of valgrind would have been for the same program, on it's own this is clearly pointless but as a stepping stone to a version that can load multiple files it's very useful and also as I've found out it makes a good test that the xml itself is providing the information needed. The first thing that I spotted is that information is missing from the xml output, in particular the malloc/free in use at exit numbers, I've had to make these up in my script although it would be easy enough to add them. malloc/free: in use at exit: 0 bytes in 0 blocks. malloc/free: 0 allocs, 0 frees, 0 bytes allocated. In order to test this code I hooked it into the test-suite in such a way that they run the memcheck tests in xml mode, use my script to convert the output to native format and then pass/fail the test as normal. I've got to the stage now where my script is as correct as it can be save for whitespace pedantry. A number of the tests are failing because the tests themselves write to stderr which then gets spliced with the xml and lost in the translation, I can't do anything about this without changing the tests to use valgrind log file and messing with the expected output :( I've fixed the xml produced in one case and extended my script to handle this but and as I say I've now got as far as I can with my perl script and am in the realms of pedantry and going any further down this road is going to require changes to valgrind source and mucking about with the way tests are run. The current test failures are as follows, I get 36 failures with xml and 16 without: memcheck/tests/addressable (stderr) The test produces invalid xml due to the use of fork(). memcheck/tests/badjump (stderr) memcheck/tests/match-overrun (stderr) memcheck/tests/describe-block (stderr) memcheck/tests/supp_unknown (stderr) Whitespace only. memcheck/tests/badjump2 (stderr) memcheck/tests/sigaltstack (stderr) memcheck/tests/sigkill (stderr) memcheck/tests/sigprocmask (stderr) memcheck/tests/toobig-allocs (stderr) memcheck/tests/x86/scalar_fork (stderr) The test writes to stderr. memcheck/tests/buflen_check (stderr) memcheck/tests/writev (stderr) Symbol names differ and tests write to stderr memcheck/tests/erringfds (stderr) memcheck/tests/malloc3 (stderr) valgrind is outputing warning which aren't in xml. memcheck/tests/badpoll (stderr) memcheck/tests/execve2 (stderr) memcheck/tests/execve (stderr) memcheck/tests/fwrite (stderr) Symbol names differ? memcheck/tests/leak-0 (stderr) memcheck/tests/leak-regroot (stderr) memcheck/tests/pointer-trace (stderr) xml is missing required malloc info. memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-tree (stderr) xml is missing required into and my script isn't noting the --leak-resolution=high option. memcheck/tests/trivialleak (stderr) memcheck/tests/mempool (stderr) memcheck/tests/nanoleak (stderr) my script isn't noting the --leak-check option memcheck/tests/partial_load_dflt (stderr) memcheck/tests/partial_load_ok (stderr) memcheck/tests/partiallydefinedeq (stderr) Whitespace and missing xml info memcheck/tests/stack_switch (stderr) I'm not sure, I think the test would have failed anyway. memcheck/tests/x86/scalar (stderr) Lots of diffs but mostly symbol names. memcheck/tests/x86/scalar_exit_group (stderr) memcheck/tests/x86/scalar_supp (stderr) memcheck/tests/xml1 (stderr) I'd expect this one to fail. In cases where the symbol names differ it's mostly because of the (below main) changes and the tests fail anyway, even without my xml hacks. I'm attaching both my script and a patch which fixes some of the xml and provides hooks into the tests, if you think it's worth me continuing along these lines then please say so, I've achieved my original purpose with this code it doesn't seem worth me chasing corner cases unless this is going to be merged. I do however plan to work on fixing the remaining xml problems (memcheck/tests/malloc3 memcheck/tests/leak-0) et. al. Ashley, |