[Qt-creator] Debugger display for array data
André Pönitz
andre.poenitz at mathematik.tu-chemnitz.de
Fri Nov 16 00:57:55 CET 2012
On Thu, Nov 15, 2012 at 05:27:49PM +0000, May, Ryan wrote:
> Hi,
Hi.
> I have a pointer to some unsigned char data that really represents 2D
> raster data. Is there some way (maybe using a custom Python dumper) to
> get this to display as an image in the debugger in Qt Creator?
Sure.
> I can dump the memory to a file using GDB and plot using Python, but it'd
> be much quicker to keep this within Creator.
>
> Thoughts?
Starting point are share/qtcreator/dumper/qttypes.py and
http://qt-project.org/doc/qtcreator-2.6/creator-debugging-helpers.html
Essentially you have to make up your mind how you want the result
to be presented, i.e. "in place" in the Locals and Expressions view,
or in a separate window (or be able to toggle between both), then
maybe look at the implementation of the dumpers for types that are
similar to yours.
There is currently no "in place" display for anything truly two dimensional,
but there are several "generic" ways to show data in separate windows,
strings in textedits, images, and processes.
A simple dumper that shows a structure like
struct Function
{
Function(QByteArray var, QByteArray f, double min, double max)
: var(var), f(f), min(min), max(max) {}
QByteArray var;
QByteArray f;
double min;
double max;
};
/*
Function func;
func.max = 10;
func.f = "cos(x)";
*/
through gnuplot could e.g. look like:
def qdump__Function(d, value):
min = value["min"]
max = value["max"]
var = extractCString(value["var"]["d"]["array"], 0)
f = extractCString(value["f"]["d"]["array"], 0)
input = "plot [%s=%f:%f] %s" % (var, min, max, f)
d.putValue("%s, %s=%f..%f" % (f, var, min, max))
d.putNumChild(0)
d.putDisplay(DisplayProcess, input, "gnuplot")
This could be added as e.g. "Additional Startup Commands" in
the GDB Settings, wrapped in form digestible to GDB:
python
def qdump__Function(d, value):
min = value["min"]
max = value["max"]
...
end
Andre'
More information about the Qt-creator
mailing list