Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932164AbbBLIOL (ORCPT ); Thu, 12 Feb 2015 03:14:11 -0500 Received: from LGEMRELSE7Q.lge.com ([156.147.1.151]:43801 "EHLO lgemrelse7q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752594AbbBLIOK (ORCPT ); Thu, 12 Feb 2015 03:14:10 -0500 X-Original-SENDERIP: 10.177.220.203 X-Original-MAILFROM: namhyung@kernel.org Date: Thu, 12 Feb 2015 17:12:34 +0900 From: Namhyung Kim To: Stephane Eranian 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 Message-ID: <20150212081234.GE30788@sejong> References: <1423611765-18200-1-git-send-email-eranian@google.com> <1423611765-18200-2-git-send-email-eranian@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1423611765-18200-2-git-send-email-eranian@google.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1889 Lines: 79 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 > --- [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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/