Closed yi452873250 closed 1 year ago
build this github demo ,but change c to cpp ,and insert some code,finally make
I guess icov is only support c not c++
My guess would be that lcov/genhtml did not pick up the lcovrc that you edited. The lcov version you will find at top-of-tree (TOT) has some features to help debug this - but 1.16 does not.
One thing to try is to change your LCOV command to
lcov --rc lcov_branch_coverage=1 ...
and your genhtml command to
genhtml --branch-coverage ....
and see what happens (if anything). If this works - then the issue is that your lcovrc is not where you thought it was. If it doesn't work..I'm not quite sure why not. I suggest to download the latest code here - then change your capture command to add some verbosity and debug logging: lcov --capture -v -v --debug ...
and then we can see what is happening.
The other question is what version of gcc you are using (gcc -dumpversion
) - but that is unlikely to be your problem - unless your gcc is very, very old.
To the best of my knowledge: lcov supports multiple languages, including C/C++/python and a few others :-)
Henry
NOTE: ...
means "use the rest of your original command line, unchanged"
My guess would be that lcov/genhtml did not pick up the lcovrc that you edited. The lcov version you will find at top-of-tree (TOT) has some features to help debug this - but 1.16 does not.
One thing to try is to change your LCOV command to
lcov --rc lcov_branch_coverage=1 ...
and your genhtml command to
genhtml --branch-coverage ....
and see what happens (if anything). If this works - then the issue is that your lcovrc is not where you thought it was. If it doesn't work..I'm not quite sure why not. I suggest to download the latest code here - then change your capture command to add some verbosity and debug logging:
lcov --capture -v -v --debug ...
and then we can see what is happening.The other question is what version of gcc you are using (
gcc -dumpversion
) - but that is unlikely to be your problem - unless your gcc is very, very old.To the best of my knowledge: lcov supports multiple languages, including C/C++/python and a few others :-)
Henry
NOTE:
...
means "use the rest of your original command line, unchanged"
it doesn`t work ,has any idea?
Sorry. I think I misread your original issue.
Please clarify. I now think that you are complaining the lcov has picked up a bunch of branches which are related to exception handling in C++ - and you do not what to see those.
If that is the case: please take a look at the --filter branch
option (on TOT code version) and/or lcov --capture --rc geninfo_no_exception_branch=1 ...
If your issue is something different...could you explain what you wanted the result to be. I'm having a hard time to guess from context.
Sorry. I think I misread your original issue. Please clarify. I now think that you are complaining the lcov has picked up a bunch of branches which are related to exception handling in C++ - and you do not what to see those. If that is the case: please take a look at the
--filter branch
option (on TOT code version) and/orlcov --capture --rc geninfo_no_exception_branch=1 ...
If your issue is something different...could you explain what you wanted the result to be. I'm having a hard time to guess from context.
insert the option
other operate is same with before
now result ,you see
I finally want the result is the branch coverage is correct ,but you see "printf" and "delete" and "cout" ,it shouldn`t show "+ -" could you operate the branch coverage from top code demo~ thanks your reply
It appears that your compiler does not correctly mark the exception branches on lines 14, 15, 17, 18, and 20. It notes that there are branches there - but does not mark that they are associated with exceptions. As a result, 'gcov' (also part of your compiler tool chain) doesn't report exception branches there - and lcov produces the report you see. This is not a surprising result. AFAIK: every version of gcc and every version of LLVM that I have tried, has at least a few of these issues.
I guess you already compared the reports that you get when you add or remvoe the "no_exception_branch" configuration flag - so you can deduce which branches are marked as exceptions and which are not.
At this point, you have 4 options:
--filter branch
option described in the man pages (TOT). This is a hack which basically looks for conditionals in the source lines which are claimed to contain branches - and then filters out branches which appear to be unrelated to any conditional. There are a lot of limitations to this approach (see documentation/see other examples in some old issues in this github repo) - but it works fairly well in our environment. YMMV.Your other option is to take a look at the gcc/llvm implementation and improve the branch coverage implementation. Then we all benefit. (I caution that, if this was easy, it would have already been done. Not a small project.)
I recognize that this is not a terribly satisfying answer.
Henry
Did you run again with --filter branch
- and did that remove the exception branches you did not want to see?
As mentioned above: the feature works for me (and for multiple other users). If it is not working for you, then there is something unusual in your environment or you are using an old version of code.
If this is working correctly: please close the issue. If it is not working: please clarify what is not working.
Thanks Henry
on my computer ,it`s not work . --filter branch is not command
You need to be using the latest lcov source version from github. Whatever old version you are using does not implement the various new features. There is a link at the top of the main project page, to either clone the lcov repo or to download a zip file of the code.
To see which version you are currently using - and to verify that you are using the downloaded lcov - you can run which genhtml
(will give you the install path) and genhtml --version
(will tell you what install version genhtml thinks that it is).
I have downed this package
then,run make make install is it not correct?
You downloaded version 1.16. It even told you that it is from june last year. Not latest.
'Latest' is from the link at the top of the main page.
I appear not to be able to upload images - so I can't point you to it.
Look for the green button labeled <> Code
- then either Download ZIP
or Clone
.
oh·I try it agin ,my english is so bad ,so sometimes I dont get it,I m so sorry!
No worries. Much (much!) better than my Mandarin. I'm lucky to make a successful coffee shop order.
now,I download the latest code and unzip lcov-master,then cd lcovmaster dir,then run make install
but run genhtml ,it has error!
Right. You are missing required Perl modules. That is what the Perl error is telling you. You can find a list of modules that lcov wants in the README file (or in the README section of the main page from where you downloaded the zip file). It also shows one method to install missing perl modules - but your platform may have some other method.
"DateTime" is not likely to be the only module you don't have.
finally,it works,let me feel happy ,without your assistance,I cant do it
Thank you for your patient answer
Hi, I can generate the html file but it is empty. [build] geninfo: WARNING: no data generated [build] Excluded data for 96 files due to include/exclude options [build] Finished .info-file creation [build] [9/19 36% :: 4.146] Generating lcov/data/init/smp-fcgi-time-slib.info [build] [10/19 42% :: 4.199] Post-processing lcov/data/init/smp-fcgi-time-slib.info [build] FAILED: lcov/data/init/smp-fcgi-time-slib.info
My setup -IDE: Visual studio code as well -lcov version : LCOV version v1.16-67-g1c16cc3 -OS: Linux Ubuntu
I also set these flags lcov_branch_coverage = 1 and genhtml_branch_coverage = 1
I recompiled lcov and I recompiled my application but I am still stuck with this errotr above.
Any help please ?
ubuntu 20.04 lcov 1.16 example demo:
include
include
include
include
int main(int argc, const char *argv[]) { bool b = false; if (strcmp(argv[1], "1") == 0) b = true;
}
steps: 1.edit lcovrc line 100
line 193
2.build
build out foo foo.gcno
run ./foo 1
run lcov --capture --directory . --output-file foo.info --no-external
![image](https://user-images.githubusercontent.com/20902016/229049969-200cea84-e944-4d35-be16-76ec6fde1cd5.png)
run genhtml foo.info --output-directory output --title "basic test" --show-details --legend![image](https://user-images.githubusercontent.com/20902016/229050359-61f14a32-3551-4be7-9419-1d724da01b51.png)
but the result is as fllow![image](https://user-images.githubusercontent.com/20902016/229050644-81c6688d-baef-480e-ae27-a5d61632d64b.png)
what`s wrong with me ~~