From owner-svn-src-head@FreeBSD.ORG Thu Sep 6 03:19:49 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 B5C3E106564A; Thu, 6 Sep 2012 03:19:49 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 870908FC31; Thu, 6 Sep 2012 03:19:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q863Jnex050508; Thu, 6 Sep 2012 03:19:49 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q863JnDe050504; Thu, 6 Sep 2012 03:19:49 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <201209060319.q863JnDe050504@svn.freebsd.org> From: Rui Paulo Date: Thu, 6 Sep 2012 03:19:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: 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 03:19:49 -0000 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') + __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); memcpy(symcopy, &sym, sizeof(sym)); /* * DTrace expects the st_value to contain