Question

I've got a PyString* object that I would like to see the contents of. Is there any way to see the text of the PyString using Qt Creator's debugger?

PyObject *import_str = PyString_InternFromString("__import__");

If it makes a difference, Qt Creator is a front end to GDB.

Was it helpful?

Solution

You can write debugging info to be displayed in QtCreator for any class using Python with the latest QtCreator. It's actually quite simple. This is thanks to gdb 7 that added support for Python in addition to C++.

You can see the ones that ship with QtCreator in /usr/share/qtcreator/gdbmacros.
For more info you can check QtCreator documentation and this blog post from Qt Labs.

OTHER TIPS

I doubt that Qt Creator can display the contents of the string like it does with QString, etc. This is because PyObject is a custom class that Qt Creator/gdbv does not know how to handle.

For instance: QString is a custom class as well, but Qt Creator loads some special commands/modules/whatever which allows for direct display of string values in the debugger.

I never did that myself, but I guess that there are ways to make gdb pass the correct information to Qt Creator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top