From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 7 20:48:05 2006 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6688616A400; Fri, 7 Apr 2006 20:48:05 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outbound7.internet-mail-service.net (outbound7.internet-mail-service.net [216.240.47.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9608943D48; Fri, 7 Apr 2006 20:48:04 +0000 (GMT) (envelope-from julian@elischer.org) Received: from idiom.com (idiom.com [216.240.32.1]) by outbound.internet-mail-service.net (Postfix) with ESMTP id 7459C24B204; Fri, 7 Apr 2006 13:48:04 -0700 (PDT) Received: from [10.251.19.131] (nat.ironport.com [63.251.108.100]) by idiom.com (8.12.11/8.12.11) with ESMTP id k37Km4Kq093403; Fri, 7 Apr 2006 13:48:04 -0700 (PDT) (envelope-from julian@elischer.org) Message-ID: <4436CFF5.60101@elischer.org> Date: Fri, 07 Apr 2006 13:47:49 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: en-us, en MIME-Version: 1.0 To: ports@freebsd.org, hackers@freebsd.org Content-Type: multipart/mixed; boundary="------------090103070602040700060400" Cc: Subject: patches for devel/mprof X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Apr 2006 20:48:05 -0000 This is a multi-part message in MIME format. --------------090103070602040700060400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I include patches to stop teh devel/mprof port from core-dumping when run. it seems to produce reasonable results on my limited testing. it really needs someone who knows about symbol table formats to check it over and see if I've screwed up in some way. It was coredumping whenever it couldn't assign a symbol (function) name to a memory address. for example if the address was in a shared library. Anyone in "ports" like to check this? I ran it on 4.x but I think it hasn't really changed.. (I wonder if there is a newer version somewhere) Julian --------------090103070602040700060400 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="mprof.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mprof.diff" Only in xwork: .PLIST.flattened Only in xwork: .PLIST.mktmp Only in xwork: .PLIST.objdump Only in xwork: .PLIST.setuid Only in xwork: .PLIST.writable Only in xwork: .install_done.mprof-3.0._usr_local Binary files work/libc_mp.a and xwork/libc_mp.a differ diff -u work/mpgraph.c xwork/mpgraph.c --- work/mpgraph.c Fri Apr 7 13:39:45 2006 +++ xwork/mpgraph.c Fri Apr 7 01:45:35 2006 @@ -836,7 +836,15 @@ while (!mp_null(chain)) { vertex v; s = (mpsym) mp_car(chain); - v = make_vertex(fn_name(s), count, fn_lcount(s), fn_parents(s)); + if ( s == NULL) { + chain = (mpcell) mp_cdr(chain); + continue; + } + if (fn_name(s)) + v = make_vertex(fn_name(s), count, fn_lcount(s), fn_parents(s)); + else + v = make_vertex("unknown", count, fn_lcount(s), fn_parents(s)); + vpush(v, vset); count += 1; chain = (mpcell) mp_cdr(chain); @@ -864,7 +872,11 @@ parent_name = fn_name((mpsym) mp_car(parent)); parent_data = (mpdata) mp_cdr(parent); - vfrom = hlookup(parent_name); + if (parent_name == NULL) { + vfrom = hlookup("unknown"); + } else { + vfrom = hlookup(parent_name); + } if (vfrom == vto) { vto->srefs += 1; Binary files work/mpgraph.o and xwork/mpgraph.o differ Binary files work/mprof and xwork/mprof differ diff -u work/mprof.c xwork/mprof.c --- work/mprof.c Fri Apr 7 13:39:45 2006 +++ xwork/mprof.c Fri Apr 7 01:28:45 2006 @@ -186,7 +186,7 @@ }; -#define STHASH_SIZE 2047 +#define STHASH_SIZE (2^20 -1) struct sthash *sthmem[STHASH_SIZE]; #define STNIL NULL @@ -491,7 +491,7 @@ #define stab_name(x) (stab[(x)].name) #define stab_addr(x) (stab[(x)].addr) -#define ST_SIZE 5000 +#define ST_SIZE 50000 #define ST_NOT_FOUND -1 typedef int stindex; @@ -899,7 +899,8 @@ if (*(colp+2) == '(') { char *commap; commap = index(symp, ','); - *commap = '0'; + if (commap) + *commap = '0'; tnum = atoi((char *) index(symp, '(')+1); } else { tnum = atoi((char *) (colp+2)); @@ -926,7 +927,8 @@ if (*(colp+2) == '(') { char *commap; commap = index(symp, ','); - *commap = '0'; + if (commap) + *commap = '0'; tnum = atoi((char *) index(symp, '(')+1); } else { tnum = atoi((char *) colp+2); @@ -1275,9 +1277,15 @@ if (d5 != 0) { fx = st_locate(d5); fsym = pc_lookup(stab_addr(fx)); - fn_name(fsym) = stab_name(fx); - lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].func = fn_name(fsym); - lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].offset = d5 - stab_addr(fx); + if (stab_name(fx) == NULL) { + fn_name(fsym) = ""; + lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].func = ""; + lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].offset = 0; + } else { + fn_name(fsym) = stab_name(fx); + lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].func = fn_name(fsym); + lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].offset = d5 - stab_addr(fx); + } } else { lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].func = ""; lte->path[SHORT_CALLSTACK_SIZE - (i + 1)].offset = 0; @@ -1403,6 +1411,8 @@ fprintf(outfile, "..."); } for (j = 0; j < SHORT_CALLSTACK_SIZE; j++) { + if (lte.path[j].func == NULL) + lte.path[j].func = ""; if (strcmp(lte.path[j].func, "") != 0) { if (leak_level == LEAK_SHOW) { fprintf(outfile, "> %s ", lte.path[j].func); Binary files work/mprof.o and xwork/mprof.o differ --------------090103070602040700060400--