I have a program that I intend to distribute to end users, and would like to have receive crash reports from them. If I were using MSVC, I would generate minidumps and have those sent to me, and then inspect them with the corresponding PDB to get a useful stack trace, at the very least.
What is the equivalent of doing this with GCC? I can generate a stack trace, but if I want this to be useful, it requires having debug symbols compiled into the executable (with -g). Obviously this is unacceptable for release distribution, since the executable can balloon in size quite a bit.
I googled a bit and found references to objcopy being able to separate out debug symbols to a separate file, but that page implied I would still need to have the debug symbols available alongside the release executable, which again is obviously unacceptable.
Well the idea is that you compile with -g
to add debug symbols but not slow the program down, ie. most programs will do -g -O2
then you can seperate debug symbols with objdump
. After that you can strip
your release build so it won't have any debug symbols.
Update: Recent gdb supports separate debug files, see https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
For example you can doo
objcopy --only-keep-debug prog prog.debug
strip prog
Now your prog
won't have any debug symbols. But you can use proc.debug
file to debug it in gdb.
I couldn't find an exact answer to this, but I found an alternate solution that works just as well: Compile with optimization and other release flags alongside -g
, store the resulting executable somewhere, then remove debug symbols using strip
. Ship the stripped executable, and when you get a stack trace, use addr2line
in combination with the original, unstripped executable, and you should get all the symbols back.