linux-test-project / lcov

LCOV
GNU General Public License v2.0
867 stars 235 forks source link

Using `--base-directory` option incorectly flagged as: --source-directory .... is unused #254

Closed Vladyyy closed 7 months ago

Vladyyy commented 7 months ago

Using the invocation below on TOT version fails with (this works with the latest release 2.0.1):

  lcov -capture --initial --no-external --output-file /tmp/tmp6m7yv_6a --directory ~/gcda_gcno_data --base-directory ~/src -j 0 --ignore-errors unused
 --source-directory ~/src" is unused.
Capturing coverage ~/gcda_gcno_data
geninfo cmd: '~/gcda_gcno_data --output-filename /tmp/tmp6m7yv_6a --source-directory ~/src --base-directory ~/src --ignore-errors unused --initial --no-external --parallel 0'
Found 36 cores.
Found gcov version: 7.3.1
Using intermediate gcov format
Writing temporary data to /tmp/geninfo_dat4gZ9
Scannin~/gcda_gcno_data for .gcno files ...
Found 491 graph files in ~/gcda_gcno_data
using: chunkSize: 10, nchunks:50, intervalLength:24
elapsed:0.0m: remaining:461 files 0.2m: 49.69 files/s 0.04 s/file (interval:49.69 f/s 0.04 s/f)
elapsed:0.0m: remaining:431 files 0.1m: 61.27 files/s 0.05 s/file (interval:79.88 f/s 0.06 s/f)
elapsed:0.0m: remaining:401 files 0.1m: 49.96 files/s 0.07 s/file (interval:36.49 f/s 0.11 s/f)
elapsed:0.0m: remaining:371 files 0.1m: 46.57 files/s 0.09 s/file (interval:38.70 f/s 0.16 s/f)
elapsed:0.1m: remaining:341 files 0.1m: 39.46 files/s 0.12 s/file (interval:24.50 f/s 0.22 s/f)
elapsed:0.1m: remaining:311 files 0.2m: 34.24 files/s 0.16 s/file (interval:20.60 f/s 0.37 s/f)
elapsed:0.1m: remaining:281 files 0.2m: 30.45 files/s 0.20 s/file (interval:18.31 f/s 0.45 s/f)
elapsed:0.1m: remaining:251 files 0.1m: 31.54 files/s 0.20 s/file (interval:42.03 f/s 0.16 s/f)
elapsed:0.1m: remaining:221 files 0.1m: 32.47 files/s 0.19 s/file (interval:42.55 f/s 0.17 s/f)
elapsed:0.2m: remaining:191 files 0.1m: 32.60 files/s 0.20 s/file (interval:33.80 f/s 0.23 s/f)
elapsed:0.2m: remaining:161 files 0.1m: 32.22 files/s 0.21 s/file (interval:28.87 f/s 0.31 s/f)
elapsed:0.2m: remaining:131 files 0.1m: 33.46 files/s 0.20 s/file (interval:58.02 f/s 0.11 s/f)
elapsed:0.2m: remaining:101 files 0.0m: 34.21 files/s 0.20 s/file (interval:46.82 f/s 0.14 s/f)
elapsed:0.2m: remaining:71 files 0.0m: 34.29 files/s 0.19 s/file (interval:35.37 f/s 0.19 s/f)
elapsed:0.2m: remaining:41 files 0.0m: 34.00 files/s 0.20 s/file (interval:30.30 f/s 0.20 s/f)
elapsed:0.2m: remaining:11 files 0.0m: 33.19 files/s 0.20 s/file (interval:24.50 f/s 0.27 s/f)
Finished processing 491 GDCA files
Apply filtering..
Filter: chunkSize 21 nChunks 46
Finished filter file processing
Finished .info-file creation
Summary coverage rate:
  source files: 950
  lines.......: 0.0% (0 of 366492 lines)
  functions...: 0.0% (0 of 329567 functions)
geninfo: WARNING: (unused) "--source-directory ~/src" is unused.
    (use "geninfo --ignore-errors unused,unused ..." to suppress this warning)
Message summary:
  3 warning messages:
    gcov: 2
    unused: 1

Omitting --base-directory option fails with:

 geninfo: ERROR: (source) unable to open~ gcda_gcno_data/tests.h: No such file or directory
geninfo: ERROR: (child) filter: 'geninfo: ERROR: (child) filter: 'ignoring data in chunk 5': child 30800 returned non-zero exit status 1 (try removing the '--parallel' option)
henry2cox commented 7 months ago

In the first: the implementation does treat the --base-directory in a similar way to --source-directory. My bug is that I added it to the sourcedir list twice...and the second appearance is unused. I believe that this is fixed in my sandbox - and will check in after some testing.

In the second invocation, the message

...unable to open~ gcda_gcno_data/tests.h ...

looks weird. Should not be a tilde character in the string.

I don't suppose you have a testcase that you can share.

Vladyyy commented 7 months ago

Sorry, that's just me modifying the paths in the output above, what I wanted to demonstrate is that the --base-directory option is needed because otherwise lcov will complain it cannot find the sources

henry2cox commented 7 months ago

FWIW: we don't use the --base-directory option - and instead use --source-directory and --build-directory. The main reason is that the more complicated projects which need such a feature contain multiple components - and need a search path rather than a single location. YMMV. We also end up using substitutions and a resolve callback - because the build layout doesn't always match the source layout (sometimes, in multiple repos).

The other observation is that your data is a bit unusual: 330K functions and 360K lines. If the numbers are right, then almost all of your code is one liners. Either you have very simple wrappers, or someone needs to start using newlines.

Vladyyy commented 7 months ago

The other observation is that your data is a bit unusual: 330K functions and 360K lines.

Interesting, I'll take a closer look. Our logging macro instantiates a lambda so I suspect that's what's going on.

henry2cox commented 7 months ago

I think that this one is fixed as well - at least the proximate cause of the misleading message. An underlying issue may still remain. Could you try again (both command line versions) and report back? Please close if the issue seems fixed. Thanks Henry

Vladyyy commented 7 months ago

Tested with TOT, I didn't hit the issue