caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] debugging c wrappers
@ 2012-05-04 20:56 Joel Reymont
  2012-05-04 22:28 ` Wojciech Meyer
  2012-05-05 12:16 ` Goswin von Brederlow
  0 siblings, 2 replies; 3+ messages in thread
From: Joel Reymont @ 2012-05-04 20:56 UTC (permalink / raw)
  To: caml-list

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!

--------------------------------------------------------------------------
Working on AlgoKit, a new algorithmic trading platform using Rithmic R|API
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] debugging c wrappers
  2012-05-04 20:56 [Caml-list] debugging c wrappers Joel Reymont
@ 2012-05-04 22:28 ` Wojciech Meyer
  2012-05-05 12:16 ` Goswin von Brederlow
  1 sibling, 0 replies; 3+ messages in thread
From: Wojciech Meyer @ 2012-05-04 22:28 UTC (permalink / raw)
  To: Joel Reymont; +Cc: caml-list


Hello Joel,

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!

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] debugging c wrappers
  2012-05-04 20:56 [Caml-list] debugging c wrappers Joel Reymont
  2012-05-04 22:28 ` Wojciech Meyer
@ 2012-05-05 12:16 ` Goswin von Brederlow
  1 sibling, 0 replies; 3+ messages in thread
From: Goswin von Brederlow @ 2012-05-05 12:16 UTC (permalink / raw)
  To: Joel Reymont; +Cc: caml-list

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-05 12:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-04 20:56 [Caml-list] debugging c wrappers Joel Reymont
2012-05-04 22:28 ` Wojciech Meyer
2012-05-05 12:16 ` Goswin von Brederlow

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