@@ -196,8 +196,8 @@ sub read_gcno_word(*;$$);
196
196
sub read_gcno_value (*$;$$);
197
197
sub read_gcno_string (*$);
198
198
sub read_gcno_lines_record (*$$$$$$);
199
- sub determine_gcno_split_crc ($$$);
200
- sub read_gcno_function_record (*$$$$);
199
+ sub determine_gcno_split_crc ($$$$ );
200
+ sub read_gcno_function_record (*$$$$$ );
201
201
sub read_gcno ($);
202
202
sub get_gcov_capabilities ();
203
203
sub get_overall_line ($$$$);
419
419
420
420
@data_directory = @ARGV ;
421
421
422
+ debug(" $lcov_version \n " );
423
+
422
424
# Check for help option
423
425
if ($help )
424
426
{
@@ -3363,20 +3365,20 @@ sub read_gcno_lines_record(*$$$$$$)
3363
3365
}
3364
3366
3365
3367
#
3366
- # determine_gcno_split_crc(handle, big_endian, rec_length)
3368
+ # determine_gcno_split_crc(handle, big_endian, rec_length, version )
3367
3369
#
3368
3370
# Determine if HANDLE refers to a .gcno file with a split checksum function
3369
3371
# record format. Return non-zero in case of split checksum format, zero
3370
3372
# otherwise, undef in case of read error.
3371
3373
#
3372
3374
3373
- sub determine_gcno_split_crc ($$$)
3375
+ sub determine_gcno_split_crc ($$$$ )
3374
3376
{
3375
- my ($handle , $big_endian , $rec_length ) = @_ ;
3377
+ my ($handle , $big_endian , $rec_length , $version ) = @_ ;
3376
3378
my $strlen ;
3377
3379
my $overlong_string ;
3378
3380
3379
- return 1 if ($gcov_version >= $GCOV_VERSION_4_7_0 );
3381
+ return 1 if ($version >= $GCOV_VERSION_4_7_0 );
3380
3382
return 1 if (is_compat($COMPAT_MODE_SPLIT_CRC ));
3381
3383
3382
3384
# Heuristic:
@@ -3408,15 +3410,15 @@ sub determine_gcno_split_crc($$$)
3408
3410
}
3409
3411
3410
3412
#
3411
- # read_gcno_function_record(handle, graph, big_endian, rec_length)
3413
+ # read_gcno_function_record(handle, graph, big_endian, rec_length, version )
3412
3414
#
3413
3415
# Read a gcno format function record from handle and add the relevant data
3414
3416
# to graph. Return (filename, function) on success, undef on error.
3415
3417
#
3416
3418
3417
- sub read_gcno_function_record (*$$$$)
3419
+ sub read_gcno_function_record (*$$$$$ )
3418
3420
{
3419
- my ($handle , $bb , $fileorder , $big_endian , $rec_length ) = @_ ;
3421
+ my ($handle , $bb , $fileorder , $big_endian , $rec_length , $version ) = @_ ;
3420
3422
my $filename ;
3421
3423
my $function ;
3422
3424
my $lineno ;
@@ -3428,7 +3430,8 @@ sub read_gcno_function_record(*$$$$)
3428
3430
# Determine if this is a function record with split checksums
3429
3431
if (!defined ($gcno_split_crc )) {
3430
3432
$gcno_split_crc = determine_gcno_split_crc($handle , $big_endian ,
3431
- $rec_length );
3433
+ $rec_length ,
3434
+ $version );
3432
3435
return undef if (!defined ($gcno_split_crc ));
3433
3436
}
3434
3437
# Skip cfg checksum word in case of split checksums
@@ -3451,6 +3454,33 @@ sub read_gcno_function_record(*$$$$)
3451
3454
return ($filename , $function );
3452
3455
}
3453
3456
3457
+ #
3458
+ # map_gcno_version
3459
+ #
3460
+ # Map version number as found in .gcno files to the format used in geninfo.
3461
+ #
3462
+
3463
+ sub map_gcno_version ($)
3464
+ {
3465
+ my ($version ) = @_ ;
3466
+ my ($a , $b , $c );
3467
+ my ($major , $minor );
3468
+
3469
+ $a = $version >> 24;
3470
+ $b = $version >> 16 & 0xff;
3471
+ $c = $version >> 8 & 0xff;
3472
+
3473
+ if ($a < ord (' A' )) {
3474
+ $major = $a - ord (' 0' );
3475
+ $minor = ($b - ord (' 0' )) * 10 + $c - ord (' 0' );
3476
+ } else {
3477
+ $major = ($a - ord (' A' )) * 10 + $b - ord (' 0' );
3478
+ $minor = $c - ord (' 0' );
3479
+ }
3480
+
3481
+ return $major << 16 | $minor << 8;
3482
+ }
3483
+
3454
3484
#
3455
3485
# read_gcno(filename)
3456
3486
#
@@ -3481,6 +3511,7 @@ sub read_gcno($)
3481
3511
my $instr ;
3482
3512
my $graph ;
3483
3513
my $filelength ;
3514
+ my $version ;
3484
3515
local *HANDLE;
3485
3516
3486
3517
open (HANDLE, " <" , $gcno_filename ) or goto open_error;
@@ -3497,8 +3528,12 @@ sub read_gcno($)
3497
3528
} else {
3498
3529
goto magic_error;
3499
3530
}
3500
- # Skip version and stamp
3501
- graph_skip(*HANDLE, 8, " version and stamp" ) or goto incomplete;
3531
+ # Read version
3532
+ $version = read_gcno_value(*HANDLE, $big_endian , " compiler version" );
3533
+ $version = map_gcno_version($version );
3534
+ debug(sprintf (" found version 0x%08x\n " , $version ));
3535
+ # Skip stamp
3536
+ graph_skip(*HANDLE, 4, " file timestamp" ) or goto incomplete;
3502
3537
while (!eof (HANDLE)) {
3503
3538
my $next_pos ;
3504
3539
my $curr_pos ;
@@ -3528,7 +3563,7 @@ sub read_gcno($)
3528
3563
if ($tag == $tag_function ) {
3529
3564
($filename , $function ) = read_gcno_function_record(
3530
3565
*HANDLE, $bb , $fileorder , $big_endian ,
3531
- $length );
3566
+ $length , $version );
3532
3567
goto incomplete if (!defined ($function ));
3533
3568
} elsif ($tag == $tag_lines ) {
3534
3569
# Read lines record
0 commit comments