[Spice-devel] Debugging helper functions

Marc-André Lureau marcandre.lureau at redhat.com
Mon Jun 12 13:00:28 UTC 2017


Hi

----- Original Message -----
> The topic of debugging popped up in the thread about logging. There is one
> thing I did not find in Spice, which I think would be helpful, namely
> debugging helper functions.
> 
> Here is an example of what I have in mind:
> https://github.com/c3d/XL-programming-language/blob/master/xlr/renderer.cpp#L828.
> These are functions that are designed primarily for use from within a
> debugger. The example linked above, from a compiler, do things like
> rendering a parse-tree pointer into the corresponding source code. The
> corresponding operation is quite complex (and occupies a good deal of file
> renderer.cpp), and is shared with “regular” operations like error messages.
> So the debug functions themselves are mostly wrappers intended to make it
> convenient and safe to use the facility from within a debugger (in the
> example, for example, there are a few pointer validity checks to avoid
> crashing the debug session if given a bad pointer)
> 
> In Spice, if I want to see what a given network packet contains, I would
> like, from gdb, to be able to do “p spice_debug_packet(ptr)” and see a
> nicely rendered output of how spice would decode that packet. Do we
> presently have such debug helper functions? If not, I’ll keep that in mind
> for future changes. If they already exist, or if you keep them in some
> private branch, would you be kind enough to share?
> 

It is not really necessary because the demarshaller/parser gives you a void * pointer that you cast to the expected type, then you can pretty-print the message content with gdb.

Eventually, spice-common codegen could learn to generate a pretty-print function, enabled in debug builds, you should get the same output.


More information about the Spice-devel mailing list