Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: Alex Baretta <alex@barettadeit.com>
Cc: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] How do I get a stack trace in a running program?
Date: Mon, 10 Jan 2005 17:58:44 +0000	[thread overview]
Message-ID: <20050110175844.GA11261@furbychan.cocan.org> (raw)
In-Reply-To: <41E2B978.5090106@barettadeit.com>

On Mon, Jan 10, 2005 at 06:20:56PM +0100, Alex Baretta wrote:
> I need to print a backtrace for an exception which I catch in the 
> outmost loop of a long-running server, which the exception must not 
> kill. Printexc does not help here.

The following only applies in bytecode, when backtraces are enabled
using OCAMLRUNPARAM=b.

When an exception is raised the backtrace is stashed in a global
[per-thread?] buffer (byterun/backtrace.c:caml_stash_backtrace).  If
an exception is uncaught (byterun/printexc.c:
caml_fatal_uncaught_exception), then the backtrace is printed
(byterun/backtrace.c:caml_print_exception_backtrace) last thing before
the program exits.

Therefore it seems there is no way to trigger the printing of
backtraces except by modifying the sources to the OCaml compuiler.
Except that possibly you could write a C extension which calls
caml_print_exception_backtrace, if that symbol is visible, and it
might do the right thing, with luck!

It would be really nice if OCaml (a) recorded the function parameters
in backtraces, and (b) made available the backtraces programmatically.
Both Java and Perl do this, so there is no excuse for our favorite
language not to do it too!

Rich.

-- 


  reply	other threads:[~2005-01-10 17:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-10 17:20 Alex Baretta
2005-01-10 17:58 ` Richard Jones [this message]
2005-01-10 18:09   ` [Caml-list] " Alex Baretta
2005-01-11 10:30     ` Alex Baretta
     [not found]       ` <20050111103546.GA16257@furbychan.cocan.org>
2005-01-11 10:59         ` Alex Baretta
2005-01-10 19:04 HENRIKSON, JEFFREY

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=20050110175844.GA11261@furbychan.cocan.org \
    --to=rich@annexia.org \
    --cc=alex@barettadeit.com \
    --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