From: "Scott McPeak" <smcpeak@cs.berkeley.edu>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: how to set breakpoint at exception throw?
Date: Tue, 4 Jul 2000 18:28:43 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.21.0007041820480.393-100000@leetch.pasture.cow> (raw)
In-Reply-To: <20000630150823.24021@pauillac.inria.fr>
> > 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.
I tried this and it took me a while to get it right, in particular
because I was using Printexc.catch to catch it at toplevel, and
several places did catch-and-rethrow. So I thought I'd summarize:
The key was to run it in the debugger, let it say "uncaught
exception", then "back" once. This puts you in Printexc.catch's code.
Now do "previous", which backsteps across fn calls, until the
execution point (denoted by "<|a|>" or "<|b|>") is at the start of the
"with" block. Then "back" to get to the next throw point, "previous"
again to the top of the block, etc. You have to use "back" to get
from "with" to "raise" -- if you do "previous" it will go haywire; you
have to use "previous" to step across fn calls in the "with" block
because otherwise it takes forever.
But, I'd like to chime in on the side of advocating more support from
the debugger and/or compiler on getting backtraces. A start would be
a stand-alone fn to retrieve a backtrace in the code itself, and then
a convention about including backtraces in exception objects. (And oh
yeah, line/col instead of (or in addition to) char offsets would be
nice.)
-Scott
next prev parent reply other threads:[~2000-07-05 21:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-28 23:24 Scott McPeak
2000-06-30 13:08 ` Xavier Leroy
2000-07-01 12:57 ` Gerd Stolpmann
2000-07-03 15:05 ` Patrick M Doane
2000-07-03 21:43 ` Norman Ramsey
2000-07-06 3:05 ` Michael Hohn
2000-07-04 14:43 ` John Max Skaller
2000-07-04 18:19 ` Gerd Stolpmann
2000-07-05 22:13 ` Jean-Christophe Filliatre
2000-07-06 1:26 ` Max Skaller
2000-07-06 11:23 ` Daniel de Rauglaudre
2000-07-05 1:28 ` Scott McPeak [this message]
2000-07-05 21:29 Don Syme
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.21.0007041820480.393-100000@leetch.pasture.cow \
--to=smcpeak@cs.berkeley.edu \
--cc=Xavier.Leroy@inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox