> I'm not especially familiar with debugging in VS, but I would have thought 
> that in a debug build, VS has enough information about the data types of the 
> pimpl classes to display them in the debugger.

Only if you build from the source. If you install the prebuilt libraries then 
it has no idea what the private class implementation is because it doesn't have 
the header files.

TOM ISAACSON | SENIOR SOFTWARE DEVELOPER | NAVICO ASIA PACIFIC



-----Original Message-----
From: Robert Knight [mailto:robertkni...@gmail.com] 
Sent: Sunday, 16 September 2012 10:57 p.m.
To: Tom Isaacson
Cc: development@qt-project.org
Subject: Re: [Development] Extending Visual Studio's display of Qt classes

>  It's intended for when the source code of the implementation isn't available 
> so internal variables and function names can be completely hidden.

That is not the motivation at all in Qt's case.  The reasons for it are:

- Binary compatibility between minor Qt versions.  Adding, removing or changing 
fields in the pimpl class does not alter the layout or size of the public class.
- It permits sharing of data between instances of the public class (aka. copy 
on write.  See QSharedData).
- During development, the amount of code that is recompiled when changing 
private implementation details in the pimpl class is reduced.

I'm not especially familiar with debugging in VS, but I would have thought that 
in a debug build, VS has enough information about the data types of the pimpl 
classes to display them in the debugger.

Regards,
Rob.

On 16 September 2012 11:08, Tom Isaacson <tom.isaac...@navico.com> wrote:
> I've been working on some networking code recently and I got very frustrated 
> with not being able to see the IP and MAC addresses in QHostAddress and 
> QNetworkInterface whilst debugging in Visual Studio. After a bit of 
> experimentation I was able to add viewers for these classes to autoexp.dat 
> and I've posted these below. But the problem I had is that these classes 
> follow the Pimpl Idiom, so it's impossible for Visual Studio to be able to 
> see the members of the classes in order to display the values. I had to look 
> into the implementation of the private part of the classes then use byte 
> shuffling in autoexp.dat to display them. This means that if the layout of 
> the classes ever changes this method will display the wrong data, which is 
> why I'm not sure if it's a good idea to add this to the Visual Studio Add-In 
> installer. However, if anyone wants to do this then go ahead.
>
> I understand why the Pimpl Idiom is being used here, but I'm wondering if 
> it's actually necessary. It's intended for when the source code of the 
> implementation isn't available so internal variables and function names can 
> be completely hidden. But in the case of Qt, where the source code is 
> available and can even be used to build your own binaries, it seems 
> excessive. It also means that useful displays of debugging data aren't really 
> possible and you have to resort to what I've done below.
>
> Can I suggest that going forward the Pimpl Idiom is dropped and we go back to 
> just using private member variables and functions to prevent them being 
> called from outside the class? Or is there some alternative that would allow 
> VS to see the layout it needs?
>
> QHostAddress|*::QHostAddress{
>     preview
>     (
>         #(
>             #if (*((quint32 *)$e.d.d) != 0) (
>                 #("IPv4=", [*(((quint8 *)$e.d.d) + 3), u],
>                 ".", [*(((quint8 *)$e.d.d) + 2), u],
>                 ".", [*(((quint8 *)$e.d.d) + 1), u],
>                 ".", [*(((quint8 *)$e.d.d) + 0), u])
>             ) #elif ((*(((quint32 *)$e.d.d) + 1)) + (*(((quint32 *)$e.d.d) + 
> 2)) + (*(((quint32 *)$e.d.d) + 3)) + (*(((quint32 *)$e.d.d) + 4)) != 0) (
>                 #("IPv6=",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x04) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x05))), x],
>                 ".",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x06) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x07))), x],
>                 ".",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x08) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x09))), x],
>                 ".",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x0A) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x0B))), x],
>                 ".",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x0C) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x0D))), x],
>                 ".",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x0E) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x0F))), x],
>                 ".",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x10) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x11))), x],
>                 ".",
>                 [(quint16)((*(((quint8 *)$e.d.d) + 0x12) << 0x8) | 
> (*(((quint8 *)$e.d.d) + 0x13))), x])
>             )
>         )
>     )
>     children
>     (
>         #(
>             [d]: [$c.d.d, x]
>         )
>     )
> }
>
>
>
> QNetworkInterface|*::QNetworkInterface{
>     preview
>     (
>         #(
>             [(QString *)(((quint32 *)$e.d.d) + 0x4)]
>         )
>     )
>     children
>     (
>         #(
>             [d]: [$c.d.d, x],
>             [QSharedData]: [*(((quint32 *)$c.d.d) + 0x0), u],
>             [index]: [*(((quint32 *)$c.d.d) + 0x1), u],
>             [flags.i]: [*(((quint32 *)$c.d.d) + 0x2), u],
>             [name]: [(QString *)(((quint32 *)$c.d.d) + 0x3)],
>             [friendlyName]: [(QString *)(((quint32 *)$c.d.d) + 0x4)],
>             [hardwareAddress]: [(QString *)(((quint32 *)$c.d.d) + 0x5)]
>         )
>     )
> }
>
> TOM ISAACSON | SENIOR SOFTWARE DEVELOPER | NAVICO ASIA PACIFIC
>
>
>
> _______________________________________________
> Development mailing list
> Development@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development


_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to