Another way to debug your application is to use the main file for debugging using GDB.
To create the main file during segmentation, you can follow these steps:
1) Copy the parameters below into your script that starts the daemon.
ulimit -c unlimited mkdir -p <path_to_core_file>, eg : /etc/user/ankit/corefiles chmod 777 /etc/user/ankit/corefiles echo "/etc/user/ankit/corefiles/%e.%s.core" > /proc/sys/kernel/core_pattern
2) Launch your application using a script and wait for the kernel dump file to be created. Once you get a kernel dump, you can debug it using gdb by doing the following:
3) Getting back trace with GDB
gdb -c <core_file>, where core_file is the file generated after segmentation fault
4) Reverse trace
Next, we want to know what the stack is when the program crashed. Running bt at the gdb prompt will give you backtrace. If GDB did not load the characters for the binary, it will give an error with a question mark, similar to this "??????". To fix this, you will need to download the characters.
Here's how to load debugging symbols.
symbol-file /path/to/binary sharedlibrary
5) Get BackTrace for all threads
thread apply all bt full
NOTE. Make sure the binary is composed using debug symbols.
source share