From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id B3FF5BBC1 for ; Thu, 1 May 2008 09:46:12 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmIAAJ8RGUjUGyodmmdsb2JhbACRXAEBAQEBCAUIBxEDmlo X-IronPort-AV: E=Sophos;i="4.27,421,1204498800"; d="scan'208";a="11719241" Received: from smtp3-g19.free.fr ([212.27.42.29]) by mail1-smtp-roc.national.inria.fr with ESMTP; 01 May 2008 09:46:12 +0200 Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 3EFBD17B56D; Thu, 1 May 2008 09:46:12 +0200 (CEST) Received: from [192.168.0.3] (rke75-3-82-229-183-156.fbx.proxad.net [82.229.183.156]) by smtp3-g19.free.fr (Postfix) with ESMTP id 10EB217B56C; Thu, 1 May 2008 09:46:11 +0200 (CEST) Message-ID: <48197541.8010809@frisch.fr> Date: Thu, 01 May 2008 09:46:09 +0200 From: Alain Frisch User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Raj Bandyopadhyay Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Indentifying OCaml exceptions from C References: <481895A4.9080407@rice.edu> In-Reply-To: <481895A4.9080407@rice.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 ocaml:01 ocaml:01 callbacks:01 runtime:01 exn:01 exn:01 wrote:01 exception:01 exception:01 caml-list:01 constructor:01 exceptions:01 exceptions:01 Raj Bandyopadhyay wrote: > Hi ocaml folks > > I have a C program that makes callbacks to the OCaml runtime via the > callback_exn() mechanism. Unfortunately, the OCaml code is raising some > exception. It seems to be one of the built-in OCaml exceptions, and not > something that I have defined in my OCaml code. > > I would like to know what is the easiest/correct way to identify the > exact OCaml exception being raised, so I can debug this program. You can use the macros Is_exception_result and Extract_exception (defined in callback.h) to check whether the result of callback_exn is an exception and to retrieve the exception value in that case. The first field of this value points to a block with one field pointing to the string representing the exception's constructor name. The other fields of the exception value are the exception's arguments. -- Alain