Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage report is empty when running --collect-only/--report--only separately for the compiled language case #396

Open
YuanLanier opened this issue Jun 12, 2023 · 2 comments

Comments

@YuanLanier
Copy link

Hi Simon,

We are experimenting kcov v41 with running --collect-only/--report-only separately for a .cc binary. But the coverage report ended being empty. Please advise whether we missed anything. Below are the details.

Here is a small .cc test example.

#include <iostream>
using namespace std;

int main() {

  int first_number, second_number, sum;
    
  cout << "Enter two integers: ";
  cin >> first_number >> second_number;

  // sum of two numbers in stored in variable sumOfTwoNumbers
  sum = first_number + second_number;

  // prints sum 
  cout << first_number << " + " <<  second_number << " = " << sum;     

  return 0;
}

We built the binary using :

g++ cplusplus_demo.cc -g -o demo

Then we used the below commands to generate the reports.

kcov --collect-only output-collect ./demo
kcov --report-only output-collect ./demo

The generated report is empty.
image

But if we create the report in one step, the coverage report is as expected.

kcov output-collect-simply ./demo

image

We notice in the case of running --collect-only/--report-only separately, the coverage.db size is much smaller and the html/js files
associated with the source files are also missing. Here is the comparison.

  • The case with --collect-only/--report-only:
image
  • The case without --collect-only/--report-only (collect and report in one step):
image

The previously reported issue #330 seems to be similar to this issue we are experiencing although our case is the compiled language case.

Could you please advise how to get the compiled language coverage report case working when using --collect-only/--report-only separately? Thank you!

@SimonKagstrom
Copy link
Owner

One thin which might perhaps affect this is if you've built a "PIE executable", which is effectively loaded as a shared library. If you're able to recompile your application, you may try to add the -no-pie argument to the CFLAGS/CXXFLAGS and the LDFLAGS.

Sorry for the late reply!

@SimonKagstrom
Copy link
Owner

I've tried this again, and can't seem to reproduce it here. I put your example in /tmp/a.cc, compiled to /tmp/a and ran

 src/kcov --collect-only /tmp/kcov /tmp/a
 src/kcov --report-only /tmp/kcov/ /tmp/a

and I get the same results with collect+report as without them. Ran the test on master, but I don't think anything has changed for a while which should be related to collect+report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants