Analyze core dump file  in Linux  for errors

sam_2012
sam_2012 used Ask the Experts™
on
Hi All,

Iam running a progrm wrtten in c++ program executable  in linux operating system and getting Core Dump error while runnning it. Iam using Linux operating system. Can anyone help how to analze the core dump file to figure out the cause of the issue.
I was told to use the  valgringd and bt command  ,but need help how to use these commands and debug the issue in the core dump file. iam very new to this type of error. Any help is really appreciated.
Also can I run the process using valgrind command?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fractional CTO
Distinguished Expert 2018
Commented:
Valgrind is likely the wrong tool.

General debug steps.

1) Do a make clean on every thing. Destroy (remove) all traces of your App code, including all libraries.

2) Recompile all code, including all libraries, with symbolic debugging enabled.

3) At this point you can either run your code under gdb (GNU Debugger) or run gdb on your core file. Either approach will show you the exact line causing the crash (core dump).

The search - site:youtube.com how to use gdb - returns 9K results, so best to go through a variety of these tutorials to learn gdb, as there are many varying approaches to using gdb.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Note: You can only debug libraries (to a file + line level) for libraries compiled with symbolic debug enabled + also where you have source code available.

If you find the problem is in a system library, when you pass correct function parameters, then to debug this, you'll install a debug version of the library + it's related source code.

Doing this on Debian/Ubuntu is extremely easy as every installation package has a related source package too.

On other Distros this can be extremely difficult to correlate source with binary code. In this case, you may require recompiling system or other libraries with symbolic debug, then using --rpath linkage directives to force your code to use debug libraries.

Big Tip: Before ever starting a debug process ensure you're using latest stable code of all software in use.

For example, old versions of Glib caused system wide crashes of many software packages for several years.

If you're using old/buggy code (fixed long ago) all your debugging will tell you is you must do a system update first, which may magically fix all your crashes.
nociSoftware Engineer
Distinguished Expert 2018

Commented:
You can use gdb + original code + coredump to analyze a coredump IF the original code still has symbols. (either unstripped binaries, or separate symbol tables).
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

David FavorFractional CTO
Distinguished Expert 2018

Commented:
Also, to do line level debugging, you'll require the exact matching version of source files used to compile your code.

Without source code, you can only do very coarse level debugging.

Author

Commented:
Thanks a lot
David FavorFractional CTO
Distinguished Expert 2018

Commented:
You're welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial