@@ -101,9 +101,10 @@ if ($^O eq "msys") {
101
101
require File::Spec::Win32;
102
102
}
103
103
104
- # Constants
105
104
our @gcov_tool ;
106
105
106
+ # Constants
107
+
107
108
our $GCOV_VERSION_8_0_0 = 0x80000;
108
109
our $GCOV_VERSION_4_7_0 = 0x40700;
109
110
@@ -208,29 +209,16 @@ our $files_created = 0; # Number of output files created
208
209
our $base_directory ;
209
210
our $version ;
210
211
our $follow ;
211
- our $opt_compat_libtool ;
212
212
our $opt_no_compat_libtool ;
213
- our $rc_adjust_src_path ; # Regexp specifying parts to remove from source path
214
- our $adjust_testname ;
215
- our @ignore_errors ; # List of errors to ignore (parameter)
216
- our @opt_filter ; # list of coverpoints to ignore (parameter)
217
213
our $initial ;
218
- our $captureAll ; # look for both .gcda and lone .gcno files
219
214
our $no_recursion = 0;
220
215
our $maxdepth ;
221
216
our $no_markers = 0;
222
217
our $opt_derive_func_data = 0;
223
- our $opt_external ;
224
218
our $gcov_caps ;
225
- our @opt_config_file ;
226
- our $opt_gcov_all_blocks = 1;
227
- our $opt_adjust_unexecuted_blocks = 0;
228
- our $opt_compat ;
229
219
our %compat_value ;
230
- our $rc_auto_base = 1;
231
- our $rc_intermediate = " auto" ;
232
220
our $intermediate ;
233
- our $intervalMonitor ; # class for progress reporting
221
+ our $intervalMonitor ; # class for progress reporting
234
222
our $totalChildCpuTime = 0;
235
223
our $intervalChildCpuTime = 0; # since last updata
236
224
@@ -256,55 +244,36 @@ $SIG{__DIE__} = \&die_handler;
256
244
$ENV {" LC_ALL" } = " C" ;
257
245
258
246
# retrieve settings from RC file - use these if not overridden on command line
259
- my @rc_build_dir ;
260
- my %geninfo_rc_opts = (
261
- " geninfo_gcov_tool" => \@gcov_tool ,
262
- " geninfo_adjust_testname" => \$adjust_testname ,
263
- " geninfo_checksum" => \$lcovutil::verify_checksum ,
264
- " geninfo_compat_libtool" => \$opt_compat_libtool ,
265
- " geninfo_external" => \$opt_external ,
266
- " geninfo_gcov_all_blocks" => \$opt_gcov_all_blocks ,
267
- " geninfo_unexecuted_blocks" => \$opt_adjust_unexecuted_blocks ,
268
- " geninfo_compat" => \$opt_compat ,
269
- " geninfo_adjust_src_path" => \$rc_adjust_src_path ,
270
- " geninfo_auto_base" => \$rc_auto_base ,
271
- " geninfo_intermediate" => \$rc_intermediate ,
272
- " geninfo_no_exception_branch" => \$lcovutil::exclude_exception_branch ,
273
- ' geninfo_chunk_size' => \$defaultChunkSize ,
274
- ' geninfo_interval_update' => \$defaultInterval ,
275
- ' geninfo_capture_all' => \$captureAll ,
276
- ' build_directory' => \@rc_build_dir );
277
-
278
247
my %geninfo_opts = (" test-name|t=s" => \$test_name ,
279
248
" output-filename|o=s" => \$output_filename ,
280
249
" base-directory|b=s" => \$base_directory ,
281
250
" build-directory=s" => \@build_directory ,
282
251
" follow|f" => \$follow ,
283
- " compat-libtool" => \$opt_compat_libtool ,
252
+ " compat-libtool" => \$lcovutil:: opt_compat_libtool ,
284
253
" no-compat-libtool" => \$opt_no_compat_libtool ,
285
254
" gcov-tool=s" => \@gcov_tool ,
286
255
" initial|i" => \$initial ,
287
- " all" => \$captureAll ,
256
+ " all" => \$lcovutil::geninfo_captureAll ,
288
257
" no-recursion" => \$no_recursion ,
289
258
" no-markers" => \$no_markers ,
290
259
" derive-func-data" => \$opt_derive_func_data ,
291
- " external|e" => \$opt_external ,
260
+ " external|e" => \$lcovutil:: opt_external ,
292
261
" no-external" => \$lcovutil::opt_no_external ,
293
- " compat=s" => \$opt_compat ,);
262
+ " compat=s" => \$lcovutil::geninfo_opt_compat ,);
294
263
295
264
# Parse command line options
296
- if (!lcovutil::parseOptions(\%geninfo_rc_opts , \%geninfo_opts )) {
265
+ if (!lcovutil::parseOptions(\%lcovutil:: geninfo_rc_opts , \%geninfo_opts )) {
297
266
print (STDERR " Use $tool_name --help to get usage information\n " );
298
267
exit (1);
299
268
}
300
269
301
270
$buildDirSearchPath =
302
271
SearchPath-> new(' build directory' ,
303
- @build_directory ? @build_directory : @rc_build_dir );
272
+ @build_directory ? @build_directory : @lcovutil:: rc_build_dir );
304
273
305
274
# Check regexp
306
- if (defined ($rc_adjust_src_path )) {
307
- my ($pattern , $replace ) = split (/ \s *=>\s */ , $rc_adjust_src_path );
275
+ if (defined ($lcovutil:: rc_adjust_src_path )) {
276
+ my ($pattern , $replace ) = split (/ \s *=>\s */ , $lcovutil:: rc_adjust_src_path );
308
277
# If no replacement is specified, simply remove pattern
309
278
$replace = ' ' unless defined ($replace );
310
279
my $p = " s#$pattern #$replace #g" ;
@@ -313,17 +282,17 @@ if (defined($rc_adjust_src_path)) {
313
282
my $str = eval { ' $test =~ ' . $p . ' ;' };
314
283
if ($@ ) {
315
284
lcovutil::ignorable_error($lcovutil::ERROR_FORMAT ,
316
- " Invalid 'geninfo_adjust_src_path=$rc_adjust_src_path ' syntax: '$@ '"
285
+ " Invalid 'geninfo_adjust_src_path=$lcovutil:: rc_adjust_src_path ' syntax: '$@ '"
317
286
);
318
287
} else {
319
288
push (@lcovutil::file_subst_patterns , [$p , 0]);
320
289
}
321
290
}
322
291
323
- if ($captureAll && $initial ) {
292
+ if ($lcovutil::geninfo_captureAll && $initial ) {
324
293
lcovutil::ignorable_error($lcovutil::ERROR_USAGE ,
325
294
" '--all' ignored when '--initial' is used" );
326
- $captureAll = undef ;
295
+ $lcovutil::geninfo_captureAll = undef ;
327
296
}
328
297
329
298
if (defined ($lcovutil::tempdirname )) {
@@ -335,13 +304,13 @@ if (defined($lcovutil::tempdirname)) {
335
304
336
305
# Merge options
337
306
if (defined ($opt_no_compat_libtool )) {
338
- $opt_compat_libtool = ($opt_no_compat_libtool ? 0 : 1);
339
- $opt_no_compat_libtool = undef ;
307
+ $lcovutil:: opt_compat_libtool = ($opt_no_compat_libtool ? 0 : 1);
308
+ $opt_no_compat_libtool = undef ;
340
309
}
341
310
342
- if (defined ($opt_external )) {
311
+ if (defined ($lcovutil:: opt_external )) {
343
312
$lcovutil::opt_no_external = 0;
344
- $opt_external = undef ;
313
+ $lcovutil:: opt_external = undef ;
345
314
}
346
315
347
316
my $start = Time::HiRes::gettimeofday();
@@ -388,18 +357,19 @@ if (system_no_output(3, @gcov_tool, "--help") == -1) {
388
357
$gcov_caps = get_gcov_capabilities();
389
358
390
359
# Determine intermediate mode
391
- if ($rc_intermediate eq " 0" ) {
360
+ if ($lcovutil:: rc_intermediate eq " 0" ) {
392
361
$intermediate = 0;
393
- } elsif ($rc_intermediate eq " 1" ) {
362
+ } elsif ($lcovutil:: rc_intermediate eq " 1" ) {
394
363
$intermediate = 1;
395
- } elsif (lc ($rc_intermediate ) eq " auto" ) {
364
+ } elsif (lc ($lcovutil:: rc_intermediate ) eq " auto" ) {
396
365
# Use intermediate format if supported by gcov and not conflicting with
397
366
# exception branch exclusion
398
367
$intermediate = (($gcov_caps -> {' intermediate-format' } &&
399
368
!$lcovutil::exclude_exception_branch ) ||
400
369
$gcov_caps -> {' json-format' }) ? 1 : 0;
401
370
} else {
402
- die (" invalid value for geninfo_intermediate: " . " '$rc_intermediate '\n " );
371
+ die (" invalid value for geninfo_intermediate: " .
372
+ " '$lcovutil::rc_intermediate '\n " );
403
373
}
404
374
405
375
if ($gcov_version >= (9 << 16) &&
@@ -428,14 +398,14 @@ push(@gcov_tool, "-b")
428
398
if ($gcov_caps -> {' branch-probabilities' } &&
429
399
($lcovutil::br_coverage ||
430
400
$lcovutil::func_coverage ||
431
- $opt_adjust_unexecuted_blocks ));
401
+ $lcovutil:: opt_adjust_unexecuted_blocks ));
432
402
push (@gcov_tool , " -c" )
433
403
if ($gcov_caps -> {' branch-counts' } &&
434
404
$lcovutil::br_coverage );
435
405
push (@gcov_tool , " -a" )
436
406
if ($gcov_caps -> {' all-blocks' } &&
437
- $opt_gcov_all_blocks &&
438
- $lcovutil::br_coverage &&
407
+ $lcovutil:: opt_gcov_all_blocks &&
408
+ $lcovutil::br_coverage &&
439
409
!$intermediate );
440
410
if ($gcov_caps -> {' hash-filenames' }) {
441
411
push (@gcov_tool , " -x" );
@@ -445,10 +415,10 @@ if ($gcov_caps->{'hash-filenames'}) {
445
415
push (@gcov_tool , ' -i' ) if $intermediate ;
446
416
447
417
# Determine compatibility modes
448
- parse_compat_modes($opt_compat );
418
+ parse_compat_modes($lcovutil::geninfo_opt_compat );
449
419
450
- push (@opt_filter , " region" , " branch_region" ) unless $no_markers ;
451
- parse_cov_filters(@opt_filter );
420
+ push (@lcovutil:: opt_filter , " region" , " branch_region" ) unless $no_markers ;
421
+ parse_cov_filters(@lcovutil:: opt_filter );
452
422
453
423
# Make sure test names only contain valid characters
454
424
if ($test_name =~ s /\W / _/ g ) {
@@ -457,7 +427,7 @@ if ($test_name =~ s/\W/_/g) {
457
427
}
458
428
459
429
# Adjust test name to include uname output if requested
460
- if ($adjust_testname ) {
430
+ if ($lcovutil::geninfo_adjust_testname ) {
461
431
$test_name .= " __" . ` uname -a` ;
462
432
$test_name =~ s /\W / _/ g ;
463
433
}
@@ -1008,7 +978,8 @@ sub find_files
1008
978
my ($name , $d , $e ) =
1009
979
File::Basename::fileparse($directory , qr /\. [^.]*/ );
1010
980
if ($e ne $ext &&
1011
- (!$captureAll || $e ne $graph_file_extension )) {
981
+ (!$lcovutil::geninfo_captureAll || $e ne $graph_file_extension )
982
+ ) {
1012
983
$self -> [2]-> {$directory } = [
1013
984
$lcovutil::ERROR_USAGE ,
1014
985
" $directory has unsupported extension: expected '$ext '" .
@@ -1249,8 +1220,8 @@ sub gen_info(@)
1249
1220
1250
1221
$builder -> find_files($initial , @_ );
1251
1222
if (!defined ($initial ) &&
1252
- defined ($captureAll ) &&
1253
- $captureAll ) {
1223
+ defined ($lcovutil::geninfo_captureAll ) &&
1224
+ $lcovutil::geninfo_captureAll ) {
1254
1225
$builder -> find_files(2, @_ );
1255
1226
}
1256
1227
my $filelist = $builder -> worklist();
@@ -1260,8 +1231,8 @@ sub gen_info(@)
1260
1231
$lcovutil::maxParallelism ?
1261
1232
(int ($total / $lcovutil::maxParallelism )) :
1262
1233
1;
1263
- if (defined ($defaultChunkSize )) {
1264
- if ($defaultChunkSize =~ / ^(\d +)\s *(%?)$ / ) {
1234
+ if (defined ($lcovutil:: defaultChunkSize )) {
1235
+ if ($lcovutil:: defaultChunkSize =~ / ^(\d +)\s *(%?)$ / ) {
1265
1236
if (defined ($2 ) && $2 ) {
1266
1237
# a percentage
1267
1238
$chunkSize = int ($total * $1 / 100);
@@ -1271,7 +1242,8 @@ sub gen_info(@)
1271
1242
}
1272
1243
} else {
1273
1244
lcovutil::ignorable_error($lcovutil::ERROR_FORMAT ,
1274
- " geninfo_chunk_size '$defaultChunkSize ' is not recognized" );
1245
+ " geninfo_chunk_size '$lcovutil::defaultChunkSize ' is not recognized"
1246
+ );
1275
1247
}
1276
1248
}
1277
1249
# Need to balance time in child vs. time to merge child data -
@@ -1307,9 +1279,9 @@ sub gen_info(@)
1307
1279
my $processedChunks = 0;
1308
1280
1309
1281
# process at least 5% of files before printing stats
1310
- $defaultInterval = 5 unless defined ($defaultInterval );
1282
+ $lcovutil:: defaultInterval = 5 unless defined ($lcovutil:: defaultInterval );
1311
1283
1312
- my $intervalLength = int ($total * $defaultInterval / 100);
1284
+ my $intervalLength = int ($total * $lcovutil:: defaultInterval / 100);
1313
1285
my $start = Time::HiRes::gettimeofday();
1314
1286
1315
1287
$intervalMonitor =
@@ -1476,8 +1448,10 @@ sub gen_info(@)
1476
1448
--$currentParallel ;
1477
1449
_merge_one_child($child , \%children , $tempFileExt , $childstatus );
1478
1450
}
1479
- info(" Finished processing %d " .
1480
- ($initial ? ' GCNO' : ($captureAll ? ' GCDA/GCNO' : ' GCDA' )) .
1451
+ info(" Finished processing %d "
1452
+ .
1453
+ ($initial ? ' GCNO' :
1454
+ ($lcovutil::geninfo_captureAll ? ' GCDA/GCNO' : ' GCDA' )) .
1481
1455
" file%s \n " ,
1482
1456
$processedFiles ,
1483
1457
1 == $processedFiles ? ' ' : ' s' );
@@ -1646,7 +1620,7 @@ sub process_dafile($$$$)
1646
1620
($instr , $graph ) = read_gcno($bb_filename );
1647
1621
1648
1622
# Try to find base directory automatically if requested by user
1649
- if ($rc_auto_base ) {
1623
+ if ($lcovutil:: rc_auto_base ) {
1650
1624
$base_dir = find_base_from_source($base_dir ,
1651
1625
[keys (%{$instr }), keys (%{$graph })]);
1652
1626
}
@@ -1894,7 +1868,7 @@ sub process_dafile($$$$)
1894
1868
lcovutil::debug(
1895
1869
" $source_filename :$line_number : unexecuted block on non-branch line with count=$hit \n "
1896
1870
);
1897
- if ($opt_adjust_unexecuted_blocks ) {
1871
+ if ($lcovutil:: opt_adjust_unexecuted_blocks ) {
1898
1872
$hit = 0;
1899
1873
} else {
1900
1874
lcovutil::ignorable_warning(
@@ -2597,7 +2571,7 @@ sub intermediate_json_to_info($)
2597
2571
lcovutil::debug(
2598
2572
" $filename :$line : unexecuted block on non-branch line with count=$count \n "
2599
2573
);
2600
- if ($opt_adjust_unexecuted_blocks ) {
2574
+ if ($lcovutil:: opt_adjust_unexecuted_blocks ) {
2601
2575
$count = 0;
2602
2576
} else {
2603
2577
lcovutil::ignorable_warning($ERROR_INCONSISTENT_DATA ,
@@ -2875,7 +2849,7 @@ sub process_intermediate($$$$)
2875
2849
}
2876
2850
2877
2851
# Try to find base directory automatically if requested by user
2878
- if ($rc_auto_base ) {
2852
+ if ($lcovutil:: rc_auto_base ) {
2879
2853
$base = find_base_from_source($base , [keys (%data )]);
2880
2854
}
2881
2855
}
@@ -3061,7 +3035,7 @@ sub process_graphfile($$)
3061
3035
($instr , $graph ) = read_gcno($graph_filename );
3062
3036
3063
3037
# Try to find base directory automatically if requested by user
3064
- if ($rc_auto_base ) {
3038
+ if ($lcovutil:: rc_auto_base ) {
3065
3039
$base_dir = find_base_from_source($base_dir ,
3066
3040
[keys (%{$instr }), keys (%{$graph })]);
3067
3041
}
@@ -4010,9 +3984,9 @@ sub parse_compat_modes($)
4010
3984
%compat_value = %COMPAT_MODE_DEFAULTS ;
4011
3985
4012
3986
# Add old style specifications
4013
- if (defined ($opt_compat_libtool )) {
3987
+ if (defined ($lcovutil:: opt_compat_libtool )) {
4014
3988
$compat_value {$COMPAT_MODE_LIBTOOL } =
4015
- $opt_compat_libtool ? $COMPAT_VALUE_ON :
3989
+ $lcovutil:: opt_compat_libtool ? $COMPAT_VALUE_ON :
4016
3990
$COMPAT_VALUE_OFF ;
4017
3991
}
4018
3992
0 commit comments