I don't have any idea how I could find the root cause of a C/C++ linux application's problem using the core files. I understand that core files are genereated when something unexpected happens to an application. But I don't know where to start. Can anybody give me a jump start?
-
1sorry, just edited a few seconds ago. It's in C/C++. – Java Noob Oct 21 '12 at 16:52
-
1The first thing I try to get out of a core dump is usually a stack backtrace for all threads, which can be done with tools like gdb or pstack, some of which are platform specific. – Seg Fault Oct 21 '12 at 16:53
-
1You start with `gdb program core`. Have you gotten past that? – Vaughn Cato Oct 21 '12 at 16:56
-
possible duplicate of [How to analyze a program's core dump file?](http://stackoverflow.com/questions/8305866/how-to-analyze-a-programs-core-dump-file) – hichris123 Sep 21 '14 at 18:24
3 Answers
"gdb" is the main tool you can use to analyze Linux core dumps. Here are several good tutorials:

- 114,292
- 17
- 138
- 190
-
There are three links :) And there's no such language as "C/C++". There's "C", there's "C++", and you will generally choose one or the other. My preference is "C"; or Java or C# for any OO stuff :) – paulsm4 Oct 22 '12 at 04:50
Some generic help:
Install gdb using :
yum install gdb
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".

- 2,150
- 1
- 15
- 13