can gcov deal with shared object?

前端 未结 1 1609
太阳男子
太阳男子 2021-01-06 11:44

I am recently using gcov to collect the code coverage info. gcov plays well with executable application :) , but when I try to load a .so file, I got this error: unknown sym

相关标签:
1条回答
  • 2021-01-06 12:34

    I ran into that problem too, but have since solved it. I just use the --coverage option in both CPPFLAGS and LDFLAGS. I think that should take care of the compile issue for you.

    The shared object still doesn't seem to produce .gcda files though and I'm not sure how to solve that problems. Like you said, it works fine with executables, but shared objects seem to have some problems.

    EDIT: Apparently, gcov does support shared objects now. I did a significant amount of research yesterday and found conflicting answers, so I mailed the gcc-help list. See thread here: http://gcc.gnu.org/ml/gcc-help/2010-09/msg00130.html. I haven't tried solving my problem based on the answer yet, but I will post back when I do.

    EDIT 2: Shared objects do work with gcov (or rather than --cover option with gcc). There's another post with details here: gcov: producing .gcda output from shared library?. It also references the same thread above.

    0 讨论(0)
提交回复
热议问题