Debugging Freeswitch

From FreeSWITCH Wiki

Jump to: navigation, search

This page is about using a debugger with freeswitch. For troubleshooting see Troubleshooting Freeswitch

Contents

Handy Troubleshooting Links

Chasing down xml errors

So you have freeswitch with all of those included files and you get the "error near line X". With all of the included files where does this line number come from.
By default it is ~freeswitch/log/freeswitch.xml.fsxml
Do not edit this file while freeswitch is running. It is memory mapped.

freeswitch@localhost.localdomain>reloadxml
API CALL [reloadxml()] output:
+OK [[error near line 1622]: unexpected closing tag </extension>]
freeswitch@localhost.localdomain> 

Recompiling with debug symbols on

export CFLAGS="-g -ggdb"
export MOD_CFLAGS="-g -ggdb"
./configure

Creating core files

For core files to be created when a crash occurs, set the core ulimit to unlimited before starting freeswitch

$ ulimit -c unlimited
$ ./freeswitch

Loading Freeswitch in GDB

From /usr/local/freeswitch:

$ gdb bin/freeswitch 

To load with a core file

$ gdb bin/freeswitch core.xxx

Getting a Backtrace

Once you load the core file into GDB you can collect a backtrace typing

bt
bt full
thread apply all bt
thread apply all bt full 

Collect the output when reporting bugs to Jira

Simple bash script to make debug easy

fs_debug.sh

 #!/bin/bash
 echo > fs_debug.txt
 echo "== Log Output ==" >> fs_debug.txt
 tail -n1000 /usr/local/freeswitch/log/freeswitch.log >> fs_debug.txt
 echo >> fs_debug.txt
 echo >> fs_debug.txt
 echo "== GDB Output ==" >> fs_debug.txt
 echo "bt" > fs_debug.cmd
 echo "bt full" >> fs_debug.cmd
 echo "thread apply all bt" >> fs_debug.cmd
 echo "thread apply all bt full" >> fs_debug.cmd
 gdb --batch --command=fs_debug.cmd \
 --pid=`cat /usr/local/freeswitch/log/freeswitch.pid` \
 /usr/local/freeswitch/bin/freeswitch >> fs_debug.txt
 rm fs_debug.cmd
Personal tools