From: Li Hong <lihong.hi@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 6/9] tracing: recordmcount.pl Exit early if no work to do
Date: Tue, 27 Oct 2009 15:02:12 +0800 [thread overview]
Message-ID: <20091027070212.GF22032@uhli> (raw)
In-Reply-To: <20091027065421.GA22032@uhli>
>From 1589563d8113db41fa77dd657459b563dcecd389 Mon Sep 17 00:00:00 2001
From: Li Hong <lihong.hi@gmail.com>
Date: Tue, 27 Oct 2009 13:13:37 +0800
Subject: [PATCH] tracing: recordmcount.pl Exit early if no work to do
Also keep the global symbols and use it to check if no work to do, exit
early.
Signed-off-by: Li Hong <lihong.hi@gmail.com>
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index a6585b6..d750da8 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -91,7 +91,7 @@
#
# Here are the steps we take:
#
-# 1) Record all the local symbols by using 'nm'
+# 1) Record all the global, local and weak symbols by using 'nm'
# 2) Use objdump to find all the call site offsets and sections for
# mcount.
# 3) Compile the list into its own object.
@@ -143,12 +143,15 @@ $mv = "mv" if ((length $mv) == 0);
#print STDERR "running: $P '$arch' '$objdump' '$objcopy' '$cc' '$ld' " .
# "'$nm' '$rm' '$mv' '$inputfile'\n";
+my %globals; # List of global functions
my %locals; # List of local (static) functions
my %weak; # List of weak functions
my %convert; # List of local functions used that needs conversion
my $type;
-my $nm_regex; # Find the local functions (return function)
+my $global_regex; # Match a global function (return function)
+my $local_regex; # Match a local function (return function)
+my $weak_regex; # Match a weak function (return function)
my $section_regex; # Find the start of a section
my $function_regex; # Find the name of a function
# (return offset and func name)
@@ -190,7 +193,9 @@ if ($arch eq "x86") {
# We base the defaults off of i386, the other archs may
# feel free to change them in the below if statements.
#
-$nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
+$global_regex = "^[0-9a-fA-F]+\\s+T\\s+(\\S+)";
+$local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
+$weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
$section_regex = "Disassembly of section\\s+(\\S+):";
$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
@@ -239,7 +244,8 @@ if ($arch eq "x86_64") {
$cc .= " -m32";
} elsif ($arch eq "powerpc") {
- $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
+ $global_regex = "^[0-9a-fA-F]+\\s+T\\s+(\\.?\\S+)";
+ $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
$function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
@@ -314,19 +320,24 @@ my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o";
check_objcopy();
#
-# Step 1: find all the local (static functions) and weak symbols.
-# 't' is local, 'w/W' is weak (we never use a weak function)
+# Step 1: find all the global and local (static functions) and weak symbols.
+# 'T' is global 't' is local, 'w/W' is weak
#
open (IN, "$nm $inputfile|") || die "error running $nm";
while (<IN>) {
- if (/$nm_regex/) {
+ if (/$global_regex/) {
+ $globals{$1} = 1;
+ } elsif (/$local_regex/) {
$locals{$1} = 1;
- } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) {
+ } elsif (/$weak_regex/) {
$weak{$2} = $1;
}
}
close(IN);
+# Exit early if no work to do
+exit(0) unless (%globals or (%locals and $can_use_local));
+
my @offsets; # Array of offsets of mcount callers
my $ref_func; # reference function to use for offsets
my $offset = 0; # offset of ref_func to section beginning
--
1.6.0.4
next prev parent reply other threads:[~2009-10-27 7:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-27 6:54 [PATCH 1/9] tracing: recordmcount.pl Amend the documentation according to the implementation Li Hong
2009-10-27 6:57 ` [PATCH 2/9] tracing: recordmcount.pl Correct the check on the number of parameters Li Hong
2009-10-30 16:19 ` [tip:tracing/core] tracing: Correct the check for number of arguments in recordmcount.pl tip-bot for Li Hong
2009-10-27 6:58 ` [PATCH 3/9] tracing: recordmcount.pl Support absolute path check on $inputfile Li Hong
2009-10-27 20:12 ` Steven Rostedt
2009-10-27 7:00 ` [PATCH 4/9] tracing: recordmcount.pl Objcopy check should disable local reference correctly Li Hong
2009-10-27 20:16 ` Steven Rostedt
2009-10-27 7:01 ` [PATCH 5/9] tracing: recordmcount.pl Clarify the logic on mcount section check Li Hong
2009-10-27 20:18 ` Steven Rostedt
2009-10-27 7:02 ` Li Hong [this message]
2009-10-27 20:20 ` [PATCH 6/9] tracing: recordmcount.pl Exit early if no work to do Steven Rostedt
2009-10-27 7:03 ` [PATCH 7/9] tracing: recordmcount.pl Combine the condition validation in update_funcs Li Hong
2009-10-27 20:22 ` Steven Rostedt
2009-10-27 7:04 ` [PATCH 8/9] tracing: recordmcount.pl We won't use weak function as reference, remove the check Li Hong
2009-10-27 20:25 ` Steven Rostedt
2009-10-27 7:05 ` [PATCH 9/9] tracing: recordmcount.pl Remove the redundant code Li Hong
2009-10-27 20:51 ` Steven Rostedt
2009-10-27 20:04 ` [PATCH 1/9] tracing: recordmcount.pl Amend the documentation according to the implementation Steven Rostedt
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=20091027070212.GF22032@uhli \
--to=lihong.hi@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.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