From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id BA352BB84 for ; Tue, 15 Jul 2008 08:13:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqUGAEXde0jOe3NG/2dsb2JhbACDJKo5 X-IronPort-AV: E=Sophos;i="4.30,364,1212357600"; d="scan'208";a="15107189" Received: from spoomusic.com ([206.123.115.70]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Jul 2008 08:13:58 +0200 Received: (qmail 1077 invoked by uid 89); 15 Jul 2008 06:13:57 -0000 Received: from unknown (HELO ?192.168.1.99?) (98.165.129.233) by 0 with ESMTPS (DHE-RSA-AES256-SHA encrypted); 15 Jul 2008 06:13:57 -0000 Message-ID: <487C4006.3090008@ramenlabs.com> Date: Mon, 14 Jul 2008 23:13:26 -0700 From: Dave Benjamin User-Agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080420) MIME-Version: 1.0 To: blue storm Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Name of currently executing function References: <487AE3A6.2080008@ramenlabs.com> <527cf6bc0807140653w6bb30b5nfa73e2e16462f181@mail.gmail.com> In-Reply-To: <527cf6bc0807140653w6bb30b5nfa73e2e16462f181@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; camlp:01 ad-hoc:01 camlp:01 syntax:01 ocaml:01 ocaml:01 complained:01 complained:01 toplevel:01 endline:01 makefile:01 lib:01 printexc:01 storm:98 unbound:01 blue storm wrote: > Here is a little camlp4 code for an ad-hoc solution : > http://bluestorm.info/camlp4/Camlp4GenericProfiler.ml This works very well. Thank you very much for the example. On a related note, I was trying to understand how these new syntax filters work, and I am a bit confused by how I'm supposed to use Camlp4Tracer. I tried compiling a simple test program with: camlp4 -parser ocaml -filter tracer -printer ocaml It complained about an unknown value "Debug.mode", which I figured out was in the Camlp4 library, so I added that library and the line: module Debug = Camlp4.Debug to my program. Then it complained about an unbound value "exc". I looked at the Camlp4Tracer.ml to discover that it expects an exception named "exc" to be in scope with every function. I'm not sure what this is for, but I was able to get it to compile by creating a toplevel variable. My test program looks like the following now: (*pp camlp4 -parser ocaml -filter tracer -printer ocaml *) module Debug = Camlp4.Debug let exc = Not_found let test () = print_endline "this is output" let () = test () And my Makefile looks like this: OCAMLMAKEFILE := OCamlMakefile SOURCES := main.ml USE_CAMLP4 := yes PACKS := camlp4.lib RESULT := main include $(OCAMLMAKEFILE) Now, I can get tracing output: % CAMLP4_DEBUG=* ./main camlp4-debug: tracer: Not_found at File "main.ml", line 8, characters 16-32 this is output So, is this the way it's supposed to work? Is this exception supposed to be some sort of marker for logging purposes? It seems like maybe the Printexc stuff was accidentally pasted in from the Camlp4ExceptionTracer, but without any docs, it's hard to tell for sure. Dave