I am very new to programming and just want to start with it, while writing my program I found some core files , I have heard that core files can be debugged so can anyone please tell how to debug the corefile in unix. Thanks in advance .
Steps to debug coredump using gdb :
Some generic help:
gdb start GDB, with no debugging les
gdb program begin debugging program
gdb program core debug coredump core produced by program
gdb --help describe command line options
1- First of all find the directory where the corefile is generated. 2- Then use "ls -ltr" command in the directory to find the latest generated corefile. 3- To load the corefile use
gdb binary path of corefile
This will load the corefile.
4- Then you can get the information using "bt" command. For detailed backtrace use "bt full".
5- To print the variables use "print varibale-name" or " p varibale-name"
6- To get any help on gdb use "help" option or use "apropos search-topic"
7- Use "frame frame-number" to go to desired frame number.
8- Use "up n" and "down n" commands to select frame n frames up and select frame n frames down respectively.
9- To stop gdb use "quit" or "q".