Debugging Freeswitch
From FreeSWITCH Wiki
This page is about using a debugger with freeswitch. For troubleshooting see Troubleshooting Freeswitch
Contents |
[edit]
Handy Troubleshooting Links
[edit]
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>
[edit]
Recompiling with debug symbols on
export CFLAGS="-g -ggdb" export MOD_CFLAGS="-g -ggdb" ./configure
[edit]
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
[edit]
Loading Freeswitch in GDB
From /usr/local/freeswitch:
$ gdb bin/freeswitch
To load with a core file
$ gdb bin/freeswitch core.xxx
[edit]
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
[edit]
Simple bash script to make debug easy
[edit]
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
