OCAML native code profiler for x86 + gcc

Of course even without any patch you can always pass -ccopt -p option to ocamlopt and get some profiling information, but with -ccopt -p you would only get the "flat" profile, while with my patch you will also get the full call graph, including the information on

I wrote my patch to mimic the behavior of gcc -pg - the patched ocamlopt works in exactly the same way as the usual ocamlopt unless it is given the -p option. When given the -p option, the patched ocamlopt:

I tested my patch only on RedHat Linux 5.1 system, but it will probably work fine on any other x86 + gcc system and I believe that it should not be too hard to port it for use with other C compilers (you will probably need to change -pg to -p and mcount to something else) or even to some other hardware architecture.

Of course there is NO WARRANTY - it works for me, but you are using it at your own risk.

To use the profiler:

  1. Apply my patch and recompile ocaml
  2. Recompile your code with -p option (only .ml files, you do not have to recompile .mli files).
  3. Run your code. It should generate the gmon.out file.
  4. Run gprof <program executable>.

Please, note:


Back Back to the Patches Page

Last update: Friday, December 14, 2001 by Aleksey Nogin (e-mail: Nogin@CS.Cornell.EDU)