Article View: gnu.gcc.help
Article #49679Is anybody working on profiling code in gcc?
From: meissner
Date: Thu, 13 Jan 1994 19:58
Date: Thu, 13 Jan 1994 19:58
84 lines
3910 bytes
3910 bytes
|
| As far as I am aware gcc has an option (possibly -a) to allow line-by-line
| execution count information to be collected.
|
| However I remember that this information was not in a format for existing
| programs to read. The two programs I know about that do a similar job are
| tcov (on SunOS) and lprof (under SVr4). With appropriate compilation options
| raw data is created from a program run which is then processed.
|
| I am interested in
|
| 1) Does the Gnu stuff already work with one or both of these
| programs. (I don't think it does).
|
| 2) Does anybody have an interest in getting it working OR is
| anyone currently working on this
|
|
| As some justification for the effort involved, after regular profiling using
| prof and/or gprof. I then used lprof to determine which lines of large single
| functions were executed many times. The routines that showed up with high
| usage were then examined and in some cases a further speedup of 20% was achieved
|
| I am just interested as it would be a nice thing to have with gcc.
| Unfortunately I do not have the time to look for this and do it myself as I
| have other commitments.
I put in the current support. While it doesn't deal with any existing
tools (except in the 68k sun case, and that is supposed to be broken),
the file it outputs by default is a plain text file. One of the
problems is figuring out exactly what the formats of data that
tcov/lprof expect, since by and large they are not documented
interfaces, and vendors feel free to modify them.
Not all backends have support for block profiling. At present, the
gmicro, h8300, i960, i386 (osfrose/osfelf only, not other targets),
m68k (sun and tower only), sparc, vax, and we32k have at least some of
the support. The other backends do not.
You might get what you need by eyeballing the output and/or writing
perl or awk filters. Be sure to add -g, so that the line numbers are
recorded.
For example, consider the following program:
main(){
int i;
printf("Before loop.\n");
for(i = 0; i < 10; i++)
printf("Inside loop.\n");
printf("After loop.\n");
return 0;
}
Running gcc -a -g -O foo.c && a.out on my 486 produces the following in bb.out:
Basic block profiling finished on Thu Jan 13 14:48:54 1994
File foo.d, 3 basic blocks
Block #1: executed 1 time(s) address= 0x400178 function= main line= 1 file= foo.c
Block #2: executed 10 time(s) address= 0x40019c function= main line= 6 file= foo.c
Block #3: executed 1 time(s) address= 0x4001b2 function= main line= 8 file= foo.c
If I run it without the -g switch, I get the output:
Basic block profiling finished on Thu Jan 13 14:50:37 1994
File foo.d, 3 basic blocks
Block #1: executed 1 time(s) address= 0x400178 function= main
Block #2: executed 10 time(s) address= 0x40019c function= main
Block #3: executed 1 time(s) address= 0x4001b2 function= main
The BLOCK_PROFILER_CODE macro is the one that controls the output of
the tables generated.
--
Michael Meissner email: meissner@osf.org phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
Old hackers never die, their bugs just increase.
Technical Details
Message-ID:
<9401131955.AA23654@pasta.osf.org>Path:
arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!osf.ORG!meissnerReferences:
meissner@osf.ORGShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,8c876b2ebaa3d8e0,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1994-01-13 13:23:26 PST Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!osf.ORG!meissner From: meissner@osf.ORG Newsgroups: gnu.gcc.help Subject: Is anybody working on profiling code in gcc? Date: 13 Jan 1994 14:58:48 -0500 Organization: GNUs Not Usenet Lines: 84 Sender: daemon@cis.ohio-state.edu Distribution: gnu Message-ID: <9401131955.AA23654@pasta.osf.org> References: meissner@osf.ORG