This is the mail archive of the
sid@sources.redhat.com
mailing list for the SID project.
Re: Profiling
- From: Scott Dattalo <scott at dattalo dot com>
- To: "Frank Ch. Eigler" <fche at redhat dot com>
- Cc: sid at sources dot redhat dot com
- Date: Wed, 26 Jun 2002 10:41:59 -0700 (PDT)
- Subject: Re: Profiling
On Tue, 25 Jun 2002, Frank Ch. Eigler wrote:
> Hi -
>
> On Tue, Jun 25, 2002 at 07:01:39PM -0700, Scott Dattalo wrote:
> > [...]
> > But the question I have is how do you build arm-elf-gprof [...]
>
> The gprof program, for historical reasons, is sometimes excluded
> from a cross-targeted toolchain. If you have a source tree with
> a Cygnus configure script at the top level, or a gcc source tree,
> then look for the "native_only" variable from the top-level
> configure.in, remove "gprof". Then reconfigure the build tree,
> and run "make" in the gprof subdirectory.
That did it!
Just to be clear, this is what I did:
I untar'd the binutils-2.12.1 tar ball and edited
binutils-2.12.1/configure.in. There's a line containing "native_only" that
several packages (like gprof, sed,...); I removed gprof from that list.
I then followed the instructions here for building binutils:
http://sources.redhat.com/ecos/tools/linux-arm-elf.html
and arm-elf-gprof was created! Score!
---
Now for profiling...
My application uses the eCos RTOS and consequently is linked with it. I
discovered that you *can't* compile the source for profiling by adding -pg
option as part of the CFLAGS. Okay, I'm lying; you can compile with the
-pg option, but you get unresolved references when you link. I don't know
if eCos can be configured for profiling or not. I'll check into that
later. For the time being though, I don't need it. I was able to extract
profiling info just fine without compiling the sources with -pg. Here's
what I did:
1) Configured SID for profiling. I followed the instructions in the SID
documentation. Essentially, I added --gprof and --trace-counter to the SID
invocation. BTW, I also told SID to creat a configuration file by adding
--save-temps and --no-run to the invocation. Once you have a configuration
file, you can invoke SID by: sid configuration_file.conf.
2) Run the application. Again, following the instructions on the SID web
page, I started sid and ran my application:
sid myconf.conf &
arm-elf-gdb myexecutable
in gdb, add these commands:
(gdb) target remote localhost:2000
(gdb) load
(gdb) break main
(gdb) cont
(note that this is a copy-n-paste from the SID faq)
I then stepped through my code and exited gdb when I was done.
3) looking at the results. Upon exiting gdb, the file "gmon.prof" is
created. This contains the profile information. Use gprof to look at it:
arm-elf-gprof --flat-profile myexecutable
Without --flat-profile, gprof reports:
arm-elf-gprof: gmon.out file is missing call-graph data
Also, you need to specify the executable to gprof and not the gmon.out
file.
The first few lines of my profile look like this:
Flat profile:
Each sample counts as 1 tick.
% cumulative self self total
time tick tick calls Tt/call Tt/call name
16.87 1009.00 1009.00 __unpack_f
16.57 2000.00 991.00 __pack_f
13.21 2790.00 790.00 _fpadd_parts
9.73 3372.00 582.00 __floatsisf
------
And now I can go off and do some work!
Thanks for the info Frank.
Scott
PS. Sorry about the abruptly ending e-mail I sent to you privately. I was
composing it for the whole list, but ran out of time. I shouldn't of even
sent it.