From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q45CGM8i000504 for ; Sat, 5 May 2012 14:16:22 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AskBAHcZpU/ZSMDqgGdsb2JhbABFsnQiAQELCwsFFgMkggwBAQQBOj8FCwshJQ8BBA0bIROHfwEDBgmwEh8rDYlTiheHCASbYYVch24 X-IronPort-AV: E=Sophos;i="4.75,536,1330902000"; d="scan'208";a="156876714" Received: from fmmailgate03.web.de ([217.72.192.234]) by mail1-smtp-roc.national.inria.fr with ESMTP; 05 May 2012 14:16:16 +0200 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate03.web.de (Postfix) with ESMTP id 593F21B4516F7 for ; Sat, 5 May 2012 14:16:16 +0200 (CEST) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb002) with ESMTPA (Nemesis) id 0M9GYQ-1SJWN72JKQ-00ChoY; Sat, 05 May 2012 14:16:15 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1SQduJ-0004TC-1U; Sat, 05 May 2012 14:16:15 +0200 From: Goswin von Brederlow To: Joel Reymont Cc: caml-list@inria.fr References: Date: Sat, 05 May 2012 14:16:14 +0200 In-Reply-To: (Joel Reymont's message of "Fri, 4 May 2012 21:56:51 +0100") Message-ID: <87k40q6cxd.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Provags-ID: V02:K0:ECdqz5NYGqxfgghIF+vUXYTJnlh9QE8e5+F3jWVKtwr O0NxrqkxzObeRG8wIXv19rbBebbbPytBTwa1AFwo29z2eiT18h JLqn/+nXVcQrW2KZUNvfbqBv8SGf958QKZi0C96cuhCOQlAcVi ivpEilhC7jA+1rxWhkeCEX6CuIjHkjfBnOxvUPTQf6EjM37hpw IbikN/P8+Zd618WZkAhzw== Subject: Re: [Caml-list] debugging c wrappers Joel Reymont writes: > How do I look inside the values in C functions called from OCaml when > running in gdb? > > I swear there's a way but I don't remember it now. > > For example, I want to check if a particular value is a variant > constructor and whether its first argument is a closure. > > Help! First: Well, why shouldn't it be? If you specified your type that way on the ocaml side then it can not be anything else. That being said I think it would be easier to use printf debugging. You need to check wether the value is a pointer or an integer. If a pointer check the tag of the block it points to (number of constructor, string, double, ...) and the size (how many arguments) and then repeat for the first field in the block. If you need help on any of the checks you might want to look at the Obj module. It has all the checks you need on the ocaml side. Just look how they did it and then write yourself a C function to print the runtime type of a value (which, beware, is much reduced compared to the compile time type). MfG Goswin