From owner-freebsd-bugs Wed Jan 22 23:10: 9 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B91BA37B401 for ; Wed, 22 Jan 2003 23:10:06 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D2C1643F43 for ; Wed, 22 Jan 2003 23:10:05 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h0N7A5NS068752 for ; Wed, 22 Jan 2003 23:10:05 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h0N7A5fm068751; Wed, 22 Jan 2003 23:10:05 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D14FD37B401; Wed, 22 Jan 2003 23:02:56 -0800 (PST) Received: from mx01.goddamnbastard.org (12-249-234-146.client.attbi.com [12.249.234.146]) by mx1.FreeBSD.org (Postfix) with ESMTP id 447B443F43; Wed, 22 Jan 2003 23:02:51 -0800 (PST) (envelope-from ryanb@goddamnbastard.org) Received: by mx01.goddamnbastard.org (Postfix, from userid 1000) id 575EF155C4; Thu, 23 Jan 2003 01:02:50 -0600 (CST) Message-Id: <20030123070250.575EF155C4@mx01.goddamnbastard.org> Date: Thu, 23 Jan 2003 01:02:50 -0600 (CST) From: ryanb@goddamnbastard.org Reply-To: ryanb@goddamnbastard.org To: FreeBSD-gnats-submit@FreeBSD.org Cc: charnier@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/47387: [PATCH] gprof -K still requires "a.out" arg / overrides in-kernel function list Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 47387 >Category: bin >Synopsis: [PATCH] gprof -K still requires "a.out" arg / overrides in-kernel function list >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jan 22 23:10:05 PST 2003 >Closed-Date: >Last-Modified: >Originator: ryan beasley >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD fredrik.internal.goddamnbastard.org 5.0-CURRENT FreeBSD 5.0-CURRENT #14: Thu Jan 9 10:19:05 CST 2003 root@fredrik.internal.goddamnbastard.org:/usr/obj/usr/src/sys/FREDRIK_DP_INV i386 usr.bin/gprof/gprof.c 1.20 >Description: According to gprof(1) manual, the -K flag compiles a namelist from the running kernel rather than the "a.out" argument supplied on the commandline. A major use for this functionality is to be able to profile KLDs. There are two problems here, though my patch really addresses only the last: Even if the -K flag is set, a user must specify at least the a.out argument, contrary to the documentation. (If this argument is going to be ignored, why bother requiring it?) Not too big a deal. There is an error in handling the Kflag in that after searching the kernel's tables, the a.out argument is still searched, completely overriding the in-kernel list, essentially defeating the K flag's purpose. >How-To-Repeat: Build a kernel with profile support (config -p, CONFIGOPTS=-p, etc.). Build a KLD with profiling (pass -pg to cc(1)) /path/to/kgmon -b (start profiling) *wait* /path/to/kgmon -p (dump the profile buffers) /path/to/gprof -K /path/to/bootfile /path/to/gmon.out Watch in awe as information about your KLD is nowhere to be found! :) >Fix: The attached patch seems to take care of this. --- gprof.c.patch begins here --- Index: src/usr.bin/gprof/gprof.c =================================================================== RCS file: /vol1/FreeBSD/src/usr.bin/gprof/gprof.c,v retrieving revision 1.20 diff -u -r1.20 gprof.c --- src/usr.bin/gprof/gprof.c 16 Oct 2002 13:50:09 -0000 1.20 +++ src/usr.bin/gprof/gprof.c 23 Jan 2003 06:33:15 -0000 @@ -170,7 +170,7 @@ * get information from the executable file. */ if ((Kflag && kernel_getnfile(a_outname, &defaultEs) == -1) || - (elf_getnfile(a_outname, &defaultEs) == -1 && + !Kflag && (elf_getnfile(a_outname, &defaultEs) == -1 && aout_getnfile(a_outname, &defaultEs) == -1)) errx(1, "%s: bad format", a_outname); /* --- gprof.c.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message