How To: Freeswitch Crash Debugging with GDB and Backtrace Tutorial
If FreeSwitch is crashing on your system on a regular basis it would be a good idea to do a debug on the core dump to find out what the problem is. This will also give you a better chance of people helping you in the #freeswitch irc channel on freenode. If you have a backtrace file someone will likely walk through it with you if you pastebin it on the web so they can read through it.
The backtrace will go step by step through the events prior to the application crash, the example below is how to do this with freeswitch but can be applied to any application, if you have any questions just post a comment and I will get back to you.
1. So the first step is to locate your core dump file, there are many ways to search through different *nix systems my preferred method is the find command, the syntax is below. This will do a search of the whole “/” root file system for a file named freeswitch.core, this will locate your core dump file and once you do go into that directory. In my example the core dump file was in /usr/local/freeswitch.
find / -name freeswitch.core cd /usr/local/freeswitch
2. The next step is to invoke the gdb tool to read through the core file, and then log all the output from the commands into a txt file to later load on a pastebin site. This is an easy enough process as shown below in my example. To invoke the gdb tool use the command below, this starts the gdb tool, loads the freeswitch binary and then inputs the core dump file. The set logging option will send all output to a txt document named core_output.txt, be sure to turn logging on after that.
gdb /usr/local/freeswitch/bin/freeswitch freeswitch.core set logging file core_output.txt set logging on bt bt full thread apply all bt thread apply all bt full quit
3. Now that the backtrace is stored in a txt file it is now possible to post that to a pastebin site that way it is easy to share with the community to help you debug your problem. To see how to pastebin from the command line see my other blog post, PastbinIt Utility, this post has instructions on how to install and use the Pastbin-It utility. At the time of this writing because PastebinIt does not include the freeswitch pastebin site I like to pastebin to the default pastebin site and copy and paste into the freeswitch pastebin site, this keeps everyone in the #freeswitch irc channel happy and will help you.
./pastebinit -i /usr/src/core_output.txt