caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ::how to locate the function in profile generated by gprof
@ 2013-02-01 10:09 沈胜宇
  2013-02-01 12:11 ` rixed
  0 siblings, 1 reply; 3+ messages in thread
From: 沈胜宇 @ 2013-02-01 10:09 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

Dear all:


I have a ocaml program compiled by "ocamlopt.opt -p".


In the profile generated from gprof, there are lots of anonymous function with name caml<module name>__fun_<number>.


For example, I have a module Misc, so there are function name like camlMisc__fun_1201.


So how can I locate the this function in source code?


Shen


[-- Attachment #2: Type: text/html, Size: 717 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ::how to locate the function in profile generated by gprof
  2013-02-01 10:09 [Caml-list] ::how to locate the function in profile generated by gprof 沈胜宇
@ 2013-02-01 12:11 ` rixed
  2013-02-01 12:30   ` Török Edwin
  0 siblings, 1 reply; 3+ messages in thread
From: rixed @ 2013-02-01 12:11 UTC (permalink / raw)
  To: caml-list

-[ Fri, Feb 01, 2013 at 06:09:21PM +0800, ?????? ]----
> For example, I have a module Misc, so there are function name like camlMisc__fun_1201.
> So how can I locate the this function in source code?

What I'd do is recompile the Misc module with -S to have the assembly temporary
file and look in there camlMisc__fun_1201.  First I'd note if this anonymous
function does raise some exception or allocate some memory (it's easy to tell
from the asm version), then I'd follow up the caller chain up to the first
named function.  Then back to the definition of this named function in misc.ml,
I'd look for all anonymous functions available from there that have the same
caracteristics reguarding exceptions and allocation.

In case there are many anonymous functions in there or because of inlining this
may be hard but in general it's quite easy to find out the culprit from there.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ::how to locate the function in profile generated by gprof
  2013-02-01 12:11 ` rixed
@ 2013-02-01 12:30   ` Török Edwin
  0 siblings, 0 replies; 3+ messages in thread
From: Török Edwin @ 2013-02-01 12:30 UTC (permalink / raw)
  To: caml-list

On 2013-02-01 14:11, rixed@happyleptic.org wrote:
> -[ Fri, Feb 01, 2013 at 06:09:21PM +0800, ?????? ]----
>> For example, I have a module Misc, so there are function name like camlMisc__fun_1201.
>> So how can I locate the this function in source code?
> 
> What I'd do is recompile the Misc module with -S to have the assembly temporary
> file and look in there camlMisc__fun_1201.  First I'd note if this anonymous
> function does raise some exception or allocate some memory (it's easy to tell
> from the asm version), then I'd follow up the caller chain up to the first
> named function.  Then back to the definition of this named function in misc.ml,
> I'd look for all anonymous functions available from there that have the same
> caracteristics reguarding exceptions and allocation.
> 
> In case there are many anonymous functions in there or because of inlining this
> may be hard but in general it's quite easy to find out the culprit from there.
> 

With OCaml 4.00.1 it might work to add -g to ocamlopt and use gdb to find out, for example:
$ ocamlopt x.ml -g -p -o x
$ gdb ./x
(gdb) b camlPrintf__fun_1770
Breakpoint 1 at 0x411ed0: file printf.ml, line 651.

--Edwin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-01 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-01 10:09 [Caml-list] ::how to locate the function in profile generated by gprof 沈胜宇
2013-02-01 12:11 ` rixed
2013-02-01 12:30   ` Török Edwin

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 NNTP newsgroup(s).