From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Dec 8 19:00:22 2006 Return-Path: X-Original-To: freebsd-ports-bugs@hub.freebsd.org Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4263416A412 for ; Fri, 8 Dec 2006 19:00:22 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6E9E243CA3 for ; Fri, 8 Dec 2006 18:59:22 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kB8J0LZ3013881 for ; Fri, 8 Dec 2006 19:00:21 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kB8J0LGS013880; Fri, 8 Dec 2006 19:00:21 GMT (envelope-from gnats) Resent-Date: Fri, 8 Dec 2006 19:00:21 GMT Resent-Message-Id: <200612081900.kB8J0LGS013880@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Julian Elischer Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3582516A416 for ; Fri, 8 Dec 2006 18:55:58 +0000 (UTC) (envelope-from julian@pan.ironport.com) Received: from pan.ironport.com (pan.ironport.com [63.251.108.103]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C69A43CA5 for ; Fri, 8 Dec 2006 18:54:58 +0000 (GMT) (envelope-from julian@pan.ironport.com) Received: from pan.ironport.com (localhost [127.0.0.1]) by pan.ironport.com (8.13.1/8.13.1) with ESMTP id kB8ItuH5052920 for ; Fri, 8 Dec 2006 10:55:56 -0800 (PST) (envelope-from julian@pan.ironport.com) Received: (from julian@localhost) by pan.ironport.com (8.13.1/8.13.1/Submit) id kB8Itphx052919; Fri, 8 Dec 2006 10:55:51 -0800 (PST) (envelope-from julian) Message-Id: <200612081855.kB8Itphx052919@pan.ironport.com> Date: Fri, 8 Dec 2006 10:55:51 -0800 (PST) From: Julian Elischer To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: ports/106491: mprof needs help to read modern binaries and symbol tables. X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Julian Elischer List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Dec 2006 19:00:22 -0000 >Number: 106491 >Category: ports >Synopsis: mprof needs help to read modern binaries and symbol tables. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Dec 08 19:00:20 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Julian Elischer >Release: FreeBSD 6.1-RELEASE i386 >Organization: Ironport Inc. >Environment: System: FreeBSD pan.ironport.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Fri Nov 28 18:05:03 PST 2006 root@new-pan.ironport.com:/usr/obj/usr/src/sys/SMPno386 i386 i386, all versions to current >Description: Over time the object formats have changed and programs have gotten bigger and ,more complicated.. Add C++ to the mox and lib mprof doesn't work any more, crashing here and there. These patched try to address the problems I encountered. They may be less than perfect but the resulting data is useful and it no linger crashes. >How-To-Repeat: try use mprof on modern binaries. (include C++ for added fun) >Fix: Apply the following patches. 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; 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 500000 #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); ##### END OF PATCH ##### >Release-Note: >Audit-Trail: >Unformatted: