c++valgrindsuppression

Is there a way to reuse valgrind suppression files?


On my work I need to profile some software and got some suppression files that were recorded an unknown time ago. One of these files (logging.supp) is used to suppress logging errors.

I guess the logging and some other parts are changed between generation of the suppression file and my my profiling.

As far as I figure out valgrind uses the stack to identify if a leak should be suppressed.

Do I need to regenerate the suppression files or is there a way to change something in the files?

Example suppression entry:

{
<insert_a_suppression_name_here>
Memcheck:Leak
fun:_Znwj
fun:_ZN3tsd6common5types8SmartPtrINS0_7logging19LogSimpleDateFormatEEaSEPS4_
fun:_ZN3tsd6common7logging23LogDatePatternConverterC1ESt6vectorISsSaISsEE
fun:_ZN3tsd6common7logging16LogPatternParser15createConverterEcSt6vectorISsSaISsEE
fun:_ZN3tsd6common7logging16LogPatternParser17finalizeConverterEcSsiSsNS0_5types8SmartPtrINS1_17LogFormattingInfoEEERSt6vectorINS4_INS1_19LogPatternConverterEEESaIS9_EERS7_IS6_SaIS6_EE
fun:_ZN3tsd6common7logging16LogPatternParser5parseESsRSt6vectorINS0_5types8SmartPtrINS1_19LogPatternConverterEEESaIS7_EERS3_INS5_INS1_17LogFormattingInfoEEESaISC_EE
fun:_ZN3tsd6common7logging16PatternLogLayout15activateOptionsEv
fun:_ZN3tsd6common7logging16PatternLogLayoutC1ERKSs
fun:_ZN3tsd6common7logging14LoggingManager4initENS0_5types8SmartPtrINS1_23LogManagerConfigurationEEE
fun:_ZN3tsd6common7logging14LoggingManager4initERKSsS4_
fun:_ZN3tsd6common7logging14LoggingManager9getLoggerERKSs
fun:_ZN3tsd6common7logging6LoggerC1ERKSs
}

I found and liked this answer:

https://stackoverflow.com/a/14781867/2764334

Can I use the dots also to ignore some functions that are intermediate stack entries?

How are the function names generated? to me it looks like either _Znjw or _ZN3tsd is the name for main?

Can you help me where to find documentation to the above questions?


Solution

  • Can I use the dots also to ignore some functions that are intermediate stack entries?

    Yes.

    How are the function names generated?

    They are mangled function names, as generated by the compiler; they contain the namespace and/or class scope, the function name, and the arguments. You can use c++filt to demangle them.

    to me it looks like either _Znjw or _ZN3tsd is the name for main?

    _Znjw is operator new(unsigned). _ZN3tsd is the prefix for things in namespace tsd.

    Can you help me where to find documentation to the above questions?

    Valgrind suppression files are documented here. The GNU mangling format doesn't seem to be officially documented; use Google and take whatever you find with a pinch of salt (assuming you don't want to trawl through the compiler source to see how the names are generated).