This page is about using a debugger with FreeSWITCH.
If you are new to troubleshooting, asking for help, or filing bug reports, please read this first. It will save you a lot of time.
For an introduction to please see troubleshooting see Troubleshooting FreeSWITCH
Handy Troubleshooting Links
UUID Stamp at each DEBUG line
The update in the code to enable a UUID Stamp at each debug line (provided kindly by Mathieu Rene and referred to in the "Finding session pointers" section below) has been committed to the GIT head (as of 19/Nov/2009), and you can enable this by a simple option at the logfile.conf.xml:
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.
Doing it Better
Some of these can be hard to track down especially if one has update a number of XML files. In such situation an external tool such as 'xmllint' (part of libxml2-utils on Debian/Ubuntu) should be used. It will narrow down the error to exact line with a more information error message.
Example of cryptic FreeSWITCH output:
Example of xmllint output find the error on line 4465; please note that you will have to also filter through errors generated by some of the vanilla included FreeSwith XML files. In t:
Recompiling with debug symbols on
Creating core files
For core files to be created when a crash occurs, set the core ulimit to unlimited before starting FreeSWITCH
The core file should be located in the directory where FreeSWITCH was started (i.e., if you were in the /tmp directory when you typed the command to start FreeSWITCH, then there should be a file called something like /tmp/core.xxx).
NOTE: On OS X, core files are dumped to a hidden directory called /cores by default, not the current directory!
Loading FreeSWITCH in GDB
Once you have reproduced the error you run the following command:
Getting a Backtrace
Once you load the core file into GDB you can collect a backtrace typing
Collect the output when reporting bugs to Jira
If you have a FS source tree available, please run instead:
Finding session pointers
Sometimes hunting stuff down can be a royal pain. The following code, submitted by Mathieu Rene, will print out all the session information (pointer information, etc.) for each session in a core file. After loading gdb with a core file (see above) do this in gdb:
NB: $x->data is the switch_core_session_t*, you can dereference the channel with ->channel and can print some other stuff you might be looking for. This also work to print the content of a hashtable (use hash_table_name->table->first on the first set)
Simple bash script to make debug easy
In the source directory there is a support-d sub-directory. Inside this directory is a handy shell script called fscore_pb. The script will collect the appropriate trace (and some other information), post it to pastebin.freeswitch.org, and then give you the URL to give to the developers.
If gcore is given it will take a gcore of a running instance of FreeSWITCH (this will pause the process during the dump). If gcore is not given it will use the most recent core.* file in the directory.
User is optional, and is the name given when submitting the pastebin. If it is omitted it will use your local username.
On Ubuntu (Dapper/Hardy/Jaunty) gdb does not show symbols for some modules (e.g. mod_portaudio), while CentOS 5.3 haven't got such issue.
The reason of the issue is that gdb in Ubuntu (probably Debian is affected too) is buggy. As a quick fix you can install development version of gdb from sources (install flex, bison and texinfo and get sources from git repository) which solves the issue. gdb trunk 20090626 is proven to work.