tracing: optimize recordmcount.pl for offsets-handling

- move check for open file in front of the writing loop
- use perl-constructs to access the array

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
LKML-Reference: <1262716072-14414-2-git-send-email-w.sang@pengutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Wolfram Sang 2010-01-05 19:27:51 +01:00 committed by Steven Rostedt
parent 7e53bd42d1
commit dc4f8845ee
1 changed files with 9 additions and 9 deletions

View File

@ -432,14 +432,14 @@ sub update_funcs
# Loop through all the mcount caller offsets and print a reference # Loop through all the mcount caller offsets and print a reference
# to the caller based from the ref_func. # to the caller based from the ref_func.
for (my $i=0; $i <= $#offsets; $i++) { if (!$opened) {
if (!$opened) { open(FILE, ">$mcount_s") || die "can't create $mcount_s\n";
open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; $opened = 1;
$opened = 1; print FILE "\t.section $mcount_section,\"a\",$section_type\n";
print FILE "\t.section $mcount_section,\"a\",$section_type\n"; print FILE "\t.align $alignment\n" if (defined($alignment));
print FILE "\t.align $alignment\n" if (defined($alignment)); }
} foreach my $cur_offset (@offsets) {
printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; printf FILE "\t%s %s + %d\n", $type, $ref_func, $cur_offset - $offset;
} }
} }
@ -514,7 +514,7 @@ while (<IN>) {
} }
# is this a call site to mcount? If so, record it to print later # is this a call site to mcount? If so, record it to print later
if ($text_found && /$mcount_regex/) { if ($text_found && /$mcount_regex/) {
$offsets[$#offsets + 1] = hex $1; push(@offsets, hex $1);
} }
} }