This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: profiling


Zdenka Safarzik wrote:
Hello,

I want to made hardware profiling. For that purposes I need to have
instrumented source code that has to be profiled. At every beginning and end
of function and program loops writing to one register must be inserted. Each
faction write different value in that register. My hardware detects access
to that register, which function had access and time when that access was
happen.

For source code instrumentation I want to use gcc. As gcc is very complex
software, I hope that you can help me.

I read gecko documentation, and it seems to me that -pg or -test-coverage
options can be used for this purpose. Can you please tell me what exactly
these options do? Do they insert some code before compiling or before
linking? Where is it in gcc source code? Can I easy change that code with
writing to some register?  Is it possible to set profiling hierarchy level
(for example: to add extra code only on "main" function instead of whole
source)?
The -pg option puts a function call at the beginning of each function to mcount. The -pg option doesn't put anything at the end of the function. This is probably not going to be very useful for what you are interested in doing.

You might look at the "-finstrument-functions" option. This option puts a call to __cyg_profile_func_enter at the beginning of each function and a call to __cyg_profile_func_exit at the end of each function. The programmer needs to supply the instrumentation functions. It can be turned off with the "no_instrument_function" attribute on a function-by-function basis.

As far as finding how the options are implementing code, use the "-dap" on simple test programs to see what the RTL looks like. You can also use "-save-temps" to keep around the assembly language files.

The source code for gcc is available from a number of places:

http://www.gnu.org/software/gcc/mirrors.html

It may take some time to figure out how to make the changes. GCC is a relatively complicated program. However, the GCC Internals Manual available from http://www.gnu.org/software/gcc/onlinedocs/ will help.

Good luck.

-Will Cohen



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]