From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 83C487F616 for ; Thu, 23 Feb 2017 18:02:55 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=ivg@ieee.org; spf=Pass smtp.mailfrom=ivg@ieee.org; spf=None smtp.helo=postmaster@mail-it0-f52.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of ivg@ieee.org) identity=pra; client-ip=209.85.214.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of ivg@ieee.org designates 209.85.214.52 as permitted sender) identity=mailfrom; client-ip=209.85.214.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-it0-f52.google.com) identity=helo; client-ip=209.85.214.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="postmaster@mail-it0-f52.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AuQeQmheOQ96ojvGzhKdFi6SJlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxcqzYx7h7PlgxGXEQZ/co6odzbGH7ua5CSdRut6oizMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVr?= =?us-ascii?q?O+/7BpDdj9it1+C15pbffxhEiCCzbL52LBi6txjdu8oZjYZmJKs61wfErGZPd+?= =?us-ascii?q?lK321jOEidnwz75se+/Z5j9zpftvc8/MNeUqv0Yro1Q6VAADspL2466svrtQLe?= =?us-ascii?q?TQSU/XsTTn8WkhtTDAfb6hzxQ4r8vTH7tup53ymaINH2QLUpUjms86tnVBnlgz?= =?us-ascii?q?oBOjUk8m/Yl9ZwgbpZrxKvpxJxzY3abpyLOvViZa7SZ88WSHBbU8pNSyBMAIWx?= =?us-ascii?q?ZJYPAeobOuZYqpHwqVgQrRSkAwmnGeLhyjhUhn/xw601z+QhEQDa3Aw7AtkDt3?= =?us-ascii?q?XUrMv6NKoJUOC60rfHwivZY/NRwzf955HFfxY8qv+PRbJ9adTdxVUrGg/fjVid?= =?us-ascii?q?qZbpMy2I2ukCqWSW7/RsWOSygGA9sQ5xuCKgxsI0h4nJmI0VzlfE+D18wIkvJN?= =?us-ascii?q?24TFd3Yd+4EJdMri2aOYt7Tt04T2FnvyY6zbIGuZqlcyQQ1JsnwBvfZ+SGc4iO?= =?us-ascii?q?/B3jSP6cLSlkiH9hYr6yhBa//VK+xuHhWcS4ylZHojRdntnJrH8N1hjT6sadSv?= =?us-ascii?q?t6+0eswTeP1x7c6uxfIEA7i7TUJIA7zr43jJoTvlzPHjXql0XukK+WakIk9/C0?= =?us-ascii?q?5Ov9Z7XmooaQN4t1igHlLqQjgde/AOQ9MggWRWeX4+W81Lv5/U34WrpGlPM2kr?= =?us-ascii?q?OK+KzdcPgco+aDAgNa38539xG6STXgytUUknREKFNeZDqIiI/mP1zLKfH8S/y4?= =?us-ascii?q?hgL/vi1swqXnILTnSrrKMn/dm7fgYa01v09CxyIywN1SoZVOBedSc7rIRkbtuY?= =?us-ascii?q?mAXVcCOAuuzrO/BQ=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BMAADdFK9YhjTWVdFdGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFgEBAQMBAQEJAQEBhQ8Hg1SKCJFbkAiFLIINhiICgxwHPxgBAQEBAQE?= =?us-ascii?q?BAQEBARIBAQEICwsKHS+CMyCCHQEBAQMBIwQZAQE3AQQLCwsNKgICIhIBBQEcB?= =?us-ascii?q?hOICAOBUgMIBQiiBz+LG2iBbDqDCAEBBYQmDYN+AQEBAQEFAQEBAQEbCBKGOoR?= =?us-ascii?q?vglGFCYJfj1J/i0iSJJERkWEUHoEVH4E4YQg+FwWEICCCCyI1AYtFAQEB?= X-IPAS-Result: =?us-ascii?q?A0BMAADdFK9YhjTWVdFdGgEBAQECAQEBAQgBAQEBFgEBAQM?= =?us-ascii?q?BAQEJAQEBhQ8Hg1SKCJFbkAiFLIINhiICgxwHPxgBAQEBAQEBAQEBARIBAQEIC?= =?us-ascii?q?wsKHS+CMyCCHQEBAQMBIwQZAQE3AQQLCwsNKgICIhIBBQEcBhOICAOBUgMIBQi?= =?us-ascii?q?iBz+LG2iBbDqDCAEBBYQmDYN+AQEBAQEFAQEBAQEbCBKGOoRvglGFCYJfj1J/i?= =?us-ascii?q?0iSJJERkWEUHoEVH4E4YQg+FwWEICCCCyI1AYtFAQEB?= X-IronPort-AV: E=Sophos;i="5.35,198,1484002800"; d="scan'208,217";a="214512821" Received: from mail-it0-f52.google.com ([209.85.214.52]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 23 Feb 2017 18:02:54 +0100 Received: by mail-it0-f52.google.com with SMTP id 203so6673781ith.0 for ; Thu, 23 Feb 2017 09:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=mo/k9c9m7qbHPuSlj2yxYa5uAHXTKDnMl4cG6vciSz4=; b=ENokXJzpCqVElCsvAjDLwr6lsVYdzKOsfPDCedDvzbBM1FvZYdzZc51vSzZSVmnNxC i73f9NvIPS5CMGC7wFd85OlvYh2nda1qzmSFKak+cKlRajvpNHf2lMHM8XEG/wqqeRaT vgcBzUH98ywlklDz/JxN03FhEEYI3qm6LrrxfKY/Rx4djFeql1DBqx5T93VAlvJl1kGi xV/wAjLqV/lDxJNCzf7MNZsWcuQeyczLqr4TeKMOwN8ZHg+wxdvEscRkiwFHA8nEKbEj p98cZjFb+Q9hWFydKkLTZ9f1px+L0e5mJjVjhDBRRiBYeCo5KsR8vJywVal7KtEAdDLd PC4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=mo/k9c9m7qbHPuSlj2yxYa5uAHXTKDnMl4cG6vciSz4=; b=OOKLgReCE3pbMH/yXma8ruNV40u4No4gGsBrMEzz++P2TeujAcKEdwgUQc5M1BuA8w rt7U2tr+M+lRMHqMDkjuzatxKc/Dk+7aWXsyZu+Bpa6bffzldlTI76xD3xxvAD/6Z3c1 lTkZ+vhIeTXbRGMOK7okI1MYZ/zNReJg18DHbFak/kANrFsbQUwXdI0X8dBfHEM/cNBe lSKahdIT4avto11C4RuS4Cge0XSLBqmk6wgT5rTFUMpQSjbmQd88Xl41AnvKHCytsI1C II9ymaHFl/Xg813hym5qRRU0FDgXRjsBEo3RLx+6cXF0iIAuoPRzkjTr1ZMT3rmPTCC/ lEgA== X-Gm-Message-State: AMke39lLYRbulZoTjxAZC6hsxWs9f/9etJ0S60qNJs2XnSaNx3xlXfdr2hDlJTTCGJgNZS3xLqeluu7x9PWZozvo X-Received: by 10.107.7.78 with SMTP id 75mr34968115ioh.165.1487869369543; Thu, 23 Feb 2017 09:02:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.46.224 with HTTP; Thu, 23 Feb 2017 09:02:49 -0800 (PST) In-Reply-To: References: From: Ivan Gotovchits Date: Thu, 23 Feb 2017 12:02:49 -0500 Message-ID: To: Tom Ridge Cc: caml-list Content-Type: multipart/alternative; boundary=001a113f98d23ea393054935957d Subject: Re: [Caml-list] OCamldebug --001a113f98d23ea393054935957d Content-Type: text/plain; charset=UTF-8 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 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 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 = >>> >>> The problem is that I know that kra is a string. But ocamldebug only >>> shows . >>> >>> 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 >>> >> >> > --001a113f98d23ea393054935957d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
It matters=C2=A0whether in the signature of a module = that is produced by the functor, the type of the key is still the same as t= he type of the key parameter. If it is not, then debugger cannot know, whet= her the output type is a key or not. Probably, if you add a sharing constra= int between the functor parameter signature and the resulting module signat= ure the debugger with capture it. Especially, if this would be an erasing s= ignature (although it is not always possible), e.g.,

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

or

<= blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px">
module = Make(Key : T) : M with type key :=3D 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_p= rinter` command). In this printer you may apply a functor,
and si= nce functors=C2=A0are applicative in OCaml the debugger might be clever eno= ugh to pick this printer. It is not guaranteed, though, as the debugger is = using lots of heuristics, and sometimes, they do fail.=C2=A0

=

Best wishes,
Ivan

<= div>

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 t= ype "Key_value_types.key" is equal to string (in this particular = case). However, this type is produced via module application, and so I cann= ot construct a printer that can print values of type "Key_value_types.= key" before program execution (which seems to be required for #install= _printer).=C2=A0

Somehow I seem to want to tell ocamldeb= ug that Key_value_types.key is in fact equal to string. Or alternatively co= erce 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=C2=A0-> unit`, where `t`= is a name of your type.=C2=A0

On Thu, Feb 23, 2017 at 11:24 AM, Tom Rid= ge <tom.j.ridge+list@googlemail.com> wrot= e:
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&q= uot; stepping.

However, sometimes I want to see th= e value of a particular variable. I can use the "p" (print) comma= nd as:

(ocd) p kra
kra: Key_value_t= ypes.key =3D <abstr>

The problem is th= at I know that kra is a string. But ocamldebug only shows <abstr>.=C2= =A0

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

Any ideas?

T



--001a113f98d23ea393054935957d--