caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Joel Reymont <joelr1@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] debugging c wrappers
Date: Sat, 05 May 2012 14:16:14 +0200	[thread overview]
Message-ID: <87k40q6cxd.fsf@frosties.localnet> (raw)
In-Reply-To: <CAOQwdX2tiD3U0urR_x61RLUVwAbiFqRV9dbEEabM2nKWFtA0gw@mail.gmail.com> (Joel Reymont's message of "Fri, 4 May 2012 21:56:51 +0100")

Joel Reymont <joelr1@gmail.com> 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

      parent reply	other threads:[~2012-05-05 12:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-04 20:56 Joel Reymont
2012-05-04 22:28 ` Wojciech Meyer
2012-05-05 12:16 ` Goswin von Brederlow [this message]

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=87k40q6cxd.fsf@frosties.localnet \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    --cc=joelr1@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).