- To: Renata Hodovan <hodovan@xxxxxxxxxxxxxxx>
- Subject: Re: Question about instrumenting gcc
- From: Ian Lance Taylor <iant@xxxxxxxxxx>
- Date: Tue, 05 Jun 2012 12:38:23 -0700
- Cc: gcc-help@xxxxxxxxxxx
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- In-reply-to: <4FCE331A.5060702@inf.u-szeged.hu> (Renata Hodovan's message of "Tue, 05 Jun 2012 18:26:02 +0200")
- User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Renata Hodovan <hodovan@xxxxxxxxxxxxxxx> writes:
> I have to instrument gcc for some purposes. The goal is to be able to
> track what GCC functions are called during a particularly
> compile. Unfortunately I'm not really familiar with the architecture
> of GCC so I need a little help. I tried the following steps:
>
> 1) Hacking gcc/Makefile.in and adding "-finstrument-functions" flag to
> T_CFLAGS.
> 2) I have an already implemented and tested version of __start_test__
> and __end_test__ functions. They are called from gcc/main.c, before
> and after toplev_main() call. The containing file is linked to gcc
> (the object is added to OBJS-common and the dependency is defined
> later in gcc/Makefile.in)
> 3) Downloading prerequisites with contrib/download_prerequisites.
> 4) Executing the configuration from a clean build directory (on the
> same level with the source dir): ./../gcc-4.6.2/configure
> --prefix="/opt/gcc-4.6.2/" --enable-languages="c,c++"
> 5) Starting the build with "make all"
>
> This way I ran out of memory, although I had 28G.
You should not have run out of memory at this step, not with 28G.
Adding -finstrument-functions should not have significantly changed the
memory usage of the build.
But I suppose you could have run out of memory if your
__cyg_profile_func_enter function uses a lot of memory. If that is the
problem, then that is what you will have to fix.
> Next I tried to remove the T_CFLAGS settings from the Makefile and
> gave -finstrument-functions to the make command:
> make CFLAGS+="-finstrument-functions" all
This won't build the compiler itself with -finstrument-functions. For
that you need to use
make BOOT_CFLAGS="-g -O2 -finstrument-functions"
Ian
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]