From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id AFD90BB9A for ; Tue, 8 Nov 2005 11:07:08 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jA8A78Y6011933 for ; Tue, 8 Nov 2005 11:07:08 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA32749 for ; Tue, 8 Nov 2005 11:07:07 +0100 (MET) Received: from publilogics.com (pouic.publilogics.com [213.186.50.35]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id jA8A77rl007844 for ; Tue, 8 Nov 2005 11:07:07 +0100 Received: (qmail 1820 invoked from network); 8 Nov 2005 10:07:06 -0000 Received: from unknown (HELO PWarp) ([61.213.94.147]) (envelope-sender ) by pouic.publilogics.com (qmail-ldap-1.03) with SMTP for ; 8 Nov 2005 10:07:06 -0000 Message-ID: <002201c5e44c$25f15eb0$0c05a8c0@PWarp> From: "Nicolas Cannasse" To: "Alessandro Baretta" Cc: "skaller" , References: <1131416033.23991.57.camel@rosella> <001e01c5e443$c7259d40$0c05a8c0@PWarp> <43707E30.2040405@barettadeit.com> Subject: Re: [Caml-list] Seeking exception source Date: Tue, 8 Nov 2005 19:06:53 +0900 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Miltered: at nez-perce with ID 437078CC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 437078CB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; cannasse:01 ncannasse:01 motion-twin:01 caml-list:01 bytecode:01 ocamlrun:01 backtrace:01 bytecode:01 backtrace:01 terminate:01 uncaught:01 ocaml:01 uncaught:01 ocaml:01 stack:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 >>> I am occasionally annoyed by Not_found propagating to my >>> top level function .. meaning the error could be anywhere >>> at all in my program. >> >> >> At that time the best is to run your program in bytecode with debug infos >> using ocamlrun -b so you'll get full backtrace informations. It would be >> better for such debug informations (not all the types but only the >> bytecode -> source positions) to be included by default, and always have >> backtrace turned on. > > In many cases this is completely inadequate. The AS/Xcaml application > server, for example, cannot terminate on an uncaught exception in a > program module. The main loop must catch the exception and do its best to > report it, without aborting the execution of the server. This means that I > need to get the backtrace within Ocaml code by applying some kind of > function to the exception object. I tried to write a C function providing > this kind of information, but I never managed to get it to work. > > Alex Yes I agree, this is not all the time easy to get exceptions backtraces since it's only possible for uncaught ones. At some time I managed to modify the Ocaml interpreter to make it work, by exporting some C inner interpreter functions but I'm not sure it was a correct hack. On the NekoVM which some design points are inspired by the OCaml VM, I recently added exception stack traces. In fact, I was thinking that this will cost more performances than it actualy did. The impact on the bootstrapping time of NekoML was quite low. It's true that the compiler being written in an ML language, quite often exceptions are used to control the flow of the program (Not_found , Eof and Exit among others). But since in general the position of catching is just a few calls away from the throw, you don't have to unwind a lot of debug informations. It is also useful in that case to have a "reraised" semantic that will keep the stack when an execption is filtered. But OCaml have that. Having full exceptions backtraces plus call stack traces available at anytime is a big plus when working on the NekoML compiler. The tagged union printers automaticaly generated and carried with instances are helping a lot too, since you can "print" polymorphicaly any runtime value. I think this is very small things that would greatly ease the everyday ocaml programmer life. Nicolas Cannasse