To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

Debugging: Difference between revisions

From ZNC
Jump to navigation Jump to search
>Mkaysi
Make commands that go to shell and gdb more clear
>Antivirtel
m Fixing wrong gdb command
Line 30: Line 30:
<pre>
<pre>
$ gdb
$ gdb
(gdb) set logging /tmp/znc.gdb.log
(gdb) set logging file /tmp/znc.gdb.log
(gdb) set logging on
(gdb) set logging on
(gdb) gdb ./znc
(gdb) gdb ./znc

Revision as of 13:47, 28 April 2015

Reporting bugs

Steps to do when you think you found a bug:

Tracing crash bugs

Configure your ZNC version with --enable-debug.

./configure --enable-debug --enable-other-things-you-may-want
make
make install

Then you can run ZNC under gdb:

$ gdb znc
(gdb) set logging file /tmp/znc.gdb.log
(gdb) set logging on
(gdb) handle SIGPIPE nostop
(gdb) run -D

If znc is already running, you can attach gdb to the already-running instance (where pid is znc's process id):

$ gdb
(gdb) set logging file /tmp/znc.gdb.log
(gdb) set logging on
(gdb) gdb ./znc
(gdb) attach pid
(gdb) handle SIGPIPE nostop
(gdb) cont

Now you use ZNC as you would always do and try to make it crash. Once it crashed, gdb will show you something like this:

Program received signal SIGSEGV, Segmentation fault.

Now we can get the useful info. This info, together with an explanation how the bug happened are then very useful to the developers.

(gdb) bt full

If you had logging file set and logging enabled, you can find the bt full and everything else in /tmp/znc.gdb.log. You might want to copy it somewhere safe (that doesn't get cleared every boot unlike /tmp).

core files

You can also get the full backtrace from core file if you have core files enabled.

First run

ulimit -c unlimited

and preferrably add it to your ~/.bashrc or rc of whatever shell you use. When your ZNC crashes, you should find a file with name "core" in the directory where you ran znc. If you used cron, it is probably located at $HOME. Now run

gdb znc core

and there

(gdb) set logging /tmp/znc.gdb.log
(gdb) set logging on
(gdb) bt full
(gdb) quit

Now your full backtrace should be in /tmp/znc.gdb.log and you can send it to the developers. It's also adviced to copy znc.gdb.log to somewhere outside /tmp as /tmp is cleared every boot.

Why use --enable-debug?

With this flag bt full shows much more info, which is needed to understand why the crash had happened. If you're interested in details, search the Web for "debug symbols" or just try with and without.