From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id EAA12671; Wed, 3 Dec 2003 04:25:26 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 EAA11002 for ; Wed, 3 Dec 2003 04:25:24 +0100 (MET) Received: from smtp.siren.ocn.ne.jp (siren.ocn.ne.jp [211.129.13.170]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hB33PMr29093 for ; Wed, 3 Dec 2003 04:25:22 +0100 (MET) Received: from PWARP (p4029-ipad05kyoto.kyoto.ocn.ne.jp [220.105.41.29]) by smtp.siren.ocn.ne.jp (Postfix) with SMTP id E68C21D73; Wed, 3 Dec 2003 12:25:19 +0900 (JST) Message-ID: <000201c3b94d$11646b80$0274a8c0@PWARP> From: "Nicolas Cannasse" To: , "Issac Trotts" References: <1070398239.15748.57.camel@flapdragon.homeip.net> <20031202222628.GA1640@localhost> Subject: Re: [Caml-list] getting stack traces in running code Date: Wed, 3 Dec 2003 12:19:05 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 openpgp:01 sks:99 unexpected:01 debugging:01 pervasives:01 failwith:01 backtrace:01 mli:01 strace:01 printexc:01 backtrace:01 stub:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Is there a reason why stack traces are available only on a crash? I > > have a project (a distributed OpenPGP keyserver system, > > http://www.nongnu.org/sks/) that is a long-running daemon. Unexpected > > errors are caught and logged, but unfortunately, there's no way of > > getting a stack-trace, since I don't let the exceptions kill the > > program. This makes debugging much more difficult, and is one of the > > single largest difficulties I have with ocaml. Is there a technical > > reason that a bytecode-compiled executable couldn't have access to the > > stack trace during execution? > > I have a partial solution: [...] > It's not quite right yet because it only prints out the > place where the exception was raised (which will be in > Pervasives if you use failwith), and the place where it > was caught and printed. Does someone know how to make it > print the whole stack? I think this is because you're adding an additional call to "print", that is writing on the stack (!). Since you can't write on the stack, you can't call any ML handler between catching and printing the exception. You should then have no backtrace.ml and only a mli with : external print_stack_strace : unit -> unit = "internal_print" the user can then print the exception using a Printexc... after printing the stack. BTW, if the "print_exception_backtrace" of the caml sources was exported as Primitive, we would be able to do it without the need of any C stub : the other way to do it is then to run a modified interpreter where CAMLexport have been replaced with CAMLprim in backtrace.c.... Nicolas Cannasse ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners