GCC equivalent of PDBs

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.