* Question about instrumenting gcc
[not found] <4FCE31EF.7060307@inf.u-szeged.hu>
@ 2012-06-05 16:26 ` Renata Hodovan
2012-06-05 19:38 ` Ian Lance Taylor
0 siblings, 1 reply; 5+ messages in thread
From: Renata Hodovan @ 2012-06-05 16:26 UTC (permalink / raw)
To: gcc-help
Hi All,
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.
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
The build was successful this way but when I tried to compile something
it resulted empty output files. (Theoretically __end_test__should have
written its result to a given file.)
What do I make wrong? Thanks in advance!
Cheers,
Reni
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Question about instrumenting gcc
2012-06-05 16:26 ` Question about instrumenting gcc Renata Hodovan
@ 2012-06-05 19:38 ` Ian Lance Taylor
2012-06-12 13:12 ` Renata Hodovan
0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2012-06-05 19:38 UTC (permalink / raw)
To: Renata Hodovan; +Cc: gcc-help
Renata Hodovan <hodovan@inf.u-szeged.hu> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Question about instrumenting gcc
2012-06-05 19:38 ` Ian Lance Taylor
@ 2012-06-12 13:12 ` Renata Hodovan
2012-06-12 16:42 ` Ian Lance Taylor
0 siblings, 1 reply; 5+ messages in thread
From: Renata Hodovan @ 2012-06-12 13:12 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-help
Hi Ian,
thank you very much your help. I redesigned __cyg_profile_enter and
__cyg_profile_exit functions and I stay in the right memory interval.
Furthermore I'm using now main_constructor and main_destructor instead
of start_test and end_test. The settings of make also seem good, it
creates the output of instrumentation that way what I expected. But the
compilation failed after a point because it couldn't understand e.g.
size_t in filenames.h and a lot of similar errors in files what I
haven't touched. I thought, since I add file IO operations to the main.c
or linking the instrument file to the project, I distracted somehow the
dependency. At this point I tried to compile the gcc --disable-bootstrap
but then the instrumentation flag hadn't any results. What is the
problem now? :S
thanks,
Reni
On 06/05/2012 09:38 PM, Ian Lance Taylor wrote:
> Renata Hodovan<hodovan@inf.u-szeged.hu> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Question about instrumenting gcc
2012-06-12 13:12 ` Renata Hodovan
@ 2012-06-12 16:42 ` Ian Lance Taylor
2012-06-14 9:11 ` Renata Hodovan
0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2012-06-12 16:42 UTC (permalink / raw)
To: Renata Hodovan; +Cc: gcc-help
Renata Hodovan <hodovan@inf.u-szeged.hu> writes:
> thank you very much your help. I redesigned __cyg_profile_enter and
> __cyg_profile_exit functions and I stay in the right memory
> interval. Furthermore I'm using now main_constructor and
> main_destructor instead of start_test and end_test. The settings of
> make also seem good, it creates the output of instrumentation that way
> what I expected. But the compilation failed after a point because it
> couldn't understand e.g. size_t in filenames.h and a lot of similar
> errors in files what I haven't touched. I thought, since I add file IO
> operations to the main.c or linking the instrument file to the
> project, I distracted somehow the dependency. At this point I tried to
> compile the gcc --disable-bootstrap but then the instrumentation flag
> hadn't any results. What is the problem now? :S
When you configure with --disable-bootstrap, use CFLAGS rather than
BOOT_CFLAGS. BOOT_CFLAGS only applies to stages 2 and 3.
I have no idea what the problem is when bootstrapping. You would need
to provide more information.
Ian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Question about instrumenting gcc
2012-06-12 16:42 ` Ian Lance Taylor
@ 2012-06-14 9:11 ` Renata Hodovan
0 siblings, 0 replies; 5+ messages in thread
From: Renata Hodovan @ 2012-06-14 9:11 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-help
Thank you, Ian. This way instrumenting works fine!
Cheers,
Reni
On 06/12/2012 06:41 PM, Ian Lance Taylor wrote:
> Renata Hodovan<hodovan@inf.u-szeged.hu> writes:
>
>> thank you very much your help. I redesigned __cyg_profile_enter and
>> __cyg_profile_exit functions and I stay in the right memory
>> interval. Furthermore I'm using now main_constructor and
>> main_destructor instead of start_test and end_test. The settings of
>> make also seem good, it creates the output of instrumentation that way
>> what I expected. But the compilation failed after a point because it
>> couldn't understand e.g. size_t in filenames.h and a lot of similar
>> errors in files what I haven't touched. I thought, since I add file IO
>> operations to the main.c or linking the instrument file to the
>> project, I distracted somehow the dependency. At this point I tried to
>> compile the gcc --disable-bootstrap but then the instrumentation flag
>> hadn't any results. What is the problem now? :S
> When you configure with --disable-bootstrap, use CFLAGS rather than
> BOOT_CFLAGS. BOOT_CFLAGS only applies to stages 2 and 3.
>
> I have no idea what the problem is when bootstrapping. You would need
> to provide more information.
>
> Ian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-14 9:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <4FCE31EF.7060307@inf.u-szeged.hu>
2012-06-05 16:26 ` Question about instrumenting gcc Renata Hodovan
2012-06-05 19:38 ` Ian Lance Taylor
2012-06-12 13:12 ` Renata Hodovan
2012-06-12 16:42 ` Ian Lance Taylor
2012-06-14 9:11 ` Renata Hodovan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).