Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c

gcc

valgrind

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.

like image 375
elinus Avatar asked Dec 02 '13 05:12

elinus


2 Answers

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).

like image 50
hyde Avatar answered Oct 04 '22 22:10

hyde


Valgrind watches upon code that being executed. Shared library is never executed unless some program uses them. If some code never executed, valgrind will never notice it.

like image 39
keltar Avatar answered Oct 04 '22 21:10

keltar