SimonKagstrom / kcov

Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
http://simonkagstrom.github.io/kcov/
GNU General Public License v2.0
713 stars 109 forks source link

Warn users when output directory contains target binary #272

Open mcraveiro opened 5 years ago

mcraveiro commented 5 years ago

Hi kcov developers,

Many thanks for a very useful tool. I just did something really silly and it took me a little while to figure it out, which led me to wonder if its not worth alerting users: I set my output directory to the same directory as the binary, and as a result got the following error:

kcov: error: elf_begin failed on /FULL_PATH_TO_DIR/dogen.annotations.tests

kcov: error: Can't start/attach to /FULL_PATH_TO_DIR/dogen.annotations.tests

This happened because kcov appears to delete the target binary and create a simlink to the reporting directory, and then (I assume) tries to open the directory as if it as a ELF binary:

lrwxrwxrwx  1 marco marco      150 Oct 15 15:48 dogen.annotations.tests -> /FULL_PATH_TO_DIR/dogen.annotations.tests.d5518294725c92ef/
drwxr-xr-x  4 marco marco     4096 Oct 15 15:48 dogen.annotations.tests.d5518294725c92ef

It may be worth issuing a warning informing users that their command line options are not sensible :-) Apologies if this has already been submitted, but could not spot it.

Many thanks for your time

Marco

SimonKagstrom commented 5 years ago

Hehe, that's one way I didn't think of before!

But I agree, it's not good behavior to overwrite the binary, so we should gate that usage.

mcraveiro commented 5 years ago

Thanks @SimonKagstrom. By the by, may I just add that, after years of gcov and associated tooling, kcov was a joy to setup! I had even given up on having code coverage for a while, just out of fear of facing gcov, but then I saw kcov! :-) got it working in slightly over half-a-day for both coveralls and codecov! amazing stuff.

BotellaA commented 5 years ago

Thanks a lot for this issue!! Really helpful