From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2041) id 4D94A3858403; Mon, 25 Jul 2022 22:07:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D94A3858403 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Vladimir Mezentsev To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] gprofng: fix bug 29392 - Unexpected line format in summary file X-Act-Checkin: binutils-gdb X-Git-Author: Ruud van der Pas X-Git-Refname: refs/heads/master X-Git-Oldrev: 408520bcaa874edb0e37506e8559b2e4194dca05 X-Git-Newrev: c69c2b6033a98d8fd28386ad92cada01dfd9b823 Message-Id: <20220725220747.4D94A3858403@sourceware.org> Date: Mon, 25 Jul 2022 22:07:47 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2022 22:07:47 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc69c2b6033a9= 8d8fd28386ad92cada01dfd9b823 commit c69c2b6033a98d8fd28386ad92cada01dfd9b823 Author: Ruud van der Pas Date: Fri Jul 22 05:59:17 2022 -0700 gprofng: fix bug 29392 - Unexpected line format in summary file =20 gprofng/Changelog: 2022-07-22 Ruud van der Pas =20 PR gprofng/29392 * gp-display-html/gp-display-html.in: modified a regex, plus the code to handle the results; renamed a variable to improve the consistency in naming. Diff: --- gprofng/gp-display-html/gp-display-html.in | 99 +++++++++++++++++++++++---= ---- 1 file changed, 78 insertions(+), 21 deletions(-) diff --git a/gprofng/gp-display-html/gp-display-html.in b/gprofng/gp-displa= y-html/gp-display-html.in index a2e629a1633..774dbd537b3 100644 --- a/gprofng/gp-display-html/gp-display-html.in +++ b/gprofng/gp-display-html/gp-display-html.in @@ -7494,11 +7494,16 @@ sub get_function_info =20 my ($FSUMMARY_FILE) =3D @_; =20 - my @function_info =3D (); - my %functions_address_and_index =3D (); - my %LINUX_vDSO =3D (); - my %function_view_structure =3D (); - my %addressobjtextm =3D (); +#-------------------------------------------------------------------------= ----- +# The regex section. +#-------------------------------------------------------------------------= ----- + my $white_space_regex =3D '\s*'; + + my @function_info =3D (); + my %function_address_and_index =3D (); + my %LINUX_vDSO =3D (); + my %function_view_structure =3D (); + my %addressobjtextm =3D (); #-------------------------------------------------------------------------= ----- # TBD: This structure is no longer used and most likely can be removed. #-------------------------------------------------------------------------= ----- @@ -7697,14 +7702,53 @@ sub get_function_info # or: # Source File: /name_of_source_file #-------------------------------------------------------------------------= ----- - if ( not ($line =3D~ /^(\s*)(.*):(\s+)([^\s]+|(.*))/)) + $line =3D~ s/^\s+//; + + my @input_fields =3D split (":", $line); + my $no_of_elements =3D scalar (@input_fields); + + gp_message ("debugXL", $subr_name, "#input_fields =3D $#input_fields= "); + gp_message ("debugXL", $subr_name, "no_of_elements =3D $no_of_elemen= ts"); + gp_message ("debugXL", $subr_name, "input_fields[0] =3D $input_field= s[0]"); + + if ($no_of_elements =3D=3D 1) + { + $whatever =3D $input_fields[0]; + $value =3D ""; + } + elsif ($no_of_elements =3D=3D 2) + { +#-------------------------------------------------------------------------= ----- +# Note that value may consist of multiple fields (e.g. 1.651 ( 95.4%)). +#-------------------------------------------------------------------------= ----- + $whatever =3D $input_fields[0]; + $value =3D $input_fields[1]; + } + elsif ($no_of_elements =3D=3D 3) + { +#-------------------------------------------------------------------------= ----- +# Assumption: must be an address field. Restore the second colon. +#-------------------------------------------------------------------------= ----- + $whatever =3D $input_fields[0]; + $value =3D $input_fields[1] . ":" . $input_fields[2]; + } + else { - my $msg =3D "unexpected line format in summary file $FSUMMARY_FI= LE line =3D $line"; + my $msg =3D "unexpected: number of fields =3D " . $no_of_element= s;=20 gp_message ("assertion", $subr_name, $msg); } - $whatever =3D $2; - $value =3D $4; +#-------------------------------------------------------------------------= ----- +# Remove any leading whitespace characters. +#-------------------------------------------------------------------------= ----- + $value =3D~ s/$white_space_regex//; + + gp_message ("debugXL", $subr_name, "whatever =3D $whatever value =3D= $value"); + $function_info[$i]{$whatever} =3D $value; + +#-------------------------------------------------------------------------= ----- +# TBD: Seems to be not used anymore and can most likely be removed. Check = this. +#-------------------------------------------------------------------------= ----- if ($whatever =3D~ /Source File/) { if (!exists ($source_files{$value})) @@ -7742,9 +7786,13 @@ sub get_function_info $function_info[$i]{"addressobjtext"} =3D $full_address_field; $addressobjtextm{$full_address_field} =3D $i; # $RI } - if (not exists ($functions_address_and_index{$routine}{$value})) + if (not exists ($function_address_and_index{$routine}{$value})) { - $functions_address_and_index{$routine}{$value} =3D $i; + $function_address_and_index{$routine}{$value} =3D $i; + + my $msg =3D "function_address_and_index{$routine}{$value} = =3D " . + $function_address_and_index{$routine}{$value}; + gp_message ("debugXL", $subr_name, $msg); }=20 else=20 { @@ -7973,13 +8021,13 @@ sub get_function_info } } #-------------------------------------------------------------------------= ----- -# Print the data structure %functions_address_and_index. This is a nested = hash. +# Print the data structure %function_address_and_index. This is a nested h= ash. #-------------------------------------------------------------------------= ----- - for my $F (keys %functions_address_and_index) + for my $F (keys %function_address_and_index) { - for my $fields (sort keys %{ $functions_address_and_index{$F} }) + for my $fields (sort keys %{ $function_address_and_index{$F} }) { - gp_message ("debug", $subr_name, "on return: functions_address_= and_index{$F}{$fields} =3D $functions_address_and_index{$F}{$fields}"); + gp_message ("debug", $subr_name, "on return: function_address_a= nd_index{$F}{$fields} =3D $function_address_and_index{$F}{$fields}"); } } #-------------------------------------------------------------------------= ----- @@ -8050,10 +8098,10 @@ sub get_function_info $multi_occurrences;=20 gp_message ("debug", $subr_name, $msg); =20 - return (\@function_info, \%functions_address_and_index, \%addressobjtext= m, \%LINUX_vDSO, \%function_view_structure); + return (\@function_info, \%function_address_and_index, \%addressobjtextm= ,=20 + \%LINUX_vDSO, \%function_view_structure); =20 } #-- End of subroutine get_function_info - #-------------------------------------------------------------------------= ----- # TBD #-------------------------------------------------------------------------= ----- @@ -9881,12 +9929,12 @@ sub parse_dis_files my $subr_name =3D get_my_name (); =20 my ($number_of_metrics_ref, $function_info_ref,=20 - $functions_address_and_index_ref, $input_string_ref,=20 + $function_address_and_index_ref, $input_string_ref,=20 $addressobj_index_ref) =3D @_; =20 #-------------------------------------------------------------------------= ----- -# Note that $functions_address_and_index_ref are is not used, -# but we need to pass in the address into generate_dis_html. +# Note that $function_address_and_index_ref is not used, but we need to pa= ss=20 +# in the address into generate_dis_html. #-------------------------------------------------------------------------= ----- my $number_of_metrics =3D ${ $number_of_metrics_ref }; my @function_info =3D @{ $function_info_ref }; @@ -9950,7 +9998,7 @@ sub parse_dis_files \$target_function, \$number_of_metrics,=20 $function_info_ref,=20 - $functions_address_and_index_ref= ,=20 + $function_address_and_index_ref,= =20 \$outputdir,=20 \$filename,=20 \@source_line,=20 @@ -11039,6 +11087,15 @@ sub process_function_files { $PCA =3D $function_address_info{$metric}[$INDEX]{"PC Address= "}; =20 + if (not exists ($functions_per_metric_first_index{$metric}{$= routine}{$PCA})) + { + gp_message ("debugXL", $subr_name, "not exists: function= s_per_metric_first_index{$metric}{$routine}{$PCA}"); + } + if (not exists ($function_address_and_index{$routine}{$PCA})) + { + gp_message ("debugXL", $subr_name, "not exists: function= _address_and_index{$routine}{$PCA}"); + } + if (exists ($functions_per_metric_first_index{$metric}{$rout= ine}{$PCA}) and=20 exists ($function_address_and_index{$routine}{$PCA})) {