These macros will help you generate code for profiling.
FUNCTION_PROFILER (file, labelno)
mcount
.
Before calling, the assembler code must load the address of a
counter variable into a register where mcount
expects to
find the address. The name of this variable is `LP
' followed
by the number labelno, so you would generate the name using
`LP%d
' in a fprintf
.
The details of how the address should be passed to mcount
are
determined by your operating system environment, not by GNU CC. To
figure them out, compile a small program for profiling using the
system's installed C compiler and look at the assembler code that
results.
PROFILE_BEFORE_PROLOGUE
FUNCTION_BLOCK_PROFILER (file, labelno)
__bb_init_func
once per object module, passing it as its sole
argument the address of a block allocated in the object module.
The name of the block is a local symbol made with this statement:
ASM_GENERATE_INTERNAL_LABEL (buffer, "LPBX", 0);
Of course, since you are writing the definition of
ASM_GENERATE_INTERNAL_LABEL
as well as that of this macro, you
can take a short cut in the definition of this macro and use the name
that you know will result.
The first word of this block is a flag which will be nonzero if the
object module has already been initialized. So test this word first,
and do not call __bb_init_func
if the flag is nonzero.
BLOCK_PROFILER (file, blockno)
ASM_GENERATE_INTERNAL_LABEL (buffer, "LPBX", 2);
Of course, since you are writing the definition of
ASM_GENERATE_INTERNAL_LABEL
as well as that of this macro, you
can take a short cut in the definition of this macro and use the name
that you know will result.
BLOCK_PROFILER_CODE