From owner-svn-src-head@FreeBSD.ORG Thu Sep 6 11:12:05 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EACA91065672; Thu, 6 Sep 2012 11:12:04 +0000 (UTC) (envelope-from gprspb@mail.ru) Received: from fallback2.mail.ru (fallback2.mail.ru [94.100.176.87]) by mx1.freebsd.org (Postfix) with ESMTP id C64FA8FC0C; Thu, 6 Sep 2012 11:12:03 +0000 (UTC) Received: from smtp13.mail.ru (smtp13.mail.ru [94.100.176.90]) by fallback2.mail.ru (mPOP.Fallback_MX) with ESMTP id CA270B6078B5; Thu, 6 Sep 2012 13:43:43 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=kRswVH7JH7e89Vu1th9rhx4J0MT91xaVKIahiO74cPY=; b=q/UN/yh2rOvLmMgmDSLnUacxrmegpBsDZM9GU7J9Hvk1Wxf4vs05CY0n1JqXavo/pD6gxU4kXUk4u+86pW6bKs0wL6wx/UPedJxSAMEfVauqqyHr1XY+QtE+ZM1jSuZY; Received: from [93.185.182.46] (port=59629 helo=gpr.nnz-home.ru) by smtp13.mail.ru with esmtpa (envelope-from ) id 1T9YcY-0005QR-Gl; Thu, 06 Sep 2012 13:43:35 +0400 Received: from gpr by gpr.nnz-home.ru with local (Exim 4.80 (FreeBSD)) (envelope-from ) id 1T9Ybe-000Pd3-O8; Thu, 06 Sep 2012 13:42:38 +0400 Date: Thu, 6 Sep 2012 13:42:38 +0400 From: Gennady Proskurin To: Rui Paulo Message-ID: <20120906094238.GF85904@gpr.nnz-home.ru> References: <201209060319.q863JnDe050504@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201209060319.q863JnDe050504@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam: Not detected X-Mras: Ok Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r240156 - head/lib/libproc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2012 11:12:05 -0000 On Thu, Sep 06, 2012 at 03:19:49AM +0000, Rui Paulo wrote: > Author: rpaulo > Date: Thu Sep 6 03:19:48 2012 > New Revision: 240156 > URL: http://svn.freebsd.org/changeset/base/240156 > > Log: > Add support for demangling C++ symbols. This requires linking libproc with > libc++rt/libsupc++. > > Discussed with: theraven > > Modified: > head/lib/libproc/Makefile > head/lib/libproc/proc_sym.c > > Modified: head/lib/libproc/Makefile > ============================================================================== > --- head/lib/libproc/Makefile Thu Sep 6 02:07:58 2012 (r240155) > +++ head/lib/libproc/Makefile Thu Sep 6 03:19:48 2012 (r240156) > @@ -1,5 +1,7 @@ > # $FreeBSD$ > > +.include > + > LIB= proc > > SRCS= proc_bkpt.c \ > @@ -13,6 +15,14 @@ INCS= libproc.h > > CFLAGS+= -I${.CURDIR} > > +.if ${MK_LIBCPLUSPLUS} != "no" > +LDADD+= -lcxxrt > +DPADD+= ${LIBCXXRT} > +.else > +LDADD+= -lsupc++ > +DPADD+= ${LIBSTDCPLUSPLUS} > +.endif > + > SHLIB_MAJOR= 2 > > WITHOUT_MAN= > > Modified: head/lib/libproc/proc_sym.c > ============================================================================== > --- head/lib/libproc/proc_sym.c Thu Sep 6 02:07:58 2012 (r240155) > +++ head/lib/libproc/proc_sym.c Thu Sep 6 03:19:48 2012 (r240156) > @@ -46,6 +46,8 @@ > > #include "_libproc.h" > > +extern char *__cxa_demangle(const char *, char *, size_t *, int *); > + > static void proc_rdl2prmap(rd_loadobj_t *, prmap_t *); > > static void > @@ -266,7 +268,11 @@ proc_addr2sym(struct proc_handle *p, uin > if (addr >= rsym && addr <= (rsym + sym.st_size)) { > s = elf_strptr(e, dynsymstridx, sym.st_name); > if (s) { > - strlcpy(name, s, namesz); > + if (strlen(s) > 2 && > + s[0] == '_' && s[1] == 'Z') checking "strlen(s) > 2" is useless and not optimal here, you can omit it completely checking s[0] and s[1] is enough, it implies that length is >=2 you may add something like "s[2] != 0" if length should be strictly >2 > + __cxa_demangle(s, name, &namesz, NULL); > + else > + strlcpy(name, s, namesz); > memcpy(symcopy, &sym, sizeof(sym)); > /* > * DTrace expects the st_value to contain > @@ -302,7 +308,11 @@ symtab: > if (addr >= rsym && addr <= (rsym + sym.st_size)) { > s = elf_strptr(e, symtabstridx, sym.st_name); > if (s) { > - strlcpy(name, s, namesz); > + if (strlen(s) > 2 && > + s[0] == '_' && s[1] == 'Z') > + __cxa_demangle(s, name, &namesz, NULL); > + else > + strlcpy(name, s, namesz); the same here > memcpy(symcopy, &sym, sizeof(sym)); > /* > * DTrace expects the st_value to contain > _______________________________________________ > svn-src-head@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >