GCC equivalent PDB

I have a program that I intend to distribute to end users and would like to receive crash reports from them. If I were using MSVC, I would generate minidumps and pass them to me, and then check them with the corresponding PDB to get a useful stack trace, at least.

What is equivalent to doing this with GCC? I can create a stack trace, but if I want this to be useful, this requires the presence of debugging symbols compiled into an executable (with -g). Obviously, this is unacceptable for distribution of the release, since the executable file may slightly increase the size.

I did a bit of work with Google and found links to objcopy that could extract debugging symbols into a separate file, but this page implied that I still need to have debugging symbols available with the release executable, which again is clearly unacceptable.

+8
gcc debugging visual-c ++
source share
2 answers

I could not find an exact answer to this question, but I found an alternative solution that works just as well: compile with optimization and other release flags next to -g, save the resulting executable file somewhere, then delete the debug symbols using the strip. Send the remote executable, and when you get the stack trace, use addr2line in combination with the original, unset-up executable, and you should return all the characters.

+5
source share

Well, the idea is that you compile -g to add debugging symbols, but don't slow down the program, i.e. most programs will do -g -O2 , then you can separate the debugging characters with objdump . After that, you can strip create your version so that it does not have any debugging symbols.

Update: latest 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 will not have any debugging symbols. But you can use the proc.debug file to debug it in gdb.

+6
source share

Source: https://habr.com/ru/post/651023/


All Articles