Other:GDBExtended
From Anope Wiki
Contents |
What is GDB?
GDB is the GNU DeBugger. It is a text-based tool to help people debug their programs. By running a program inside GDB, you can halt program execution at certain points or at crashes. Because GDB doesn't let the program quit when it crashes, the program is still in the exact state it was in when it crashed. GDB provides a number of tools to examine the state of the program when it crashed.
Why you need GDB
You were probably sent here because your copy of Anope crashed for one reason or another. By using GDB you can help us find the cause of the crash. If you run Anope inside of GDB and produce a so-called backtrace, we can find the exact line of code which caused the crash. A backtrace reports exactly where in the program execution halted.
Getting GDB
Most (if not all) Linux distributions include GDB in their package manager nowadays. On Debian-based distributions the package will be called 'gdb'. On other Linux distributions the name will be something similar.
If your distribution doesn't provide GDB, you can download it from the GNU site:
Running GDB
When running GDB, it will have to load a program into it's memory. This program is specified on the command-line; in the case of Anope, this is ./services. So to start GDB with the ./services program in it's memory, you need to enter this at your shell:
gdb ./services
This will launch GDB. It will show some startup information (which can usually be safely ignored, it just states it's free software etc), and then shows a GDB prompt:
GNU gdb 6.4-debian Copyright 2005 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i486-linux-gnu"...Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1". (gdb)
This is the GDB prompt we'll be using from now on. All the commands following from now will have to be entered at this GDB prompt. First we'll show you how to get out of GDB; that's simply done by using the quit command:
(gdb) quit
This will terminate GDB and return you to your shell.
Running Anope inside GDB
The next step is to run Anope inside of GDB. This is done using the run command. The run command accepts the normal command-line parameters for Anope as it's arguments. You should run Anope with the -debug and -nofork options inside GDB. The -debug option will increase the verbosity of Anope by a lot; it will show all network traffic and an overview of the internal workings of Anope. The -nofork option makes sure Anope doesn't hide itself and the background; if Anope is hidden, GDB can't 'control' it.
(gdb) run -debug -nofork
Anope will now start and connect to your IRC server etc. The next step is to make Anope crash. Once Anope has crashed, you will be back at the GDB prompt. From here you will have to generate a backtrace by using the bt command.
(gdb) bt
This will produce a backtrace output. The backtrace output will be a number of lines (usually something around 8 or 9 lines) starting with # and a number. After the backtrace output the GDB prompt will pop up again. Copy the backtrace from GDB and paste it to our pasting page at http://anope.org/paste2.php. You are now done and can quit GDB.

