From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA04368 for caml-red; Sun, 2 Jul 2000 19:10:37 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA19341 for ; Sat, 1 Jul 2000 15:21:14 +0200 (MET DST) Received: from mail.ngi.de ([195.243.0.227]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e61DLD108474; Sat, 1 Jul 2000 15:21:13 +0200 (MET DST) Received: from ice.darmstadt.netsurf.de (62.224.60.187) by mail.ngi.de (5.1.034) id 39451E810010B1CA; Sat, 1 Jul 2000 15:17:49 +0200 Received: from localhost (localhost [[UNIX: localhost]]) by ice.darmstadt.netsurf.de (8.9.3/8.9.3) id PAA22851; Sat, 1 Jul 2000 15:16:53 +0200 From: Gerd Stolpmann Reply-To: gerd@gerd-stolpmann.de Organization: privat To: Xavier Leroy , Scott McPeak , caml-list@inria.fr Subject: Re: how to set breakpoint at exception throw? Date: Sat, 1 Jul 2000 14:57:30 +0200 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain References: <20000630150823.24021@pauillac.inria.fr> In-Reply-To: <20000630150823.24021@pauillac.inria.fr> MIME-Version: 1.0 Message-Id: <00070115165309.14914@ice> Content-Transfer-Encoding: 8bit Sender: weis@pauillac.inria.fr On Fri, 30 Jun 2000, Xavier Leroy wrote: >> [Scott McPeak:] In the debugger, I'd like to put a breakpoint essentially in >> the 'raise' function. The idea is to get control whenever an exception is >> raised, and be able to take a backtrace. >> Any ideas on how to do this? > >Reverse execution is your friend: simply run the program under the >debugger; if an uncaught exception causes the program to terminate, >back-step (command "back") once, and voila, you're at the point where >the exception was raised, and you can examine the backtrace. > >If your program traps all exceptions or performs finalization before >re-raising exceptions, you may have to back-step several times, but >eventually you'll hit the point where the exception was raised. This debugging technique should be mentioned in the manual; it is important enough. Does reverse execution also work for programs doing I/O, for example reading from a pipe? Nevertheless, I have a wish: At least for programs compiled with the bytecode compiler, an automatic backtrace of uncaught exceptions would be often helpful (i.e I get a list where the last uncaught exception was raised, and all locations where it is re-raised in the "with" clause of the "try" statement). First, this type of error is very frequent, and it would save much time if the location where the problem occurs were output from the failing program itself. Second, under some environments it is difficult to run the debugger; not every program is run from the command-line (CGI programs, for example). Furthermore, such a feature would help bug searching in production environments: on such machines, there is usually no debugger installed, and it is sometimes difficult to reconstruct the failing data case. For me, such a feature would be more worth than the loss of execution performance of exceptions. I can imagine that it might be even possible to turn such a feature dynamically on or off (by setting a hook in the bytecode interpreter). For multi-threaded programs, it is sufficient to store the list of uncaught exceptions for every thread, and to output the list of the failing thread. Gerd -- ---------------------------------------------------------------------------- Gerd Stolpmann Telefon: +49 6151 997705 (privat) Viktoriastr. 100 64293 Darmstadt EMail: gerd@gerd-stolpmann.de Germany ----------------------------------------------------------------------------