How to find the coverage of a library opened using

2019-07-21 10:50发布

问题:

I have a C++ library (.so) which is opened using dlopen() by another application. But I need to find the code coverage of this library while run within the application using gcov. Is it possible? If yes, how can it be done?

If not, how can the issue be resolved?

回答1:

Firstly have your compiled your C++ library with the --coverage flag? I've never actually used a '.so' library with gcov before, so I'm not sure it would work anyway.

Secondly could you arrange a test version of your application to not use dlopen(), but instead be linked to a static library(.a) version of your library and still make the usual calls?