Re: [Caml-list] debugging c wrappers

2012-05-05 Thread Goswin von Brederlow
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

-- 
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



Re: [Caml-list] debugging c wrappers

2012-05-04 Thread Wojciech Meyer

Hello Joel,

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!

In general case this is not currently possible, but I think there is
some work going on by OCamlPro for better gdb integration [1], if you
are talking about showing precise types - as it needs some extra debug
information.

To see if it's a variant constructor, array, string or closure etc. you
can look at the tag however.

There is a Python script by Ygrek [2] that probably to some extent does what
you want.

- Wojciech

[1] http://caml.inria.fr/mantis/view.php?id=5487
[2] http://ygrek.org.ua/p/code/mlvalues.py.html

-- 
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