This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to create a plugin to instrument function calls?
- From: Paul <pgsery at swcp dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 23 Sep 2009 22:01:33 -0600
- Subject: Re: How to create a plugin to instrument function calls?
Ian Lance Taylor<iant@google.com> said:
"Paul Sery"<pgsery@swcp.com> writes:
> I want to create a plugin that inserts custom code before function calls. The
> plugin would mimic the way fprofile-arcs instruments function calls, but not
> other structures. For instance, I'd like to modify the following code,
> ...
> I think/guess the best place for this to occur is in the assembler, like
> finstrument-functions?
The assembler is an OK place to hack things which change the function
prologue or epilogue. It sounds like you want to change the actual body
of the function, which is quite different. I would suggest working at
the GIMPLE level instead, and modifying function calls there.
Ok, I'll go that route. Do you think it better recycle an existing function like the one
finstrument-functions option uses?
...
profile_function_entry_libfunc
= init_one_libfunc ("__cyg_profile_func_enter");
--->
profile_function_entry_libfunc
= init_one_libfunc ("__myfn");
or perhaps mimic the way the gcov option works?
...
= build_function_type_list (void_type_node,...
= build_fn_decl ("__gcov_interval_profiler",
...
Thanks,
Paul