Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jan 2003 01:02:50 -0600 (CST)
From:      ryanb@goddamnbastard.org
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        charnier@FreeBSD.org
Subject:   bin/47387: [PATCH] gprof -K still requires "a.out" arg / overrides in-kernel function list
Message-ID:  <20030123070250.575EF155C4@mx01.goddamnbastard.org>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030123070250.575EF155C4>