From: Hemant Kumar <hemant@linux.vnet.ibm.com>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: linux-kernel@vger.kernel.org, srikar@linux.vnet.ibm.com,
peterz@infradead.org, oleg@redhat.com,
hegdevasant@linux.vnet.ibm.com, mingo@redhat.com,
anton@redhat.com, systemtap@sourceware.org, namhyung@kernel.org,
aravinda@linux.vnet.ibm.com, penberg@iki.fi
Subject: Re: [PATCH v2 1/5] perf/sdt: ELF support for SDT
Date: Sun, 05 Oct 2014 13:47:45 +0530 [thread overview]
Message-ID: <5430FEA9.3090405@linux.vnet.ibm.com> (raw)
In-Reply-To: <542E8AF3.2030206@hitachi.com>
On 10/03/2014 05:09 PM, Masami Hiramatsu wrote:
> (2014/10/01 11:47), Hemant Kumar wrote:
>> This patch serves as the basic support to identify and list SDT events in binaries.
>> When programs containing SDT markers are compiled, gcc with the help of assembler
>> directives identifies them and places them in the section ".note.stapsdt". To find
>> these markers from the binaries, one needs to traverse through this section and
>> parse the relevant details like the name, type and location of the marker. Also,
>> the original location could be skewed due to the effect of prelinking. If that is
>> the case, the locations need to be adjusted.
>>
>> The functions in this patch open a given ELF, find out the SDT section, parse the
>> relevant details, adjust the location (if necessary) and populate them in a list.
>>
>> Made the necessary changes as suggested by Namhyung Kim.
> Looks almost good!
> I have some comments, please see below.
Ok.
>> Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
>> ---
>> tools/perf/util/symbol-elf.c | 207 ++++++++++++++++++++++++++++++++++++++++++
>> tools/perf/util/symbol.h | 19 ++++
>> 2 files changed, 226 insertions(+)
>>
>> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
>> index 2a92e10..9702167 100644
>> --- a/tools/perf/util/symbol-elf.c
>> +++ b/tools/perf/util/symbol-elf.c
>> @@ -1672,6 +1672,213 @@ void kcore_extract__delete(struct kcore_extract *kce)
>> unlink(kce->extract_filename);
>> }
>>
>> +/*
>> + * populate_sdt_note() : Responsible for parsing the section .note.stapsdt and
>> + * after adjusting the note's location, returns that to the calling functions.
>> + */
>> +static int populate_sdt_note(Elf **elf, const char *data, size_t len, int type,
>> + struct sdt_note **note)
>> +{
>> + const char *provider, *name;
>> + struct sdt_note *tmp = NULL;
>> + GElf_Ehdr ehdr;
>> + GElf_Addr base_off = 0;
>> + GElf_Shdr shdr;
>> + int ret = -1;
> -1 is not an error code. maybe, -EINVAL is better.
Sure, will change this to EINVAL.
>> + int i;
>> +
>> + union {
>> + Elf64_Addr a64[3];
>> + Elf32_Addr a32[3];
>> + } buf;
>> +
>> + Elf_Data dst = {
>> + .d_buf = &buf, .d_type = ELF_T_ADDR, .d_version = EV_CURRENT,
>> + .d_size = gelf_fsize((*elf), ELF_T_ADDR, 3, EV_CURRENT),
>> + .d_off = 0, .d_align = 0
>> + };
>> + Elf_Data src = {
>> + .d_buf = (void *) data, .d_type = ELF_T_ADDR,
>> + .d_version = EV_CURRENT, .d_size = dst.d_size, .d_off = 0,
>> + .d_align = 0
>> + };
>> +
>> + /* Check the type of each of the notes */
>> + if (type != SDT_NOTE_TYPE)
>> + goto out_err;
>> +
>> + tmp = (struct sdt_note *)calloc(1, sizeof(struct sdt_note));
>> + if (!tmp) {
>> + ret = -ENOMEM;
>> + goto out_err;
>> + }
>> +
>> + INIT_LIST_HEAD(&tmp->note_list);
>> +
>> + if (len < dst.d_size + 3)
>> + goto out_free_note;
>> +
>> + /* Translation from file representation to memory representation */
>> + if (gelf_xlatetom(*elf, &dst, &src,
>> + elf_getident(*elf, NULL)[EI_DATA]) == NULL)
>> + printf("gelf_xlatetom : %s\n", elf_errmsg(-1));
> pr_err? and shouldn't it goes to out_free_note?
Yes it should go to out_free_note. Will make the change.
>> [...]
>>
>>
Thank You for reviewing this patch.
--
Thanks,
Hemant Kumar
next prev parent reply other threads:[~2014-10-05 8:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 2:44 [PATCH v2 0/5] perf/sdt: SDT events listing/probing Hemant Kumar
2014-10-01 2:47 ` [PATCH v2 1/5] perf/sdt: ELF support for SDT Hemant Kumar
2014-10-03 11:39 ` Masami Hiramatsu
2014-10-05 8:17 ` Hemant Kumar [this message]
2014-10-07 2:20 ` Namhyung Kim
2014-10-07 6:09 ` Hemant Kumar
2014-10-01 2:47 ` [PATCH v2 2/5] perf/sdt: Add SDT events into a cache Hemant Kumar
2014-10-07 2:59 ` Namhyung Kim
2014-10-07 6:23 ` Hemant Kumar
2014-10-01 2:48 ` [PATCH v2 3/5] perf/sdt: Show SDT cache contents Hemant Kumar
2014-10-03 12:52 ` Masami Hiramatsu
2014-10-03 12:55 ` Masami Hiramatsu
2014-10-05 8:18 ` Hemant Kumar
2014-10-01 2:48 ` [PATCH v2 4/5] perf/sdt: Delete SDT events from cache Hemant Kumar
2014-10-07 3:17 ` Namhyung Kim
2014-10-07 6:24 ` Hemant Kumar
2014-10-01 2:48 ` [PATCH v2 5/5] perf/sdt: Add support to perf record to trace SDT events Hemant Kumar
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=5430FEA9.3090405@linux.vnet.ibm.com \
--to=hemant@linux.vnet.ibm.com \
--cc=anton@redhat.com \
--cc=aravinda@linux.vnet.ibm.com \
--cc=hegdevasant@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=penberg@iki.fi \
--cc=peterz@infradead.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=systemtap@sourceware.org \
/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