From: Namhyung Kim <namhyung@kernel.org>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, acme@redhat.com,
peterz@infradead.org, mingo@elte.hu, ak@linux.intel.com,
jolsa@redhat.com, cel@us.ibm.com, sukadev@linux.vnet.ibm.com,
sonnyrao@chromium.org, johnmccutchan@google.com
Subject: Re: [PATCH 1/4] perf tools: add Java demangling support
Date: Thu, 12 Feb 2015 17:12:34 +0900 [thread overview]
Message-ID: <20150212081234.GE30788@sejong> (raw)
In-Reply-To: <1423611765-18200-2-git-send-email-eranian@google.com>
On Wed, Feb 11, 2015 at 12:42:42AM +0100, Stephane Eranian wrote:
> Add Java function descriptor demangling support.
> Something bfd cannot do.
>
> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---
[SNIP]
> +/*
> + * Demangle Java function signature (Hotspot, not GCJ)
> + * input:
> + * str: string to parse. String is not modified
> + * return:
> + * if can demangle then a a newly allocate string is returned.
> + * if cannot demangle, then NULL is returned
> + *
> + * Note that caller is responsible for freeing demangled string
> + */
> +char *
> +java_demangle_sym(const char *str)
> +{
> + char *buf, *ptr;
> + char *p;
> + size_t len, l1;
> +
> + if (!str)
> + return NULL;
> +
> + /* find start of retunr type */
> + p = strrchr(str, ')');
> + if (!p)
> + return NULL;
> +
> + /*
> + * expansion factor estimated to 3x
> + */
> + len = strlen(str) * 3 + 1;
> + buf = malloc(len);
> + if (!buf)
> + return NULL;
> +
> + buf[0] = '\0';
> + /*
> + * get return type first
> + */
> + ptr = __demangle_java_sym(p+1, NULL, buf, len, MODE_TYPE);
> + if (!ptr)
> + goto error;
> +
> + /* add space between return type and function prototype */
> + l1 = strlen(buf);
> + buf[l1++] = ' ';
> +
> + /* process function up to return type */
> + ptr = __demangle_java_sym(str, p + 1, buf + l1, len - l1, MODE_PREFIX);
> + if (!ptr)
> + goto error;
Do we really need to use return type for Java symbol name? Note that
for C++ demangling, we show function name only by default and
parameters will be shown when user gave -v option.
Thanks,
Namhyung
> +
> + return buf;
> +error:
> + free(buf);
> + return NULL;
> +}
> +
> +
next prev parent reply other threads:[~2015-02-12 8:14 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 23:42 [PATCH 0/4] perf: add support for profiling jitted code Stephane Eranian
2015-02-10 23:42 ` [PATCH 1/4] perf tools: add Java demangling support Stephane Eranian
2015-02-12 8:12 ` Namhyung Kim [this message]
2015-02-12 11:27 ` Jiri Olsa
2015-02-10 23:42 ` [PATCH 2/4] perf tools: pass timestamp to map_init Stephane Eranian
2015-02-16 6:55 ` Adrian Hunter
2015-02-10 23:42 ` [PATCH 3/4] perf inject: add jitdump mmap injection support Stephane Eranian
2015-02-11 11:59 ` Peter Zijlstra
2015-02-11 13:13 ` Stephane Eranian
2015-02-11 15:27 ` David Ahern
2015-02-12 8:19 ` Namhyung Kim
2015-02-10 23:42 ` [PATCH 4/4] perf tools: add JVMTI agent library Stephane Eranian
2015-02-12 8:21 ` Namhyung Kim
2015-02-12 13:25 ` Jiri Olsa
2015-02-12 16:09 ` Stephane Eranian
2015-02-12 16:58 ` Andi Kleen
2015-02-12 17:11 ` Stephane Eranian
2015-02-16 7:01 ` Adrian Hunter
2015-02-16 20:22 ` Stephane Eranian
2015-02-18 8:43 ` Adrian Hunter
2015-02-11 11:39 ` [PATCH 0/4] perf: add support for profiling jitted code Peter Zijlstra
2015-02-11 13:18 ` Stephane Eranian
2015-02-11 16:15 ` Peter Zijlstra
2015-02-11 16:25 ` David Ahern
2015-02-12 13:42 ` Jiri Olsa
2015-02-12 17:27 ` Stephane Eranian
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=20150212081234.GE30788@sejong \
--to=namhyung@kernel.org \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=cel@us.ibm.com \
--cc=eranian@google.com \
--cc=johnmccutchan@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=sonnyrao@chromium.org \
--cc=sukadev@linux.vnet.ibm.com \
/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