caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] OCamldebug
@ 2017-02-23 16:24 Tom Ridge
  2017-02-23 16:31 ` Ivan Gotovchits
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Ridge @ 2017-02-23 16:24 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

Dear All,

I am debugging some code. For various reasons I have started to use
ocamldebug rather than printf.

I should say that ocamldebug is excellent. Really excellent. Especially the
"backwards" stepping.

However, sometimes I want to see the value of a particular variable. I can
use the "p" (print) command as:

(ocd) p kra
kra: Key_value_types.key = <abstr>

The problem is that I know that kra is a string. But ocamldebug only shows
<abstr>.

Admittedly the code is functorized. But I have a feeling I should be able
to tweak something to get ocamldebug to print the value of kra.

Any ideas?

T

[-- Attachment #2: Type: text/html, Size: 873 bytes --]

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

* Re: [Caml-list] OCamldebug
  2017-02-23 16:24 [Caml-list] OCamldebug Tom Ridge
@ 2017-02-23 16:31 ` Ivan Gotovchits
  2017-02-23 16:49   ` Tom Ridge
  0 siblings, 1 reply; 9+ messages in thread
From: Ivan Gotovchits @ 2017-02-23 16:31 UTC (permalink / raw)
  To: Tom Ridge; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

Probably it is an abstract type, that is represented as string. In any case
you can use the `#install_printer` directive to enable printing any type.
The argument
is a function of type `t -> Format.formatter -> unit`, where `t` is a name
of your type.

On Thu, Feb 23, 2017 at 11:24 AM, Tom Ridge <tom.j.ridge+list@googlemail.com
> wrote:

> Dear All,
>
> I am debugging some code. For various reasons I have started to use
> ocamldebug rather than printf.
>
> I should say that ocamldebug is excellent. Really excellent. Especially
> the "backwards" stepping.
>
> However, sometimes I want to see the value of a particular variable. I can
> use the "p" (print) command as:
>
> (ocd) p kra
> kra: Key_value_types.key = <abstr>
>
> The problem is that I know that kra is a string. But ocamldebug only shows
> <abstr>.
>
> Admittedly the code is functorized. But I have a feeling I should be able
> to tweak something to get ocamldebug to print the value of kra.
>
> Any ideas?
>
> T
>

[-- Attachment #2: Type: text/html, Size: 1594 bytes --]

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

* Re: [Caml-list] OCamldebug
  2017-02-23 16:31 ` Ivan Gotovchits
@ 2017-02-23 16:49   ` Tom Ridge
  2017-02-23 17:02     ` Ivan Gotovchits
  2017-02-24  8:41     ` Sébastien Hinderer
  0 siblings, 2 replies; 9+ messages in thread
From: Tom Ridge @ 2017-02-23 16:49 UTC (permalink / raw)
  To: Ivan Gotovchits; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]

Regarding `#install_printer`, can you explain more? The type
"Key_value_types.key" is equal to string (in this particular case).
However, this type is produced via module application, and so I cannot
construct a printer that can print values of type "Key_value_types.key"
before program execution (which seems to be required for #install_printer).

Somehow I seem to want to tell ocamldebug that Key_value_types.key is in
fact equal to string. Or alternatively coerce kra (using Obj.magic) to
string type so that it can easily be printed by ocamldebug?



On 23 February 2017 at 16:31, Ivan Gotovchits <ivg@ieee.org> wrote:

> Probably it is an abstract type, that is represented as string. In any
> case you can use the `#install_printer` directive to enable printing any
> type. The argument
> is a function of type `t -> Format.formatter -> unit`, where `t` is a name
> of your type.
>
> On Thu, Feb 23, 2017 at 11:24 AM, Tom Ridge <tom.j.ridge+list@googlemail.
> com> wrote:
>
>> Dear All,
>>
>> I am debugging some code. For various reasons I have started to use
>> ocamldebug rather than printf.
>>
>> I should say that ocamldebug is excellent. Really excellent. Especially
>> the "backwards" stepping.
>>
>> However, sometimes I want to see the value of a particular variable. I
>> can use the "p" (print) command as:
>>
>> (ocd) p kra
>> kra: Key_value_types.key = <abstr>
>>
>> The problem is that I know that kra is a string. But ocamldebug only
>> shows <abstr>.
>>
>> Admittedly the code is functorized. But I have a feeling I should be able
>> to tweak something to get ocamldebug to print the value of kra.
>>
>> Any ideas?
>>
>> T
>>
>
>

[-- Attachment #2: Type: text/html, Size: 2654 bytes --]

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

* Re: [Caml-list] OCamldebug
  2017-02-23 16:49   ` Tom Ridge
@ 2017-02-23 17:02     ` Ivan Gotovchits
  2017-02-24  9:16       ` Tom Ridge
  2017-02-24  8:41     ` Sébastien Hinderer
  1 sibling, 1 reply; 9+ messages in thread
From: Ivan Gotovchits @ 2017-02-23 17:02 UTC (permalink / raw)
  To: Tom Ridge; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2833 bytes --]

It matters whether in the signature of a module that is produced by the
functor, the type of the key is still the same as the type of the key
parameter. If it is not, then debugger cannot know, whether the output type
is a key or not. Probably, if you add a sharing constraint between the
functor parameter signature and the resulting module signature the debugger
with capture it. Especially, if this would be an erasing signature
(although it is not always possible), e.g.,

module M = sig type key type t end
module Make(Key : T) : M with type key = Key.t


or

module Make(Key : T) : M with type key := Key.t



If these approaches do not work for you, then you can define a printer
yourself in a separate module (that is loaded with `load_printer` command).
In this printer you may apply a functor,
and since functors are applicative in OCaml the debugger might be clever
enough to pick this printer. It is not guaranteed, though, as the debugger
is using lots of heuristics, and sometimes, they do fail.


Best wishes,
Ivan



On Thu, Feb 23, 2017 at 11:49 AM, Tom Ridge <tom.j.ridge+list@googlemail.com
> wrote:

> Regarding `#install_printer`, can you explain more? The type
> "Key_value_types.key" is equal to string (in this particular case).
> However, this type is produced via module application, and so I cannot
> construct a printer that can print values of type "Key_value_types.key"
> before program execution (which seems to be required for #install_printer).
>
> Somehow I seem to want to tell ocamldebug that Key_value_types.key is in
> fact equal to string. Or alternatively coerce kra (using Obj.magic) to
> string type so that it can easily be printed by ocamldebug?
>
>
>
> On 23 February 2017 at 16:31, Ivan Gotovchits <ivg@ieee.org> wrote:
>
>> Probably it is an abstract type, that is represented as string. In any
>> case you can use the `#install_printer` directive to enable printing any
>> type. The argument
>> is a function of type `t -> Format.formatter -> unit`, where `t` is a
>> name of your type.
>>
>> On Thu, Feb 23, 2017 at 11:24 AM, Tom Ridge <
>> tom.j.ridge+list@googlemail.com> wrote:
>>
>>> Dear All,
>>>
>>> I am debugging some code. For various reasons I have started to use
>>> ocamldebug rather than printf.
>>>
>>> I should say that ocamldebug is excellent. Really excellent. Especially
>>> the "backwards" stepping.
>>>
>>> However, sometimes I want to see the value of a particular variable. I
>>> can use the "p" (print) command as:
>>>
>>> (ocd) p kra
>>> kra: Key_value_types.key = <abstr>
>>>
>>> The problem is that I know that kra is a string. But ocamldebug only
>>> shows <abstr>.
>>>
>>> Admittedly the code is functorized. But I have a feeling I should be
>>> able to tweak something to get ocamldebug to print the value of kra.
>>>
>>> Any ideas?
>>>
>>> T
>>>
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 4562 bytes --]

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

* Re: [Caml-list] OCamldebug
  2017-02-23 16:49   ` Tom Ridge
  2017-02-23 17:02     ` Ivan Gotovchits
@ 2017-02-24  8:41     ` Sébastien Hinderer
  2017-02-24  9:14       ` Tom Ridge
  1 sibling, 1 reply; 9+ messages in thread
From: Sébastien Hinderer @ 2017-02-24  8:41 UTC (permalink / raw)
  To: caml-list

Tom Ridge (2017/02/23 16:49 +0000):
> Regarding `#install_printer`, can you explain more? The type
> "Key_value_types.key" is equal to string (in this particular case).
> However, this type is produced via module application, and so I cannot
> construct a printer that can print values of type "Key_value_types.key"
> before program execution (which seems to be required for
> #install_printer).

Can't you add the pretty-printer to the module, actually?

Sébastien.

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

* Re: [Caml-list] OCamldebug
  2017-02-24  8:41     ` Sébastien Hinderer
@ 2017-02-24  9:14       ` Tom Ridge
  0 siblings, 0 replies; 9+ messages in thread
From: Tom Ridge @ 2017-02-24  9:14 UTC (permalink / raw)
  To: Sébastien Hinderer, caml-list

[-- Attachment #1: Type: text/plain, Size: 1147 bytes --]

Not sure. There is this clause in the ocamldebug page:

"For technical reasons, the debugger cannot call printing functions that
reside in the program being debugged. The code for the printing functions
must therefore be loaded explicitly in the debugger."

Also, I'm only trying to view a string...




On 24 February 2017 at 08:41, Sébastien Hinderer <
Sebastien.Hinderer@inria.fr> wrote:

> Tom Ridge (2017/02/23 16:49 +0000):
> > Regarding `#install_printer`, can you explain more? The type
> > "Key_value_types.key" is equal to string (in this particular case).
> > However, this type is produced via module application, and so I cannot
> > construct a printer that can print values of type "Key_value_types.key"
> > before program execution (which seems to be required for
> > #install_printer).
>
> Can't you add the pretty-printer to the module, actually?
>
> Sébastien.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 1982 bytes --]

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

* Re: [Caml-list] OCamldebug
  2017-02-23 17:02     ` Ivan Gotovchits
@ 2017-02-24  9:16       ` Tom Ridge
  2017-02-24  9:20         ` Tom Ridge
  2017-02-24  9:28         ` Sébastien Hinderer
  0 siblings, 2 replies; 9+ messages in thread
From: Tom Ridge @ 2017-02-24  9:16 UTC (permalink / raw)
  To: Ivan Gotovchits; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 3233 bytes --]

My functors never hide anything, and always include the input module as a
submodule of the output module. So I hope that type equalities are as
maximally visible as they could be. But ocamldebug doesn't seem to get it :(



On 23 February 2017 at 17:02, Ivan Gotovchits <ivg@ieee.org> wrote:

> It matters whether in the signature of a module that is produced by the
> functor, the type of the key is still the same as the type of the key
> parameter. If it is not, then debugger cannot know, whether the output type
> is a key or not. Probably, if you add a sharing constraint between the
> functor parameter signature and the resulting module signature the debugger
> with capture it. Especially, if this would be an erasing signature
> (although it is not always possible), e.g.,
>
> module M = sig type key type t end
> module Make(Key : T) : M with type key = Key.t
>
>
> or
>
> module Make(Key : T) : M with type key := Key.t
>
>
>
> If these approaches do not work for you, then you can define a printer
> yourself in a separate module (that is loaded with `load_printer` command).
> In this printer you may apply a functor,
> and since functors are applicative in OCaml the debugger might be clever
> enough to pick this printer. It is not guaranteed, though, as the debugger
> is using lots of heuristics, and sometimes, they do fail.
>
>
> Best wishes,
> Ivan
>
>
>
> On Thu, Feb 23, 2017 at 11:49 AM, Tom Ridge <tom.j.ridge+list@googlemail.
> com> wrote:
>
>> Regarding `#install_printer`, can you explain more? The type
>> "Key_value_types.key" is equal to string (in this particular case).
>> However, this type is produced via module application, and so I cannot
>> construct a printer that can print values of type "Key_value_types.key"
>> before program execution (which seems to be required for #install_printer).
>>
>> Somehow I seem to want to tell ocamldebug that Key_value_types.key is in
>> fact equal to string. Or alternatively coerce kra (using Obj.magic) to
>> string type so that it can easily be printed by ocamldebug?
>>
>>
>>
>> On 23 February 2017 at 16:31, Ivan Gotovchits <ivg@ieee.org> wrote:
>>
>>> Probably it is an abstract type, that is represented as string. In any
>>> case you can use the `#install_printer` directive to enable printing any
>>> type. The argument
>>> is a function of type `t -> Format.formatter -> unit`, where `t` is a
>>> name of your type.
>>>
>>> On Thu, Feb 23, 2017 at 11:24 AM, Tom Ridge <
>>> tom.j.ridge+list@googlemail.com> wrote:
>>>
>>>> Dear All,
>>>>
>>>> I am debugging some code. For various reasons I have started to use
>>>> ocamldebug rather than printf.
>>>>
>>>> I should say that ocamldebug is excellent. Really excellent. Especially
>>>> the "backwards" stepping.
>>>>
>>>> However, sometimes I want to see the value of a particular variable. I
>>>> can use the "p" (print) command as:
>>>>
>>>> (ocd) p kra
>>>> kra: Key_value_types.key = <abstr>
>>>>
>>>> The problem is that I know that kra is a string. But ocamldebug only
>>>> shows <abstr>.
>>>>
>>>> Admittedly the code is functorized. But I have a feeling I should be
>>>> able to tweak something to get ocamldebug to print the value of kra.
>>>>
>>>> Any ideas?
>>>>
>>>> T
>>>>
>>>
>>>
>>
>

[-- Attachment #2: Type: text/html, Size: 5332 bytes --]

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

* Re: [Caml-list] OCamldebug
  2017-02-24  9:16       ` Tom Ridge
@ 2017-02-24  9:20         ` Tom Ridge
  2017-02-24  9:28         ` Sébastien Hinderer
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Ridge @ 2017-02-24  9:20 UTC (permalink / raw)
  To: Ivan Gotovchits; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 3540 bytes --]

I take it back! Some of my code goes via external functors which indeed
hide various type equalities.

Thanks for your help.

On 24 February 2017 at 09:16, Tom Ridge <tom.j.ridge+list@googlemail.com>
wrote:

> My functors never hide anything, and always include the input module as a
> submodule of the output module. So I hope that type equalities are as
> maximally visible as they could be. But ocamldebug doesn't seem to get it :(
>
>
>
> On 23 February 2017 at 17:02, Ivan Gotovchits <ivg@ieee.org> wrote:
>
>> It matters whether in the signature of a module that is produced by the
>> functor, the type of the key is still the same as the type of the key
>> parameter. If it is not, then debugger cannot know, whether the output type
>> is a key or not. Probably, if you add a sharing constraint between the
>> functor parameter signature and the resulting module signature the debugger
>> with capture it. Especially, if this would be an erasing signature
>> (although it is not always possible), e.g.,
>>
>> module M = sig type key type t end
>> module Make(Key : T) : M with type key = Key.t
>>
>>
>> or
>>
>> module Make(Key : T) : M with type key := Key.t
>>
>>
>>
>> If these approaches do not work for you, then you can define a printer
>> yourself in a separate module (that is loaded with `load_printer` command).
>> In this printer you may apply a functor,
>> and since functors are applicative in OCaml the debugger might be clever
>> enough to pick this printer. It is not guaranteed, though, as the debugger
>> is using lots of heuristics, and sometimes, they do fail.
>>
>>
>> Best wishes,
>> Ivan
>>
>>
>>
>> On Thu, Feb 23, 2017 at 11:49 AM, Tom Ridge <
>> tom.j.ridge+list@googlemail.com> wrote:
>>
>>> Regarding `#install_printer`, can you explain more? The type
>>> "Key_value_types.key" is equal to string (in this particular case).
>>> However, this type is produced via module application, and so I cannot
>>> construct a printer that can print values of type "Key_value_types.key"
>>> before program execution (which seems to be required for #install_printer).
>>>
>>> Somehow I seem to want to tell ocamldebug that Key_value_types.key is in
>>> fact equal to string. Or alternatively coerce kra (using Obj.magic) to
>>> string type so that it can easily be printed by ocamldebug?
>>>
>>>
>>>
>>> On 23 February 2017 at 16:31, Ivan Gotovchits <ivg@ieee.org> wrote:
>>>
>>>> Probably it is an abstract type, that is represented as string. In any
>>>> case you can use the `#install_printer` directive to enable printing any
>>>> type. The argument
>>>> is a function of type `t -> Format.formatter -> unit`, where `t` is a
>>>> name of your type.
>>>>
>>>> On Thu, Feb 23, 2017 at 11:24 AM, Tom Ridge <
>>>> tom.j.ridge+list@googlemail.com> wrote:
>>>>
>>>>> Dear All,
>>>>>
>>>>> I am debugging some code. For various reasons I have started to use
>>>>> ocamldebug rather than printf.
>>>>>
>>>>> I should say that ocamldebug is excellent. Really excellent.
>>>>> Especially the "backwards" stepping.
>>>>>
>>>>> However, sometimes I want to see the value of a particular variable. I
>>>>> can use the "p" (print) command as:
>>>>>
>>>>> (ocd) p kra
>>>>> kra: Key_value_types.key = <abstr>
>>>>>
>>>>> The problem is that I know that kra is a string. But ocamldebug only
>>>>> shows <abstr>.
>>>>>
>>>>> Admittedly the code is functorized. But I have a feeling I should be
>>>>> able to tweak something to get ocamldebug to print the value of kra.
>>>>>
>>>>> Any ideas?
>>>>>
>>>>> T
>>>>>
>>>>
>>>>
>>>
>>
>

[-- Attachment #2: Type: text/html, Size: 6065 bytes --]

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

* Re: [Caml-list] OCamldebug
  2017-02-24  9:16       ` Tom Ridge
  2017-02-24  9:20         ` Tom Ridge
@ 2017-02-24  9:28         ` Sébastien Hinderer
  1 sibling, 0 replies; 9+ messages in thread
From: Sébastien Hinderer @ 2017-02-24  9:28 UTC (permalink / raw)
  To: caml-list

Tom Ridge (2017/02/24 09:16 +0000):
> My functors never hide anything, and always include the input module as a
> submodule of the output module. So I hope that type equalities are as
> maximally visible as they could be. But ocamldebug doesn't seem to get
> it :(

May that be worth a feature request on Mantis?

Sébastien.

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

end of thread, other threads:[~2017-02-24  9:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 16:24 [Caml-list] OCamldebug Tom Ridge
2017-02-23 16:31 ` Ivan Gotovchits
2017-02-23 16:49   ` Tom Ridge
2017-02-23 17:02     ` Ivan Gotovchits
2017-02-24  9:16       ` Tom Ridge
2017-02-24  9:20         ` Tom Ridge
2017-02-24  9:28         ` Sébastien Hinderer
2017-02-24  8:41     ` Sébastien Hinderer
2017-02-24  9:14       ` Tom Ridge

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