mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ian Munsie" <imunsie@au1.ibm.com>
To: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>
Cc: tom.leiming@gmail.com, Ian Munsie <imunsie@au1.ibm.com>
Subject: [PATCH 3/3] perf, powerpc: Allow perf test to handle PowerPC symbol naming
Date: Thu, 25 Nov 2010 15:12:55 +1100	[thread overview]
Message-ID: <1290658375-10342-3-git-send-email-imunsie@au1.ibm.com> (raw)
In-Reply-To: <1290658375-10342-1-git-send-email-imunsie@au1.ibm.com>

From: Ian Munsie <imunsie@au1.ibm.com>

The PowerPC ABI prefixes symbol names with periods, which causes perf
test to fail when it compares the symbol from the vmlinux file with the
symbol names from kallsyms. This patch adds the infrastructure to allow
archs to override how symbol names are compared and implements the
PowerPC function to disregard any prefixed periods, allowing perf test
to pass.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 tools/perf/arch/powerpc/Makefile      |    5 +++++
 tools/perf/arch/powerpc/util/symbol.c |   22 ++++++++++++++++++++++
 tools/perf/builtin-test.c             |    2 +-
 tools/perf/util/symbol.c              |    5 +++++
 tools/perf/util/symbol.h              |    2 ++
 5 files changed, 35 insertions(+), 1 deletions(-)
 create mode 100644 tools/perf/arch/powerpc/util/symbol.c

diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index 15130b5..b3e211e 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -2,3 +2,8 @@ ifndef NO_DWARF
 PERF_HAVE_DWARF_REGS := 1
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
 endif
+
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/symbol.o
+
+$(OUTPUT)arch/powerpc/util/%.o : arch/powerpc/util/%.c $(OUTPUT)PERF-CFLAGS
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -I util/ $<
diff --git a/tools/perf/arch/powerpc/util/symbol.c b/tools/perf/arch/powerpc/util/symbol.c
new file mode 100644
index 0000000..db56913
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/symbol.c
@@ -0,0 +1,22 @@
+/*
+ * Functions to handle PowerPC symbol naming
+ *
+ * Copyright © 2010 Ian Munsie, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <string.h>
+#include <symbol.h>
+
+/* Overrides the definition in the generic code */
+int arch_sym_strcmp(const char *s1, const char *s2)
+{
+	const char *ts1, *ts2;
+	ts1 = (*s1 == '.' ? s1+1 : s1);
+	ts2 = (*s2 == '.' ? s2+1 : s2);
+	return strcmp(ts1, ts2);
+}
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 035b9fa..9c0301b 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -126,7 +126,7 @@ static int test__vmlinux_matches_kallsyms(void)
 
 		if (pair && pair->start == sym->start) {
 next_pair:
-			if (strcmp(sym->name, pair->name) == 0) {
+			if (arch_sym_strcmp(sym->name, pair->name) == 0) {
 				/*
 				 * kallsyms don't have the symbol end, so we
 				 * set that by using the next symbol start - 1,
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a348906..180683e 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -2473,3 +2473,8 @@ int machine__load_vmlinux_path(struct machine *self, enum map_type type,
 
 	return ret;
 }
+
+int __attribute__((weak)) arch_sym_strcmp(const char *s1, const char *s2)
+{
+	return strcmp(s1, s2);
+}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 038f220..6f4daae 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -229,4 +229,6 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);
 
 size_t machine__fprintf_vmlinux_path(struct machine *self, FILE *fp);
 
+int arch_sym_strcmp(const char *s1, const char *s2);
+
 #endif /* __PERF_SYMBOL */
-- 
1.7.2.3


  parent reply	other threads:[~2010-11-25  4:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-25  4:12 [PATCH 1/3] perf: Correct final kernel map guesses Ian Munsie
2010-11-25  4:12 ` [PATCH 2/3] perf: Allow strong and weak functions in LIB_OBJS Ian Munsie
2010-11-26 21:18   ` Arnaldo Carvalho de Melo
2010-11-29  0:53     ` Ian Munsie
2010-12-07  6:42       ` Ian Munsie
2010-12-07 14:55         ` Arnaldo Carvalho de Melo
2010-12-08  7:39       ` [tip:perf/core] perf makefile: " tip-bot for Ian Munsie
2010-11-25  4:12 ` Ian Munsie [this message]
2010-12-10  4:47   ` [PATCH 3/3] perf, powerpc: Allow perf test to handle PowerPC symbol naming Ian Munsie
2010-12-12 14:39   ` Arnaldo Carvalho de Melo
2010-12-13  0:30     ` Ian Munsie
2010-11-28  8:34 ` [tip:perf/core] perf symbols: Correct final kernel map guesses tip-bot for Ian Munsie

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=1290658375-10342-3-git-send-email-imunsie@au1.ibm.com \
    --to=imunsie@au1.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=tom.leiming@gmail.com \
    /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

all inboxes | Powered by JetHome®