GCC相当于PDB [英] GCC equivalent of PDBs

查看:151
本文介绍了GCC相当于PDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个计划分发给最终用户的程序,并且希望收到他们的崩溃报告。如果我使用的是MSVC,我将生成小型转储并将其发送给我,然后至少使用相应的PDB检查它们,以获取有用的堆栈跟踪。

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.

使用GCC进行此操作相当于什么?我可以生成一个堆栈跟踪,但是如果我想使用它,则需要将调试符号编译到可执行文件中(使用-g)。显然,这对于发行版分发是不可接受的,因为可执行文件的大小可能会膨胀很多。

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.

我在Google上做了一些搜索,发现对objcopy的引用能够分离出调试符号到一个单独的文件,但该页面暗示我仍然需要在发布可执行文件旁边提供调试符号,这显然也是不可接受的。

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.

推荐答案

我找不到确切的答案,但是我找到了一个同样有效的替代解决方案:连同优化和其他发行标志一起在 -g ,将生成的可执行文件存储在某个位置,然后使用 strip 删除调试符号。装运已剥离的可执行文件,并在获得堆栈跟踪时,将 addr2line 与原始的未剥离的可执行文件结合使用,并且应该重新获得所有符号。

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.

这篇关于GCC相当于PDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆