All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Alexis Berlemont <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com,
	mhiramat@kernel.org, peterz@infradead.org,
	ravi.bangoria@linux.vnet.ibm.com, alexis.berlemont@gmail.com,
	hpa@zytor.com, mingo@kernel.org,
	alexander.shishkin@linux.intel.com, hemant@linux.vnet.ibm.com,
	tglx@linutronix.de
Subject: [tip:perf/core] perf sdt: Add scanning of sdt probes arguments
Date: Fri, 24 Mar 2017 11:44:19 -0700	[thread overview]
Message-ID: <tip-be88184b1c7054719296387c6063748fb48fa645@git.kernel.org> (raw)
In-Reply-To: <20161214000732.1710-2-alexis.berlemont@gmail.com>

Commit-ID:  be88184b1c7054719296387c6063748fb48fa645
Gitweb:     http://git.kernel.org/tip/be88184b1c7054719296387c6063748fb48fa645
Author:     Alexis Berlemont <alexis.berlemont@gmail.com>
AuthorDate: Wed, 14 Dec 2016 01:07:31 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 21 Mar 2017 10:56:28 -0300

perf sdt: Add scanning of sdt probes arguments

During a "perf buildid-cache --add" command, the section ".note.stapsdt"
of the "added" binary is scanned in order to list the available SDT
markers available in a binary. The parts containing the probes arguments
were left unscanned.

The whole section is now parsed; the probe arguments are extracted for
later use.

Signed-off-by: Alexis Berlemont <alexis.berlemont@gmail.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20161214000732.1710-2-alexis.berlemont@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/symbol-elf.c | 25 +++++++++++++++++++++++--
 tools/perf/util/symbol.h     |  1 +
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 4e59dde..0e660db 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1828,7 +1828,7 @@ void kcore_extract__delete(struct kcore_extract *kce)
 static int populate_sdt_note(Elf **elf, const char *data, size_t len,
 			     struct list_head *sdt_notes)
 {
-	const char *provider, *name;
+	const char *provider, *name, *args;
 	struct sdt_note *tmp = NULL;
 	GElf_Ehdr ehdr;
 	GElf_Addr base_off = 0;
@@ -1887,6 +1887,25 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len,
 		goto out_free_prov;
 	}
 
+	args = memchr(name, '\0', data + len - name);
+
+	/*
+	 * There is no argument if:
+	 * - We reached the end of the note;
+	 * - There is not enough room to hold a potential string;
+	 * - The argument string is empty or just contains ':'.
+	 */
+	if (args == NULL || data + len - args < 2 ||
+		args[1] == ':' || args[1] == '\0')
+		tmp->args = NULL;
+	else {
+		tmp->args = strdup(++args);
+		if (!tmp->args) {
+			ret = -ENOMEM;
+			goto out_free_name;
+		}
+	}
+
 	if (gelf_getclass(*elf) == ELFCLASS32) {
 		memcpy(&tmp->addr, &buf, 3 * sizeof(Elf32_Addr));
 		tmp->bit32 = true;
@@ -1898,7 +1917,7 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len,
 	if (!gelf_getehdr(*elf, &ehdr)) {
 		pr_debug("%s : cannot get elf header.\n", __func__);
 		ret = -EBADF;
-		goto out_free_name;
+		goto out_free_args;
 	}
 
 	/* Adjust the prelink effect :
@@ -1923,6 +1942,8 @@ static int populate_sdt_note(Elf **elf, const char *data, size_t len,
 	list_add_tail(&tmp->note_list, sdt_notes);
 	return 0;
 
+out_free_args:
+	free(tmp->args);
 out_free_name:
 	free(tmp->name);
 out_free_prov:
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 6c358b7..9222c7e 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -351,6 +351,7 @@ int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb);
 struct sdt_note {
 	char *name;			/* name of the note*/
 	char *provider;			/* provider name */
+	char *args;
 	bool bit32;			/* whether the location is 32 bits? */
 	union {				/* location, base and semaphore addrs */
 		Elf64_Addr a64[3];

  parent reply	other threads:[~2017-03-24 18:48 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 23:55 [PATCH 0/2] perf: add support of SDT probes arguments Alexis Berlemont
2016-11-16 23:56 ` [PATCH 1/2] perf sdt: add scanning of sdt probles arguments Alexis Berlemont
2016-11-16 23:56 ` [PATCH 2/2] perf probe: add sdt probes arguments into the uprobe cmd string Alexis Berlemont
2016-11-17  9:04   ` Hemant Kumar
2016-11-18 23:56     ` [PATCH v2 0/2] " Alexis Berlemont
2016-11-18 23:56     ` [PATCH v2 1/2] perf sdt: add scanning of sdt probles arguments Alexis Berlemont
2016-11-25 14:40       ` Arnaldo Carvalho de Melo
2016-11-26  0:58         ` [PATCH v4 0/2] perf probe: add sdt probes arguments into the uprobe cmd string Alexis Berlemont
2016-12-05 23:42           ` Alexis Berlemont
2016-12-06 14:45             ` Arnaldo Carvalho de Melo
2016-11-26  0:58         ` [PATCH v4 1/2] perf sdt: add scanning of sdt probles arguments Alexis Berlemont
2016-12-07  2:44           ` Masami Hiramatsu
2016-11-26  0:58         ` [PATCH v4 2/2] perf probe: add sdt probes arguments into the uprobe cmd string Alexis Berlemont
2016-12-07  3:26           ` Masami Hiramatsu
2016-12-09 15:14             ` Arnaldo Carvalho de Melo
2016-12-10 10:00               ` Masami Hiramatsu
2016-12-14  0:07             ` [PATCH v5 0/2] " Alexis Berlemont
2016-12-14  7:36               ` Ingo Molnar
2017-01-23 11:23                 ` Ravi Bangoria
2017-02-22 22:41                   ` Alexis Berlemont
2017-01-24  6:58                 ` Ravi Bangoria
2017-01-24  8:22                   ` Ingo Molnar
2017-01-24  8:36                     ` Ravi Bangoria
2017-02-02 11:11               ` [PATCH 0/5] perf/sdt: Argument support for x86 and powepc Ravi Bangoria
2017-02-02 11:11                 ` [PATCH 1/5] perf/sdt: Show proper hint Ravi Bangoria
2017-02-02 13:40                   ` Ingo Molnar
2017-02-02 16:20                     ` Arnaldo Carvalho de Melo
2017-02-03 10:26                       ` [PATCH v2] " Ravi Bangoria
2017-02-03 15:18                         ` Arnaldo Carvalho de Melo
2017-02-07  7:53                           ` Ingo Molnar
2017-02-07 15:50                             ` Arnaldo Carvalho de Melo
2017-02-07  8:00                           ` Ingo Molnar
2017-02-16 10:16                           ` [RFC] perf/sdt: Directly record SDT event with 'perf record' Ravi Bangoria
2017-02-20  7:08                             ` Ingo Molnar
2017-02-20  8:21                               ` Ravi Bangoria
2017-02-20  8:42                                 ` Ingo Molnar
2017-02-20 11:01                                   ` Ravi Bangoria
2017-02-20 14:11                                     ` Arnaldo Carvalho de Melo
2017-02-23  8:13                                       ` Ravi Bangoria
2017-02-23 12:48                                         ` Arnaldo Carvalho de Melo
2017-02-07  1:13                         ` [PATCH v2] perf/sdt: Show proper hint Masami Hiramatsu
2017-02-10  7:44                         ` [tip:perf/core] perf sdt: Show proper hint when event not yet in place via 'perf probe' tip-bot for Ravi Bangoria
2017-02-02 11:11                 ` [PATCH 2/5] perf/sdt/x86: Add renaming logic for rNN and other registers Ravi Bangoria
2017-02-07  3:11                   ` Masami Hiramatsu
2017-03-21 14:08                     ` Arnaldo Carvalho de Melo
2017-03-24 18:45                   ` [tip:perf/core] perf sdt x86: " tip-bot for Ravi Bangoria
2017-02-02 11:11                 ` [PATCH 3/5] perf/sdt/x86: Move OP parser to tools/perf/arch/x86/ Ravi Bangoria
2017-02-07  3:11                   ` Masami Hiramatsu
2017-02-07  5:22                     ` Ravi Bangoria
2017-03-21 14:10                       ` Arnaldo Carvalho de Melo
2017-03-21 23:00                         ` Masami Hiramatsu
2017-03-22 11:22                           ` Arnaldo Carvalho de Melo
2017-03-21 14:55                   ` Masami Hiramatsu
2017-02-02 11:11                 ` [PATCH 4/5] perf/sdt/powerpc: Add argument support Ravi Bangoria
2017-02-02 11:11                 ` [PATCH 5/5] perf/probe: Change MAX_CMDLEN Ravi Bangoria
2017-02-07  1:40                   ` Masami Hiramatsu
2017-02-07  5:45                     ` [PATCH v2] " Ravi Bangoria
2017-03-21  5:19                       ` Masami Hiramatsu
2017-03-21 13:37                         ` Arnaldo Carvalho de Melo
2017-03-24 18:43                       ` [tip:perf/core] perf probe: " tip-bot for Ravi Bangoria
2017-02-07  2:55                 ` [PATCH 0/5] perf/sdt: Argument support for x86 and powepc Masami Hiramatsu
2017-03-06  7:53                   ` Ravi Bangoria
2017-03-06 13:42                     ` Masami Hiramatsu
2017-03-21  5:08               ` [PATCH v5 0/2] perf probe: add sdt probes arguments into the uprobe cmd string Masami Hiramatsu
2016-12-14  0:07             ` [PATCH v5 1/2] perf sdt: add scanning of sdt probles arguments Alexis Berlemont
2017-03-06 13:39               ` Masami Hiramatsu
2017-03-21 13:52                 ` Arnaldo Carvalho de Melo
2017-03-24 18:44               ` tip-bot for Alexis Berlemont [this message]
2016-12-14  0:07             ` [PATCH v5 2/2] perf probe: add sdt probes arguments into the uprobe cmd string Alexis Berlemont
2017-01-24  8:50               ` Ravi Bangoria
2017-03-06 17:23               ` Masami Hiramatsu
2017-03-24 18:44               ` [tip:perf/core] perf probe: Add " tip-bot for Alexis Berlemont
2016-11-18 23:56     ` [PATCH v2 2/2] perf probe: add " Alexis Berlemont
2016-11-21 10:25       ` Hemant Kumar
2016-11-24 23:13         ` [PATCH v3 0/2] " Alexis Berlemont
2016-11-24 23:13         ` [PATCH v3 1/2] perf sdt: add scanning of sdt probles arguments Alexis Berlemont
2016-11-24 23:13         ` [PATCH v3 2/2] perf probe: add sdt probes arguments into the uprobe cmd string Alexis Berlemont

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-be88184b1c7054719296387c6063748fb48fa645@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexis.berlemont@gmail.com \
    --cc=hemant@linux.vnet.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@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 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.