Auto-expanding objects when debuggingI am used to developing software using the C++ MFC framework and I especially like the fact that, when debugging, serialized info from objects can be seen in the debugging windows, namely the variables window and the watch window. That's cool as a mean to avoid to have to expand nodes by hand any time you are dealing with an object only to access a particular member. serialized object info in the debugging windows Unfortunately, if you try and use this mechanism for your own classes, then it won't work by default as the pic below exemplifies, you are forced to manually expand the node over and over again. serialized object info does not work by default with your own classes I haven't found any documentation over this, so I dived into the MFC classes in hope of finding more. I took a look to the CString class, which of course draws a natual attention on that matter, and was initially misled by the additional methods that it implements, namey ////////////////////////////////////////////////////////////////////////////// // Diagnostic support #ifdef _DEBUG friend CDumpContext& AFXAPI operator<<(CDumpContext& dc, const CString& string) { dc << string.m_pchData; return dc; } #endif with a After a while, I thought that regardless what that serialization implementation did, it was too awful to implement for my own classes, requiring an object to serialize itself is way too much implementation work! So I ended the experiments somewhat frustrated. It's only thanks to the re-reading of Debugging Windows Applications (Amazon) to learn more about advanced debugging techniques for another reason that I stump on that topic, given its tiny corner in the book. Surprisingly enough, classes able to serialize themselves "intelligently" in debugging windows are explicitely declared in a DevStudio-specific environment file, which is reloaded any time a debugging session starts. That file is Adding your own classes is a breaze, at least if the expected stuff to appear in the debugging windows is simple : number, string. There is no support for a callback or whatsoever that would, unlike I thought the previous MFC Dump stuff did (and I am wrong about it), allow to show complex stuff. I have a AString =text=<m_str,s>where the syntax is as follows :
The following table (excerpt from autoexp.dat) shows the available formatting options
Stéphane Rodriguez- November 12, 2003. |
Home Blog |