Yemelyanenko Fyodor fyodor_e at hotmail.com
Thu Oct 26 02:24:33 UTC 2017


During work on bug https://bugs.documentfoundation.org/show_bug.cgi?id=108124 I found dumpAsXml methods in different classes (i.e. SwNode, SwNodes, SwDoc, SwPaM, SwPosition, etc.)
I've created separate function which creates XML writer, calls dumpAsXml from some class and outputs result to debugger output. This is useful, as I can call such function from debugger (using .call in WinDbg) and immediately get class contents as xml (i.e SwNodes as xml). This function accepts only one parameter - pointer to class. Such pointer can be found in locals window in debugger. So dumping any class to debug output become easy and quick task, without rewriting and recompiling code.

The code itself is at the end of this message (this is draft code, written quickly).

I can make this code better (add cross-platform'ness as it depends on OutputDebugStringA and I'm not sure that it exists in any other OS than Windows), and submit as patch to master. Also I can add several lines here on how to use my function to get xml dump during debugging https://wiki.documentfoundation.org/Development/How_to_debug#Debugging_options

If all this makes sense and can be useful not only for me?

---------------------------- Dumper function code ----------------------------------------

 template <typename ClassWithDumpAsXml>
void DumpXmlToDebug(ClassWithDumpAsXml& tDumpedToDebug)

xmlDocPtr doc;
xmlChar *xmlbuff;
int buffersize;

xmlTextWriterPtr xmlWrt = xmlNewTextWriterDoc(&doc, 0);

if (xmlTextWriterStartDocument(xmlWrt, NULL, "ISO-8859-1", NULL) < 0)
OutputDebugStringA("\n\nerror in xmlTextWriterStartDocument \n\n");


if (xmlTextWriterEndDocument(xmlWrt) < 0)
OutputDebugStringA("\n\nerror in xmlTextWriterEndDocument \n\n");

xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);

std::stringstream dbg;
dbg << "\n !!!!!!-------- !!!!!!!\n !! Called for " << typeid(ClassWithDumpAsXml).name() << " !!\n " << (char *)xmlbuff << "\n\n\n";



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20171026/ff3dc64b/attachment.html>

More information about the LibreOffice mailing list