From ryanb@goddamnbastard.org  Wed Jan 22 23:02:56 2003
Return-Path: <ryanb@goddamnbastard.org>
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
Subject: [PATCH] gprof -K still requires "a.out" arg / overrides in-kernel function list
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         47387
>Category:       bin
>Synopsis:       [patch] gprof(1) -K still requires "a.out" arg / overrides in-kernel function list
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 22 23:10:05 PST 2003
>Closed-Date:    Mon Jan 12 21:50:11 UTC 2009
>Last-Modified:  Mon Jan 12 22:00:04 UTC 2009
>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:
State-Changed-From-To: open->closed 
State-Changed-By: obrien 
State-Changed-When: Mon Jan 12 21:49:52 UTC 2009 
State-Changed-Why:  
Committed, thanks! 


Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: obrien 
Responsible-Changed-When: Mon Jan 12 21:49:52 UTC 2009 
Responsible-Changed-Why:  
Made the commit. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47387 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/47387: commit references a PR
Date: Mon, 12 Jan 2009 21:49:54 +0000 (UTC)

 Author: obrien
 Date: Mon Jan 12 21:49:42 2009
 New Revision: 187116
 URL: http://svn.freebsd.org/changeset/base/187116
 
 Log:
   If running with "-K" really do not information about symbols from the a.out
   argument.  Before this fix, after searching the currently-running kernel,
   we would still search the a.out argument - completely override the in-kernel
   list, essentially defeating the K flag's purpose.
   
   PR:		47387
   Submitted by:	Ryan Beasley <ryanb@goddamnbastard.org>
 
 Modified:
   head/usr.bin/gprof/gprof.c
 
 Modified: head/usr.bin/gprof/gprof.c
 ==============================================================================
 --- head/usr.bin/gprof/gprof.c	Mon Jan 12 21:30:22 2009	(r187115)
 +++ head/usr.bin/gprof/gprof.c	Mon Jan 12 21:49:42 2009	(r187116)
 @@ -165,7 +165,7 @@ main(argc, argv)
  	 *	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);
  	/*
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
