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

Difference between revisions of "Debugging"

From ZNC
Jump to: navigation, search
m (add missing "file" to gdb)
(Restore Debugging from archive.org - 2016/11/07)
 
(2 intermediate revisions by 2 users not shown)
Line 19: Line 19:
  
 
<pre>
 
<pre>
set logging file /tmp/znc.gdb.log
+
$ gdb znc
set logging on
+
(gdb) set logging file /tmp/znc.gdb.log
gdb ./znc
+
(gdb) set logging on
handle SIGPIPE nostop
+
(gdb) handle SIGPIPE nostop noprint pass
run -D
+
(gdb) run -D
 
</pre>
 
</pre>
  
Line 29: Line 29:
  
 
<pre>
 
<pre>
set logging /tmp/znc.gdb.log
+
$ gdb
set logging on
+
(gdb) set logging file /tmp/znc.gdb.log
gdb ./znc
+
(gdb) set logging on
attach pid
+
(gdb) gdb ./znc
handle SIGPIPE nostop
+
(gdb) attach pid
cont
+
(gdb) handle SIGPIPE nostop noprint pass
 +
(gdb) cont
 
</pre>
 
</pre>
  
Line 46: Line 47:
  
 
<pre>
 
<pre>
bt full
+
(gdb) bt full
 
</pre>
 
</pre>
  
Line 59: Line 60:
 
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 <pre>gdb znc core</pre> and there
 
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 <pre>gdb znc core</pre> and there
 
<pre>
 
<pre>
set logging /tmp/znc.gdb.log
+
(gdb) set logging /tmp/znc.gdb.log
set logging on
+
(gdb) set logging on
bt full
+
(gdb) bt full
quit
+
(gdb) quit
 
</pre>
 
</pre>
  

Latest revision as of 22:31, 21 May 2017

Reporting bugs[edit]

Steps to do when you think you found a bug:

Tracing crash bugs[edit]

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 noprint pass
(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 noprint pass
(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[edit]

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?[edit]

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.