[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150212081234.GE30788@sejong>
Date: Thu, 12 Feb 2015 17:12:34 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Stephane Eranian <eranian@...gle.com>
Cc: linux-kernel@...r.kernel.org, acme@...hat.com,
peterz@...radead.org, mingo@...e.hu, ak@...ux.intel.com,
jolsa@...hat.com, cel@...ibm.com, sukadev@...ux.vnet.ibm.com,
sonnyrao@...omium.org, johnmccutchan@...gle.com
Subject: Re: [PATCH 1/4] perf tools: add Java demangling support
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@...gle.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;
> +}
> +
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists