Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC equivalent of PDBs

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.

like image 956
pjohansson Avatar asked Jan 13 '11 10:01

pjohansson


People also ask

Is PDB file required for deployment?

No, you don't have to deploy the . pdb file. To quote from MSDN, "A PDB file is created when you build with /debug (Visual Basic/C#).", so it shouldn't be creating the debug database when compiling for release.

What are PDBs where must they be located for debugging to work?

A program database (PDB) file holds debugging and project state information that allows incremental linking of a debug configuration of your program. A PDB file is created when you build with /debug (Visual Basic/C#). You can build Visual Basic and Visual C# applications with /debug:full or /debug:pdbonly.

What are PDB symbols?

Program database (. pdb) files, also called symbol files, map identifiers and statements in your project's source code to corresponding identifiers and instructions in compiled apps. These mapping files link the debugger to your source code, which enables debugging.


1 Answers

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.

like image 102
ismail Avatar answered Oct 19 '22 00:10

ismail