Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View a custom data type's values while debugging OCaml code

I have a list called list_ds of a custom-defined data structure in my OCaml source. I compiled the source for debugging and ran the debugger halting execution of my code at a breakpoint. Now I want to check particular element of the data structure within the list. If I use the print list_ds command in the debugger, I see [ abstr; abstr; abstr; abstr; <abstr>; ...] - list with word abstr. If I use "print list_ds.(0)" command in the debugger, it tells me that $1 : ds = abstr. But I really want to see the elements of the ds data structure at the first location in the list_ds. How can I do that?

like image 365
maths-help-seeker Avatar asked Sep 09 '26 03:09

maths-help-seeker


1 Answers

One option would be to install your own custom print function for the type. This is described in Section 16.8.8 of the OCaml Debugger Manual.

A downside of this approach is that it requires quite a bit of setup, especially since the output must be done through the Format module. You might be able to use the deriving project to speed this up. It can generate formatting functions automatically.

like image 52
Jeffrey Scofield Avatar answered Sep 11 '26 18:09

Jeffrey Scofield



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!