From: ruud.vanderpas@oracle.com
To: binutils@sourceware.org
Subject: [PATCH] gprofng: fix bug 29392 - Unexpected line format in summary file
Date: Fri, 22 Jul 2022 14:08:25 -0700 [thread overview]
Message-ID: <20220722210825.1989857-1-ruud.vanderpas@oracle.com> (raw)
From: Ruud van der Pas <ruud.vanderpas@oracle.com>
gprofng/Changelog:
2022-07-22 Ruud van der Pas <ruud.vanderpas@oracle.com>
* 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.
---
gprofng/gp-display-html/gp-display-html.in | 101 ++++++++++++++++-----
1 file changed, 79 insertions(+), 22 deletions(-)
diff --git a/gprofng/gp-display-html/gp-display-html.in b/gprofng/gp-display-html/gp-display-html.in
index 54a87d7a3c7..c7a013970e1 100644
--- a/gprofng/gp-display-html/gp-display-html.in
+++ b/gprofng/gp-display-html/gp-display-html.in
@@ -7469,11 +7469,16 @@ sub get_function_info
my ($FSUMMARY_FILE) = @_;
- my @function_info = ();
- my %functions_address_and_index = ();
- my %LINUX_vDSO = ();
- my %function_view_structure = ();
- my %addressobjtextm = ();
+#------------------------------------------------------------------------------
+# The regex section.
+#------------------------------------------------------------------------------
+ my $white_space_regex = '\s*';
+
+ my @function_info = ();
+ my %function_address_and_index = ();
+ my %LINUX_vDSO = ();
+ my %function_view_structure = ();
+ my %addressobjtextm = ();
#------------------------------------------------------------------------------
# TBD: This structure is no longer used and most likely can be removed.
#------------------------------------------------------------------------------
@@ -7672,14 +7677,53 @@ sub get_function_info
# or:
# Source File: <absolute_path>/name_of_source_file
#------------------------------------------------------------------------------
- if ( not ($line =~ /^(\s*)(.*):(\s+)([^\s]+|(.*))/))
+ $line =~ s/^\s+//;
+
+ my @input_fields = split (":", $line);
+ my $no_of_elements = scalar (@input_fields);
+
+ gp_message ("debugXL", $subr_name, "#input_fields = $#input_fields");
+ gp_message ("debugXL", $subr_name, "no_of_elements = $no_of_elements");
+ gp_message ("debugXL", $subr_name, "input_fields[0] = $input_fields[0]");
+
+ if ($no_of_elements == 1)
+ {
+ $whatever = $input_fields[0];
+ $value = "";
+ }
+ elsif ($no_of_elements == 2)
+ {
+#------------------------------------------------------------------------------
+# Note that value may consist of multiple fields (e.g. 1.651 ( 95.4%)).
+#------------------------------------------------------------------------------
+ $whatever = $input_fields[0];
+ $value = $input_fields[1];
+ }
+ elsif ($no_of_elements == 3)
{
- my $msg = "unexpected line format in summary file $FSUMMARY_FILE line = $line";
+#------------------------------------------------------------------------------
+# Assumption: must be an address field. Restore the second colon.
+#------------------------------------------------------------------------------
+ $whatever = $input_fields[0];
+ $value = $input_fields[1] . ":" . $input_fields[2];
+ }
+ else
+ {
+ my $msg = "unexpected: number of fields = " . $no_of_elements;
gp_message ("assertion", $subr_name, $msg);
}
- $whatever = $2;
- $value = $4;
+#------------------------------------------------------------------------------
+# Remove any leading whitespace characters.
+#------------------------------------------------------------------------------
+ $value =~ s/$white_space_regex//;
+
+ gp_message ("debugXL", $subr_name, "whatever = $whatever value = $value");
+
$function_info[$i]{$whatever} = $value;
+
+#------------------------------------------------------------------------------
+# TBD: Seems to be not used anymore and can most likely be removed. Check this.
+#------------------------------------------------------------------------------
if ($whatever =~ /Source File/)
{
if (!exists ($source_files{$value}))
@@ -7707,7 +7751,7 @@ sub get_function_info
#------------------------------------------------------------------------------
# Convert to a base 10 number
#------------------------------------------------------------------------------
- $address_decimal = hex ($offset); # decimal
+ $address_decimal = bigint::hex ($offset); # decimal
#------------------------------------------------------------------------------
# Construct the address field. Note that we use the hex address here.
#------------------------------------------------------------------------------
@@ -7717,9 +7761,13 @@ sub get_function_info
$function_info[$i]{"addressobjtext"} = $full_address_field;
$addressobjtextm{$full_address_field} = $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} = $i;
+ $function_address_and_index{$routine}{$value} = $i;
+
+ my $msg = "function_address_and_index{$routine}{$value} = " .
+ $function_address_and_index{$routine}{$value};
+ gp_message ("debugXL", $subr_name, $msg);
}
else
{
@@ -7948,13 +7996,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 hash.
#------------------------------------------------------------------------------
- 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} = $functions_address_and_index{$F}{$fields}");
+ gp_message ("debug", $subr_name, "on return: function_address_and_index{$F}{$fields} = $function_address_and_index{$F}{$fields}");
}
}
#------------------------------------------------------------------------------
@@ -8025,10 +8073,10 @@ sub get_function_info
$multi_occurrences;
gp_message ("debug", $subr_name, $msg);
- return (\@function_info, \%functions_address_and_index, \%addressobjtextm, \%LINUX_vDSO, \%function_view_structure);
+ return (\@function_info, \%function_address_and_index, \%addressobjtextm,
+ \%LINUX_vDSO, \%function_view_structure);
} #-- End of subroutine get_function_info
-
#------------------------------------------------------------------------------
# TBD
#------------------------------------------------------------------------------
@@ -9847,12 +9895,12 @@ sub parse_dis_files
my $subr_name = get_my_name ();
my ($number_of_metrics_ref, $function_info_ref,
- $functions_address_and_index_ref, $input_string_ref,
+ $function_address_and_index_ref, $input_string_ref,
$addressobj_index_ref) = @_;
#------------------------------------------------------------------------------
-# 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 pass
+# in the address into generate_dis_html.
#------------------------------------------------------------------------------
my $number_of_metrics = ${ $number_of_metrics_ref };
my @function_info = @{ $function_info_ref };
@@ -9916,7 +9964,7 @@ sub parse_dis_files
\$target_function,
\$number_of_metrics,
$function_info_ref,
- $functions_address_and_index_ref,
+ $function_address_and_index_ref,
\$outputdir,
\$filename,
\@source_line,
@@ -11005,6 +11053,15 @@ sub process_function_files
{
$PCA = $function_address_info{$metric}[$INDEX]{"PC Address"};
+ if (not exists ($functions_per_metric_first_index{$metric}{$routine}{$PCA}))
+ {
+ gp_message ("debugXL", $subr_name, "not exists: functions_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}{$routine}{$PCA}) and
exists ($function_address_and_index{$routine}{$PCA}))
{
--
2.27.0
reply other threads:[~2022-07-22 21:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220722210825.1989857-1-ruud.vanderpas@oracle.com \
--to=ruud.vanderpas@oracle.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).