All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	acme@kernel.org, mpe@ellerman.id.au
Cc: ananth@in.ibm.com
Subject: [PATCHv2 5/8] perf probe powerpc: Allow matching against dot symbols
Date: Mon, 15 Dec 2014 20:20:35 +0530	[thread overview]
Message-ID: <062b1dbee6747d8013ea91d7020216969aefb128.1418654436.git.naveen.n.rao@linux.vnet.ibm.com> (raw)
In-Reply-To: <cover.1418654435.git.naveen.n.rao@linux.vnet.ibm.com>
In-Reply-To: <cover.1418654435.git.naveen.n.rao@linux.vnet.ibm.com>

Allow perf probe to work on powerpc ABIv1 without the need to specify
the leading dot '.' for functions. 'perf probe do_fork' works with this
patch.

Introduce HAVE_ARCH_SYMBOL_HANDLING to indicate need for special
handling of symbols. In this patch, we override probe_function_filter()
on powerpc to account for dot symbols.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
Changes from the previous patchset:
Introduced arch helper to override the way probe function filter works.

 tools/perf/arch/powerpc/Makefile            |  1 +
 tools/perf/arch/powerpc/util/sym-handling.c | 28 ++++++++++++++++++++++++++++
 tools/perf/config/Makefile                  |  1 +
 tools/perf/util/probe-event.c               | 10 +++++-----
 tools/perf/util/probe-event.h               |  5 +++++
 5 files changed, 40 insertions(+), 5 deletions(-)
 create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c

diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index 6f7782b..1c3d435 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -3,4 +3,5 @@ PERF_HAVE_DWARF_REGS := 1
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/skip-callchain-idx.o
 endif
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/sym-handling.o
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
new file mode 100644
index 0000000..0a77825
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -0,0 +1,28 @@
+/*
+ * Special symbol handling for PowerPC:
+ * - Handle dot symbols on ABIv1
+ *
+ * Copyright (C) 2014 Naveen N Rao, 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 "map.h"
+#include "symbol.h"
+#include "probe-event.h"
+
+int probe_function_filter(struct map *map __maybe_unused, struct symbol *sym)
+{
+	if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) {
+		if ((strcmp(looking_function_name, sym->name) == 0) ||
+		    (sym->name[0] == '.' && looking_function_name[0] != '.' &&
+		     strcmp(looking_function_name, sym->name+1) == 0)) {
+			num_matched_functions++;
+			return 0;
+		}
+	}
+	return 1;
+}
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5d4b039..35cf934 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -383,6 +383,7 @@ ifeq ($(ARCH),powerpc)
   ifndef NO_DWARF
     CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
   endif
+  CFLAGS += -DHAVE_ARCH_SYMBOL_HANDLING
 endif
 
 ifndef NO_LIBUNWIND
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 74b7fef..7eb9b27 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -50,6 +50,8 @@
 #define PERFPROBE_GROUP "probe"
 
 bool probe_event_dry_run;	/* Dry run flag */
+char *looking_function_name;
+int num_matched_functions;
 
 #define semantic_error(msg ...) pr_err("Semantic error :" msg)
 
@@ -2210,11 +2212,8 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
 	return ret;
 }
 
-static char *looking_function_name;
-static int num_matched_functions;
-
-static int probe_function_filter(struct map *map __maybe_unused,
-				      struct symbol *sym)
+#ifndef HAVE_ARCH_SYMBOL_HANDLING
+int probe_function_filter(struct map *map __maybe_unused, struct symbol *sym)
 {
 	if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) &&
 	    strcmp(looking_function_name, sym->name) == 0) {
@@ -2223,6 +2222,7 @@ static int probe_function_filter(struct map *map __maybe_unused,
 	}
 	return 1;
 }
+#endif /* HAVE_ARCH_SYMBOL_HANDLING */
 
 #define strdup_or_goto(str, label)	\
 	({ char *__p = strdup(str); if (!__p) goto label; __p; })
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index e01e994..8564451 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -7,6 +7,8 @@
 #include "strfilter.h"
 
 extern bool probe_event_dry_run;
+extern char *looking_function_name;
+extern int num_matched_functions;
 
 /* kprobe-tracer and uprobe-tracer tracing point */
 struct probe_trace_point {
@@ -136,6 +138,9 @@ extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
 extern int show_available_funcs(const char *module, struct strfilter *filter,
 				bool user);
 
+extern int probe_function_filter(struct map *map __maybe_unused,
+					struct symbol *sym);
+
 /* Maximum index number of event-name postfix */
 #define MAX_EVENT_INDEX	1024
 
-- 
2.1.3


WARNING: multiple messages have this Message-ID (diff)
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	acme@kernel.org, mpe@ellerman.id.au
Subject: [PATCHv2 5/8] perf probe powerpc: Allow matching against dot symbols
Date: Mon, 15 Dec 2014 20:20:35 +0530	[thread overview]
Message-ID: <062b1dbee6747d8013ea91d7020216969aefb128.1418654436.git.naveen.n.rao@linux.vnet.ibm.com> (raw)
In-Reply-To: <cover.1418654435.git.naveen.n.rao@linux.vnet.ibm.com>
In-Reply-To: <cover.1418654435.git.naveen.n.rao@linux.vnet.ibm.com>

Allow perf probe to work on powerpc ABIv1 without the need to specify
the leading dot '.' for functions. 'perf probe do_fork' works with this
patch.

Introduce HAVE_ARCH_SYMBOL_HANDLING to indicate need for special
handling of symbols. In this patch, we override probe_function_filter()
on powerpc to account for dot symbols.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
Changes from the previous patchset:
Introduced arch helper to override the way probe function filter works.

 tools/perf/arch/powerpc/Makefile            |  1 +
 tools/perf/arch/powerpc/util/sym-handling.c | 28 ++++++++++++++++++++++++++++
 tools/perf/config/Makefile                  |  1 +
 tools/perf/util/probe-event.c               | 10 +++++-----
 tools/perf/util/probe-event.h               |  5 +++++
 5 files changed, 40 insertions(+), 5 deletions(-)
 create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c

diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index 6f7782b..1c3d435 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -3,4 +3,5 @@ PERF_HAVE_DWARF_REGS := 1
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/skip-callchain-idx.o
 endif
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/sym-handling.o
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
new file mode 100644
index 0000000..0a77825
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -0,0 +1,28 @@
+/*
+ * Special symbol handling for PowerPC:
+ * - Handle dot symbols on ABIv1
+ *
+ * Copyright (C) 2014 Naveen N Rao, 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 "map.h"
+#include "symbol.h"
+#include "probe-event.h"
+
+int probe_function_filter(struct map *map __maybe_unused, struct symbol *sym)
+{
+	if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) {
+		if ((strcmp(looking_function_name, sym->name) == 0) ||
+		    (sym->name[0] == '.' && looking_function_name[0] != '.' &&
+		     strcmp(looking_function_name, sym->name+1) == 0)) {
+			num_matched_functions++;
+			return 0;
+		}
+	}
+	return 1;
+}
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5d4b039..35cf934 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -383,6 +383,7 @@ ifeq ($(ARCH),powerpc)
   ifndef NO_DWARF
     CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
   endif
+  CFLAGS += -DHAVE_ARCH_SYMBOL_HANDLING
 endif
 
 ifndef NO_LIBUNWIND
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 74b7fef..7eb9b27 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -50,6 +50,8 @@
 #define PERFPROBE_GROUP "probe"
 
 bool probe_event_dry_run;	/* Dry run flag */
+char *looking_function_name;
+int num_matched_functions;
 
 #define semantic_error(msg ...) pr_err("Semantic error :" msg)
 
@@ -2210,11 +2212,8 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
 	return ret;
 }
 
-static char *looking_function_name;
-static int num_matched_functions;
-
-static int probe_function_filter(struct map *map __maybe_unused,
-				      struct symbol *sym)
+#ifndef HAVE_ARCH_SYMBOL_HANDLING
+int probe_function_filter(struct map *map __maybe_unused, struct symbol *sym)
 {
 	if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) &&
 	    strcmp(looking_function_name, sym->name) == 0) {
@@ -2223,6 +2222,7 @@ static int probe_function_filter(struct map *map __maybe_unused,
 	}
 	return 1;
 }
+#endif /* HAVE_ARCH_SYMBOL_HANDLING */
 
 #define strdup_or_goto(str, label)	\
 	({ char *__p = strdup(str); if (!__p) goto label; __p; })
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index e01e994..8564451 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -7,6 +7,8 @@
 #include "strfilter.h"
 
 extern bool probe_event_dry_run;
+extern char *looking_function_name;
+extern int num_matched_functions;
 
 /* kprobe-tracer and uprobe-tracer tracing point */
 struct probe_trace_point {
@@ -136,6 +138,9 @@ extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
 extern int show_available_funcs(const char *module, struct strfilter *filter,
 				bool user);
 
+extern int probe_function_filter(struct map *map __maybe_unused,
+					struct symbol *sym);
+
 /* Maximum index number of event-name postfix */
 #define MAX_EVENT_INDEX	1024
 
-- 
2.1.3

  parent reply	other threads:[~2014-12-15 14:51 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 14:50 [PATCHv2 0/8] Fix perf probe issues on powerpc Naveen N. Rao
2014-12-15 14:50 ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 1/8] kprobes: Fix kallsyms lookup across powerpc ABIv1 and ABIv2 Naveen N. Rao
2014-12-15 14:50   ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 2/8] perf probe: Improve detection of file/function name in the probe pattern Naveen N. Rao
2014-12-15 14:50   ` Naveen N. Rao
2015-03-12 20:24   ` Arnaldo Carvalho de Melo
2015-03-12 20:24     ` Arnaldo Carvalho de Melo
2015-03-12 20:25     ` Arnaldo Carvalho de Melo
2015-03-12 20:25       ` Arnaldo Carvalho de Melo
2015-03-13  2:03     ` Ananth N Mavinakayanahalli
2015-03-13  2:03       ` Ananth N Mavinakayanahalli
2015-03-13 11:20     ` Masami Hiramatsu
2015-03-13 11:20       ` Masami Hiramatsu
2015-04-27  5:05       ` Naveen N. Rao
2015-04-27  5:05         ` Naveen N. Rao
2015-04-27  5:09       ` Naveen N. Rao
2015-04-27  5:09         ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 3/8] perf probe powerpc: Fix symbol fixup issues due to ELF type Naveen N. Rao
2014-12-15 14:50   ` Naveen N. Rao
2015-03-12 20:23   ` Arnaldo Carvalho de Melo
2015-03-12 20:23     ` Arnaldo Carvalho de Melo
2015-04-27  5:06     ` Naveen N. Rao
2015-04-27  5:06       ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 4/8] perf probe powerpc: Handle powerpc dot symbols Naveen N. Rao
2014-12-15 14:50   ` Naveen N. Rao
2015-03-12 20:26   ` Arnaldo Carvalho de Melo
2015-03-12 20:26     ` Arnaldo Carvalho de Melo
2014-12-15 14:50 ` Naveen N. Rao [this message]
2014-12-15 14:50   ` [PATCHv2 5/8] perf probe powerpc: Allow matching against " Naveen N. Rao
2015-03-12 20:30   ` Arnaldo Carvalho de Melo
2015-03-12 20:30     ` Arnaldo Carvalho de Melo
2015-04-27  5:08     ` Naveen N. Rao
2015-04-27  5:08       ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 6/8] perf tools powerpc: Fix PPC64 ELF ABIv2 symbol decoding Naveen N. Rao
2014-12-15 14:50   ` Naveen N. Rao
2015-03-12 20:35   ` Arnaldo Carvalho de Melo
2015-03-12 20:35     ` Arnaldo Carvalho de Melo
2014-12-15 14:50 ` [PATCHv2 7/8] perf probe powerpc: Use DWARF info only if necessary Naveen N. Rao
2014-12-15 14:50   ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 8/8] perf probe powerpc: Fixup function entry if using kallsyms lookup Naveen N. Rao
2014-12-15 14:50   ` Naveen N. Rao
2015-03-12 20:37   ` Arnaldo Carvalho de Melo
2015-03-12 20:37     ` Arnaldo Carvalho de Melo
2015-01-28  5:42 ` [PATCHv2 0/8] Fix perf probe issues on powerpc Naveen N. Rao
2015-01-28  5:42   ` Naveen N. Rao
2015-01-28  6:14   ` Michael Ellerman
2015-01-28  6:14     ` Michael Ellerman
2015-01-28  6:43     ` Naveen N. Rao
2015-01-28  6:43       ` Naveen N. Rao
2015-01-30  2:19       ` Michael Ellerman
2015-01-30  2:19         ` Michael Ellerman

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=062b1dbee6747d8013ea91d7020216969aefb128.1418654436.git.naveen.n.rao@linux.vnet.ibm.com \
    --to=naveen.n.rao@linux.vnet.ibm.com \
    --cc=acme@kernel.org \
    --cc=ananth@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.