Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Debug-Output of e.g. Qt-Types(How to define gdb-output-definition of external datatypes ?)
Debug-Output of e.g. Qt-Types [message #840573] Tue, 10 April 2012 08:59 Go to next message
Simon Lange is currently offline Simon LangeFriend
Messages: 5
Registered: April 2012
Junior Member
hi all,

using CDT with Qt there is a problem for me: I'm not able to define the kind of interpretation of the variable-contents shown by gdb at e.g. a breakpoint.

Googling told me:

->this CDT-problem has been discussed before
->there is a generally possibility to tell gdb (by macros) how to format datatype-output.

can somebody tell me:

->is there a way to educate CDT to do this interpretation of e.g. "QString" - type
->is there a simple way to solve this via e.g. a plugin ?
->is there another prepared way to bind the gdb-makros into CDT ? (is this the generally way to solve this also for the std-datatypes in background ? )
->or is there generally another point in the eclipse-architecture to turn the screw ?

thanks and best regards

Simon
Re: Debug-Output of e.g. Qt-Types [message #840621 is a reply to message #840573] Tue, 10 April 2012 09:59 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
If you have a recent gdb (at least 7.0) you can use the gdb internal python interpreter to enable so-called pretty preinting. Info is here http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_inspect_the_contents_of_STL_containers.3F
I use the Qt pretty printers from KDE https://projects.kde.org/projects/extragear/kdevelop/kdevelop/repository/revisions/master/changes/debuggers/gdb/printers/qt4.py

# to use it put the following lines in your ~/.gdbinit
# of course the path has to be adapted
python
import sys
sys.path.insert(0, '/PATH/TO/FILE/qt4.py')
from qt_printers_gdb import register_qt4_printers
register_qt4_printers (None)
end
set print pretty 1


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Debug-Output of e.g. Qt-Types [message #840904 is a reply to message #840621] Tue, 10 April 2012 16:44 Go to previous messageGo to next message
Simon Lange is currently offline Simon LangeFriend
Messages: 5
Registered: April 2012
Junior Member
hi axel,

thanks. working with Eclipse indigo and gdb 7.3.1 I tried it out:

->If I try to use STL-pretty-printing and start the gdb it says: "gdb not configured to start with python" or so. if I try to start the gdb by using "gdb --with-python" it starts and never comes back. is it necessary to put the python-path (on a WIN-system) to the PATH-variable on order to be found by gdb ?)

->If I try the Qt-pretty-printing using the qt4.py-file and start the gdb it seems to run ok, but the output of e.g. QString in the debug-prints is the same as before. may be the qt4.py isnt found and so there isn't any request to work with python ?

but the script -I am not familiary with python- seems to be ok for me. I attached the folder-view and the dbginit-file, would you be so kind to have a look at it ?

do you know if there is a gdb-debug-log to find the reason ?

best regards

Simon
  • Attachment: Path.jpg
    (Size: 62.29KB, Downloaded 315 times)
  • Attachment: Path.jpg
    (Size: 62.29KB, Downloaded 287 times)
  • Attachment: dbginit.jpg
    (Size: 48.26KB, Downloaded 309 times)
Re: Debug-Output of e.g. Qt-Types [message #841303 is a reply to message #840904] Wed, 11 April 2012 06:23 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
You can start gdb from the command line and enter the commands from gdbinit manually. Then you will see if it works. But it seems your gdb version lacks python support or it cannot find Python on your system. I guess you have to set PYTHONPATH or so (I am not sure, on Linux it works out of the box).

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Debug-Output of e.g. Qt-Types [message #841397 is a reply to message #841303] Wed, 11 April 2012 08:45 Go to previous messageGo to next message
Simon Lange is currently offline Simon LangeFriend
Messages: 5
Registered: April 2012
Junior Member
hi axel,

ok, now it runs. the problem was, that in the MinGW-distribution i use there is a "normal" gdb.exe without python-support. and there is also a "gdb-python27.exe"-gdb. if i use the last one the python-script is worked ok and the new debug-interpretation of Qt-classes is visible.

thank you very much

Simon

Re: Debug-Output of e.g. Qt-Types [message #848826 is a reply to message #841397] Wed, 18 April 2012 16:01 Go to previous messageGo to next message
jonathan ponroy is currently offline jonathan ponroyFriend
Messages: 12
Registered: April 2012
Junior Member
Hi,

i tried also to have a good display of QT type and tried the method proposed above but gdb launch an error with gdbinit :

ImportError: No module named qt_printers_gdb

I'm under Ubuntu 10.04

If somebody have a suggestion for me
Re: Debug-Output of e.g. Qt-Types [message #849498 is a reply to message #848826] Thu, 19 April 2012 07:45 Go to previous message
jonathan ponroy is currently offline jonathan ponroyFriend
Messages: 12
Registered: April 2012
Junior Member
I found the solution :

rename file qt4.py to qt_printers_gdb.py

and change .gdbinit like following:

# to use it put the following lines in your ~/.gdbinit
# of course the path has to be adapted
python
import sys
sys.path.insert(0, '/PATH/TO/FOLDER/WHERE/qt_printers_gdb.py/IS/')
from qt_printers_gdb import register_qt4_printers
register_qt4_printers (None)
end
set print pretty 1

Enjoy

[Updated on: Thu, 19 April 2012 08:46]

Report message to a moderator

Previous Topic:DOM/AST Questions
Next Topic:Program terminated without execution
Goto Forum:
  


Current Time: Fri Apr 26 14:21:55 GMT 2024

Powered by FUDForum. Page generated in 0.04455 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top