VALGRIND: How to use valgrind for ".so" library?

c, c++, gcc, valgrind

Solution

Not directly. Library does not have an entry point where to start executing it, and valgrind only checks code that is actually executing.

Still, if you want to test a library with valgrind, there is a simple way. Just write a test program, which uses the library in the way that tests the parts and features of library you want tested. Then valgrind that.

It is probably better to write several small test programs to test different features and use patterns, instead if one big one which tries to test everything in one execution (easier to isolate any problem valgrind finds, faster to run).

Problem

Do i need to use valgrind on each program file with which ".so" is made.. or is there any we can run valgrind directly on ".so" library. please provide steps for later.

Original source