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 PAA14308; Wed, 14 Nov 2001 15:46:45 +0100 (MET) 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 PAA14025 for ; Wed, 14 Nov 2001 15:46:43 +0100 (MET) Received: from mail.mimuw.edu.pl (paf87.warszawa.sdi.tpnet.pl [217.96.225.87]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fAEEkc526178 for ; Wed, 14 Nov 2001 15:46:39 +0100 (MET) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id PAA22309 for caml-list@inria.fr; Wed, 14 Nov 2001 15:47:17 +0100 X-Authentication-Warning: qrnik.zagroda: news set sender to Marcin 'Qrczak' Kowalczyk using -f From: "Marcin 'Qrczak' Kowalczyk" Subject: Re: [Caml-list] A few questions regarding the compiler Date: Wed, 14 Nov 2001 14:47:13 +0000 (UTC) Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: References: <9smdf7$511$1@qrnik.zagroda> <9ssfsl$fa4$1@qrnik.zagroda> <9sttmn$kei$1@qrnik.zagroda> X-Trace: qrnik.zagroda 1005749233 21284 192.168.0.1 (14 Nov 2001 14:47:13 GMT) X-Complaints-To: abuse@localhost NNTP-Posting-Date: Wed, 14 Nov 2001 14:47:13 +0000 (UTC) User-Agent: slrn/0.9.7.2 (Linux) To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 14 Nov 2001 14:20:37 +0100, David Mentre pisze: > Maybe I have missed something but the point of raising an exception and > getting its location has already been discussed on the list: > http://caml.inria.fr/archives/200007/msg00028.html (look also at the thread) > > To generate a backtrace, just do an "assert(false)" with the environment > variable OCAMLRUNPARAM set to "b=1" (without quotes, see man ocamlrun). I know, but the backtrace is just dumped to stderr just before the program dies. I would like the program itself to have access to its own backtrace, so it can do something with it instead of displaying it in the default format and dying. I can wrap each top-level value binding which can fail in a 'try ... with exn -> my_handler exn' (i.e. I let my compiler generate such code), where my_handler does some magic to access the backtrace and translates it to something readable. I'll now try to do it myself basing on backtrace.c, but I don't understand yet how it works. A more convenient way would be to call some magic hook which will install my_handler for unhandled exceptions instead of the builtin fatal_uncaught_exception, so I would save those 'try ...' for each binding. Looking at the code I guess that it's now impossible, calling fatal_uncaught_exception is just hardwired in appropriate places. > Yes. Somebody has written a tool to convert a trace in source position: > http://caml.inria.fr/archives/200109/msg00111.html This is an external tool which reads original sources and the backtrace. I want to customize the backtrace itself. Especially as OCaml sources is only an intermediate step between my language and executable - they should not be required to be available for producing a proper backtrace. I will set up my own translation of OCaml positions to original source positions and embed it in the program. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr