memory-leaksruntimevalgrind

Is there a way to suppress process id in valgrind output?


I have two valgrind reports and I want to diff them. With pid in each line, diff obviously finds everything different. If I can suppress the pid in output, it will be easier for me to diff. Is there a way to suppress process id in valgrind output ?

Background:

My program is a simulator which is meant to be running forever (until manually killed). After it does its initialization, I can feed it networking packets and it processes them. Using valgrind, I've narrowed down and fixed the memory leaks that occur during packet processing. However, I still have a very small leak. I was trying to figure out if there was a way for me to reset the memory leak count in valgrind at runtime. If I could=> after sending one packet, I'd zero out the memory errors, and only those errors that would be happening at subsequent packet pass would be reported. But I couldn't figure out how to do this.

So, I thought of taking the diff of two valgrind reports: one with 1 packet and another with l10 packets. That should help me narrow down the culprit.

If there's a better alternative to solving this without using diff, please let me know!


Solution

  • I haven't seen an option that prevents the pid from being printed, but I was looking for a way to add a time limit to how long valgrind ran so I may have missed it.

    That said, each line begins with "==pid==" so you could make a prog/script to simply strip that part out, then run diff on what is left from each run. Valgrind doesn't use "=" anywhere else so something like this (in c++) should work:

    string line;
    line = fileIN.readline();
    int start = line.find_last_of('='); //index of last instance of char
    //you need to start one behind the last index
    //and end one index before the size
    line = line.substr( (start + 1), (line.size() - 1) ); 
    

    Right now I think that's your best bet.