|
From: Patrick M. R. <rut...@gm...> - 2010-03-10 09:38:10
|
So, I took some time out today to learn how to get into the habit of
using valgrind on server code here at work. One thing that really
bugged me was that I could not devise any obvious way to dump
suppressions to a specified file during a run. If I tried
--log-file=foo.supp then all of the error prompts would go to foo.supp
as well, making valgrind completely unusable. I also tried concocting
some magic with 2>&1 or tee(1), but no dice. I ended up digging into
the valgrind source and adding something like this to around like 390
of m_errormgr.c in a fresh unzip of the 3.5.0 source:
========= [BEGIN CODE] =============
/* And now display it. */
if (! VG_(clo_xml) )
{
SysRes fd;
char* buff = (HChar*)VG_(indexXA)(text, 0);
// the simple case
VG_(printf)("%s", (HChar*) VG_(indexXA)(text, 0) );
fd = VG_(open)
(
"out.supp",
VKI_O_WRONLY | VKI_O_CREAT | VKI_O_APPEND,
VKI_S_IRUSR | VKI_S_IWUSR | VKI_S_IRGRP | VKI_S_IROTH
);
if( ( ! fd._isError) && (fd._val != -1) )
VG_(write)(fd._val, buff, VG_(strlen(buff)));
}
========= [END CODE] =============
In English, what does is opens "out.supp" for appending whenever a
suppression is about to print, and then directs a copy of the
suppression to the bottom of the out.supp file.
I find this extremely useful; I can run my valgrind command and just
type "Y" at the suppression prompts, without a care in the world,
knowing that they will be "stacked up" in the out.supp file.
Then I can re-run valgrind on another run of the program, again
without a thought as to how to save suppressions.
It sure does beat manually copy-pasting them from the terminal!
Any thoughts guys?
I know probably did a bunch of things wrong in that code, my
familiarity with the valgrind source only extends to the 30 minutes I
just spent with it.
-Patrick
|