Hi,

I've been dabbling with python debugging helpers, trying to write some for
my own custom classes.
The documentation is a bit raw, it is not always easy to find how to do
simple things.
With lots of trial and error I've had some limited success.  I've looked at
gdbmacros.py as reference.

Example of my current problem:

In a C++ source function I have local MyClass instance, and another comes in
as a reference parameter

I can see the local value of MyClass instance with:

def qdump__MyClass(d, item):
    data = call(item.value, 'chars()')
    s = data.string('utf-8')  # Tells gdb that pointer is 'string like', in
encoding utf-8
    d.putValue(s)  # it would be nice to have a helper to quote this...
gdbmacros.py way looks cryptic...
    d.putNumChild(0)

But the reference type MyClass & does not show up.
I tried the following hack:

def qdump__MyClass(d, item):
    if item.value.type.code == gdb.TYPE_CODE_REF:
        ref = item.value.dereference()
        data = call(ref, 'chars()')
    else:
        data = call(item.value, 'chars()')
    s = data.string('utf-8')  # Tells gdb that pointer is 'string like', in
encoding utf-8
    d.putValue(s)
    d.putNumChild(0)

It takes the deref branch for the refence instance, but still does not work.

Btw. from time to time I get a value '<unavailable synchroneous data>',
(misspelling is intentional, coming from qtcreator), but that appears to be
just a symptom for gdb/qtcreator not finding the reference type and thinking
it should have children.


I'm on Ubuntu 10.04, 64 bit. qtcreator 1.3.83, GNU gdb (GDB) 7.1-ubuntu



-- 
Grego
http://mpaja.com/
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-creator

Reply via email to