Linux – Core Dump analysis generated by the Release version app

Core Dump analysis generated by the Release version app… here is a solution to the problem.

Core Dump analysis generated by the Release version app

From something like this I already know how to parse a core dump file generated by a debug version of an application. For core dump files, I can also use the gdb tool and the bt command to get the call stack.

But when using other commands like info locals, list, print localvariable, etc., I find that they show nothing! To my surprise, this core dump is as large as the debug version of the application and is 1.6 GB bytes in size!

Is there a way to get more information including the call stack? Can I view additional details about variables in the last function call when generating a core dump?

Solution

What surprises me is that this core dump file is as big as the one generated by debug version app and has size of 1.6G bytes!

You shouldn’t be surprised by this. A core dump contains a modifiable segment of application memory. An application compiled with debug information will have exactly the same modifiable memory as an application compiled without debug information and should produce exactly the same core dump (assuming the other compilation flags are the same and the application can be run repeatedly).

Debugging information is required to understand memory dumps in the debugger. But you can also understand that memory dump without debugging information, it’s just more manual and tedious.

Is there anyway to get more information including the call stack?

You say you already have the call stack.

It’s a best practice to always build your application with complete debugging information, for example

gcc -O2 -g -c foo.cc -o foo.o
gcc -g foo.o bar.o ... -o app

Then keep the resulting (large) binary for debugging, but send a stripped variant of that binary to the end user:

cp app app-stripped
strip -g app-stripped   # removes all debug info from app-stripped

Now, when you get a core dump from application stripping, use the full debug app to analyze the core.

Alternatively, you can use a separate debug information file, as described in the documentationhere

Related Problems and Solutions