Joel Reymont <joe...@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

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to