mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot for Naveen N. Rao" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com,
	naveen.n.rao@linux.vnet.ibm.com, masami.hiramatsu.pt@hitachi.com,
	srikar@linux.vnet.ibm.com, ananth@in.ibm.com, tglx@linutronix.de,
	mingo@kernel.org, acme@redhat.com, sukadev@linux.vnet.ibm.com,
	mpe@ellerman.id.au
Subject: [tip:perf/core] perf probe: Improve detection of file/ function name in the probe pattern
Date: Tue, 5 May 2015 20:13:12 -0700	[thread overview]
Message-ID: <tip-3099c026002e97b8c173d9d0bbdfc39257d14402@git.kernel.org> (raw)
In-Reply-To: <db680f7cb11c4452b632f908e67151f3aa0f4602.1430217967.git.naveen.n.rao@linux.vnet.ibm.com>

Commit-ID:  3099c026002e97b8c173d9d0bbdfc39257d14402
Gitweb:     http://git.kernel.org/tip/3099c026002e97b8c173d9d0bbdfc39257d14402
Author:     Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Tue, 28 Apr 2015 17:35:34 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 4 May 2015 12:43:53 -0300

perf probe: Improve detection of file/function name in the probe pattern

Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':

  $ perf probe -F | grep schedule_timeout_interruptible
  .schedule_timeout_interruptible
  $ perf probe .schedule_timeout_interruptible
  Semantic error :File always requires line number or lazy pattern.
    Error: Command Parse Error.

Fix this:
- by checking the probe pattern in more detail, and
- skipping leading dot if one exists when creating/deleting events.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/db680f7cb11c4452b632f908e67151f3aa0f4602.1430217967.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index eb75a5e..416c10f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1077,6 +1077,7 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
 	struct perf_probe_point *pp = &pev->point;
 	char *ptr, *tmp;
 	char c, nc = 0;
+	bool file_spec = false;
 	/*
 	 * <Syntax>
 	 * perf probe [EVENT=]SRC[:LN|;PTN]
@@ -1105,6 +1106,23 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
 		arg = tmp;
 	}
 
+	/*
+	 * Check arg is function or file name and copy it.
+	 *
+	 * We consider arg to be a file spec if and only if it satisfies
+	 * all of the below criteria::
+	 * - it does not include any of "+@%",
+	 * - it includes one of ":;", and
+	 * - it has a period '.' in the name.
+	 *
+	 * Otherwise, we consider arg to be a function specification.
+	 */
+	if (!strpbrk(arg, "+@%") && (ptr = strpbrk(arg, ";:")) != NULL) {
+		/* This is a file spec if it includes a '.' before ; or : */
+		if (memchr(arg, '.', ptr - arg))
+			file_spec = true;
+	}
+
 	ptr = strpbrk(arg, ";:+@%");
 	if (ptr) {
 		nc = *ptr;
@@ -1115,10 +1133,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
 	if (tmp == NULL)
 		return -ENOMEM;
 
-	/* Check arg is function or file and copy it */
-	if (strchr(tmp, '.'))	/* File */
+	if (file_spec)
 		pp->file = tmp;
-	else			/* Function */
+	else
 		pp->function = tmp;
 
 	/* Parse other options */
@@ -2265,6 +2282,9 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
 {
 	int i, ret;
 
+	if (*base == '.')
+		base++;
+
 	/* Try no suffix */
 	ret = e_snprintf(buf, len, "%s", base);
 	if (ret < 0) {
@@ -2766,6 +2786,9 @@ int del_perf_probe_events(struct strlist *dellist)
 			event = str;
 		}
 
+		if (event && *event == '.')
+			event++;
+
 		ret = e_snprintf(buf, 128, "%s:%s", group, event);
 		if (ret < 0) {
 			pr_err("Failed to copy event.");

  parent reply	other threads:[~2015-05-06  3:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 12:05 [PATCH v3 0/7] Fixes for perf probe issues on ppc Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 1/7] perf probe: Improve detection of file/function name in the probe pattern Naveen N. Rao
2015-04-28 13:46   ` Arnaldo Carvalho de Melo
2015-05-06  3:13   ` tip-bot for Naveen N. Rao [this message]
2015-04-28 12:05 ` [PATCH v3 2/7] perf probe/ppc: Fix symbol fixup issues due to ELF type Naveen N. Rao
2015-04-28 13:48   ` Arnaldo Carvalho de Melo
2015-05-06  3:10   ` [tip:perf/core] perf probe ppc: " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 3/7] perf probe/ppc: Use the right prefix when ignoring SyS symbols on ppc Naveen N. Rao
2015-05-06  3:10   ` [tip:perf/core] perf probe ppc: " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 4/7] perf probe/ppc: Enable matching against dot symbols automatically Naveen N. Rao
2015-05-06  3:10   ` [tip:perf/core] perf probe ppc: " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 5/7] perf probe/ppc64le: Fix ppc64 ABIv2 symbol decoding Naveen N. Rao
2015-05-06  3:11   ` [tip:perf/core] perf probe ppc64le: " tip-bot for Ananth N Mavinakayanahalli
2015-04-28 12:05 ` [PATCH v3 6/7] perf probe/ppc64le: Prefer symbol table lookup over DWARF Naveen N. Rao
2015-05-06  3:11   ` [tip:perf/core] perf probe ppc64le: " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 7/7] perf probe/ppc64le: Fixup function entry if using kallsyms lookup Naveen N. Rao
2015-05-06  3:11   ` [tip:perf/core] perf probe ppc64le: " tip-bot for Naveen N. Rao
2015-04-28 13:54 ` [PATCH v3 0/7] Fixes for perf probe issues on ppc Arnaldo Carvalho de Melo
2015-04-28 16:12   ` Naveen N. Rao
2015-04-28 16:40     ` Arnaldo Carvalho de Melo
2015-04-28 22:17   ` Masami Hiramatsu
2015-04-29  5:18     ` Naveen N. Rao
2015-04-29  5:37   ` Srikar Dronamraju
2015-04-29 22:09     ` Arnaldo Carvalho de Melo

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=tip-3099c026002e97b8c173d9d0bbdfc39257d14402@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=ananth@in.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome