From: Pekka Enberg <penberg@kernel.org>
To: Stephane Eranian <eranian@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, Andi Kleen <ak@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
cel@us.ibm.com, sukadev@linux.vnet.ibm.com,
sonnyrao@chromium.org, johnmccutchan@google.com,
David Ahern <dsahern@gmail.com>,
adrian.hunter@intel.com, Pawel Moll <pawel.moll@arm.com>
Subject: Re: [PATCH v6 2/4] perf tools: add Java demangling support
Date: Tue, 31 Mar 2015 10:00:15 +0300 [thread overview]
Message-ID: <CAOJsxLGctG0ysbN+-F1Ce=LCtUT4eTs4eebX1kycq6A2zTnqYw@mail.gmail.com> (raw)
In-Reply-To: <1427753974-13380-3-git-send-email-eranian@google.com>
Hi Stephane,
On Tue, Mar 31, 2015 at 1:19 AM, Stephane Eranian <eranian@google.com> wrote:
> +#define BASE_ENT(c, n) [c-'A']=n
> +static const char *base_types['Z'-'A' + 1]={
> + BASE_ENT('B', "byte" ),
> + BASE_ENT('C', "char" ),
> + BASE_ENT('D', "double" ),
> + BASE_ENT('F', "float" ),
> + BASE_ENT('I', "int" ),
> + BASE_ENT('J', "long" ),
> + BASE_ENT('S', "short" ),
> + BASE_ENT('Z', "bool" ),
It's "boolean", not "bool" in JVM speak.
> +static char *
> +__demangle_java_sym(const char *str, const char *end, char *buf, int maxlen, int mode)
> +{
> + int rlen = 0;
> + int array = 0;
> + int narg = 0;
> + const char *q;
> +
> + if (!end)
> + end = str + strlen(str);
> +
> + for (q = str; q != end; q++) {
> +
> + if (rlen == (maxlen - 1))
> + break;
> +
> + switch (*q) {
> + case 'L':
> + if (mode == MODE_PREFIX || mode == MODE_CTYPE) {
> + if (mode == MODE_CTYPE) {
> + if (narg)
> + rlen += scnprintf(buf + rlen, maxlen - rlen, ", ");
> + narg++;
> + }
> + rlen += scnprintf(buf + rlen, maxlen - rlen, "class ");
> + if (mode == MODE_PREFIX)
> + mode = MODE_CLASS;
> + } else
> + buf[rlen++] = *q;
> + break;
This looks odd to me. "L" marks the beginning of an class name and
it's terminated by ";". You could just strhchr() the terminator and
simply copy the name to "buf" and drop cases ';', '/', and the default
label fro the switch statement.
> +char *
> +java_demangle_sym(const char *str, int flags)
> +{
[snip]
> + /*
> + * expansion factor estimated to 3x
> + */
> + len = strlen(str) * 3 + 1;
> + buf = malloc(len);
> + if (!buf)
> + return NULL;
Truncated symbols are lame. Can't you use realloc() to ensure that
never happens?
- Pekka
next prev parent reply other threads:[~2015-03-31 7:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 22:19 [PATCH v6 0/4] perf: add support for profiling jitted code Stephane Eranian
2015-03-30 22:19 ` [PATCH v6 1/4] perf,record: Add clockid parameter Stephane Eranian
2015-03-30 22:24 ` David Ahern
2015-03-30 22:27 ` Stephane Eranian
2015-03-31 7:16 ` Peter Zijlstra
2015-03-31 7:28 ` Peter Zijlstra
2015-03-30 22:19 ` [PATCH v6 2/4] perf tools: add Java demangling support Stephane Eranian
2015-03-31 7:00 ` Pekka Enberg [this message]
2015-03-30 22:19 ` [PATCH v6 3/4] perf inject: add jitdump mmap injection support Stephane Eranian
2015-04-01 6:58 ` Adrian Hunter
[not found] ` <CABPqkBRd9+Ystsb-6gOn0Pni37BOc4uTGkj7DHfKbBvBCU9E7A@mail.gmail.com>
2015-04-08 12:15 ` Adrian Hunter
2015-04-08 14:12 ` Stephane Eranian
2015-04-10 12:51 ` Adrian Hunter
2015-04-13 0:37 ` Stephane Eranian
2015-04-13 7:03 ` Adrian Hunter
2015-03-30 22:19 ` [PATCH v6 4/4] perf tools: add JVMTI agent library Stephane Eranian
2015-03-31 7:33 ` [PATCH v6 0/4] perf: add support for profiling jitted code Brendan Gregg
2015-03-31 21:31 ` Brendan Gregg
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='CAOJsxLGctG0ysbN+-F1Ce=LCtUT4eTs4eebX1kycq6A2zTnqYw@mail.gmail.com' \
--to=penberg@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=cel@us.ibm.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=johnmccutchan@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung@kernel.org \
--cc=pawel.moll@arm.com \
--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;
as well as URLs for NNTP newsgroup(s).