From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757719AbdCUOB2 (ORCPT ); Tue, 21 Mar 2017 10:01:28 -0400 Received: from mail.kernel.org ([198.145.29.136]:59846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751477AbdCUOB1 (ORCPT ); Tue, 21 Mar 2017 10:01:27 -0400 Date: Tue, 21 Mar 2017 10:52:57 -0300 From: Arnaldo Carvalho de Melo To: Masami Hiramatsu Cc: Alexis Berlemont , linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Subject: Re: [PATCH v5 1/2] perf sdt: add scanning of sdt probles arguments Message-ID: <20170321135257.GB30938@kernel.org> References: <20161214000732.1710-1-alexis.berlemont@gmail.com> <20161214000732.1710-2-alexis.berlemont@gmail.com> <20170306143915.f7778227b43e90ba7a799a55@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170306143915.f7778227b43e90ba7a799a55@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Mar 06, 2017 at 02:39:15PM +0100, Masami Hiramatsu escreveu: > On Wed, 14 Dec 2016 01:07:31 +0100 > Alexis Berlemont wrote: > > > 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. > > > > Looks good to me. > > Acked-by: Masami Hiramatsu Thanks, applied. > Thanks! > > > Signed-off-by: Alexis Berlemont > > --- > > 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 99400b0..7725c3f 100644 > > --- a/tools/perf/util/symbol-elf.c > > +++ b/tools/perf/util/symbol-elf.c > > @@ -1822,7 +1822,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; > > @@ -1881,6 +1881,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; > > @@ -1892,7 +1911,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 : > > @@ -1917,6 +1936,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]; > > -- > > 2.10.2 > > > > > -- > Masami Hiramatsu