= Debug Tools = Most times debugging without a debugger is really hard. In complex programms printing text and values of variables to the console is not an option for debugging anymore. Being able to handle a debugger like GDB oder DDD makes (coders) life much easier. == GDB == GDB is the standard (console based) unix debugger. === Basic usage === To simply run the program and wait for a segfault follow the below instructions. 1. Go to the binary directory (bin) and run '''gdb orxonox''' 2. Type '''run''' 3. Wait for the segfault to occur ... * If you want to display the back trace ( list of function calls ) just type '''bt'''. * You can change the context (function to debug) by typing '''up''' and '''down'''. * If you want to display the value of a variable make sure you are in the right context (by using up and down) and type '''print varname''' * If you have an object pointer and you don't know the exact type of the class (e.g. pointer to WorldEntity which is actually a !SpaceShip) you can type '''x/wa addressOfObject''' and gdb will tell you what class type the object located in ''addressOfObject'' has by considering the vtables === Setting Breakpoints === You can set breakpoints for - functions: '''break namespace::ClassName::functionName''' (e.g. ''break orxonox::SpaceShip::fire'') - codelines: '''break fileName.cc::''lineNr''''' (e.g. ''break !SpaceShip.cc:367'') If the program hasn't yet been run in gdb, it will not have loaded all our libraries (e.g. libcore.so, libnetwork.so) and thus will not be able to set the breakpoint immediately, but ask you whether it should set it at run time. Make sure you entered the address/function correctly and type ''yes''. * To delete a breakpoint you can either use '''delete''' or '''clear'''. Type '''help''' / '''help ''gdb-function''''' for more information. === Setting Watchpoints === Sometimes it's usefull to know when the value of a variable changes. 1. To make use of this feature set a breakpoint somewhere you can access the variable from (watchpoints for static variables can be set without doing this). 2. Run the program and wait for the breakpoint to get triggered 3. Type '''watch ''varname''''' == DDD == DDD is a simple graphical debugger based on GDB.