Debugging
From Yzis Wiki
Contents |
Yzis Log System
Be sure to check the Yzis Log System page. This will allow you to debug a lot of things.
Debugging Yzis with gdb
In addition to using the log system, running Yzis inside a debugger is a good way to diagnose crashes or find bugs. Step by step execution or breakpoints are a useful tool.
Building yzis with debugging support
Building yzis with debugging support allows to diagnose crashes, or to run Yzis in gdb - the Gnu Debugger.
Make sure you build yzis with debugging enabled. Follow the instructions at the Build Yzis page, and you should be fine.
Gdb and more
First of all you need a recent version of gdb, the text ui used in the example below requires gdb version 5.1 or newer.
You should also download the gdb macros from the KDE project:
wget "http://websvn.kde.org/*checkout*/trunk/KDE/kdesdk/scripts/kde-devel-gdb"
Put this file in a smart place and source it in your ~/.gdbinit:
source /path/to/kde-devel-gdb
This enables you to print the contents of QStrings and other Qt objects.
Using the GNU debugger (gdb) to debug yzis
This is not an gdb tutorial, if you want to learn to use gdb you can find plenty of tutorials by googling. In this example I will use gdb's text ui and debug a qyzis session.
To start debugging, type
gdbtui qyzis
Your screen should now look something like this:
The basic commands are:
- b Sets a breakpoint
- run Starts the program with given parameters
- cont Continues execution to the next breakpoint (if any) after stopping at a breakpoint
- bt Prints a backtrace of all stack frames. This is what you will use to track down segfaults ;-)
- p Prints the value of a variable or a function/method. This lets you examine the value of ints, strings etc. Note: this doesn't work very well for QString objects, to print the contents of a QString, use the printq4string macro defined in kde-devel-gdb
- n Continues to the next line of code as shown on screen. If a subroutine is called, you won't step in it
- step Steps exactly one line of code, including subroutines. If you are on a line containing "int a = foo()", this will take you in to the function foo(), while n would have skipped to the next line on screen
To switch between the source code view and the command line in the text ui, press control+x and then control+o.

