[m-users.] Debugging with foreign types

Julien Fischer jfischer at opturion.com
Mon May 25 10:17:32 AEST 2015


On Sat, 23 May 2015, Mark Brown wrote:

> On Sat, May 23, 2015 at 2:15 AM, Zoltan Somogyi
> <zoltan.somogyi at runbox.com> wrote:
>> On Fri, 22 May 2015 12:26:44 +0100, matthias.guedemann at googlemail.com (Matthias G├╝demann) wrote:
>>> when using mdb on code that uses foreign types, the repective values are
>>> always displayed as '<<foreign>>'.
>>> Is it possible to get a string representation for foreign types for
>>> debugging?
>> How would you expect to specify the conversion from the foreign type
>> to string?
> It would be sufficient to print the word as a hex value, as is done
> with c_pointer.
> Although it doesn't tell you the state of the foreign type, you have
> its identity and you can observe all the Mercury values going into and
> coming out of the foreign calls. So you should be able to tell whether
> the bug is on the Mercury side or the foreign side.

I think printing a hex value would be a useful thing to do.  I've just
had a grep through the various bodies of Mercury code I have access to.
Based on that sample, (1) pretty much all C foreign types** are pointers,
(2) those that aren't are usually integers -- in fact many of those
integers are actually MR_Word, so they're really pointers too.

Instead of printing '<<foreign>>' in the debugger we should print, for
example, '<<foreign(0x000023ab)>>'.


More information about the users mailing list