Linux / C ++如何调试发布应用程序

Linux / C ++如何调试发布应用程序

问题描述:

我有linux c + +多线程应用程序。现在它在生产服务器上测试并具有segfault。问题是,我不能在我的任何测试服务器上重现该错误,并且无法访问生产服务器。我没有转储或任何其他有用的信息。只有行:
segfault at 0000000046bf0fb8 rip 000000000048ac6b rsp 0000000046bf0fa0错误6

I have linux c++ multithreaded application. Now it's tested on production servers and have segfault. Problem is that I cannot reproduce that error on any of my test servers and have no access to production servers. I have no dump or any other useful information. Only line: segfault at 0000000046bf0fb8 rip 000000000048ac6b rsp 0000000046bf0fa0 error 6

我想问问社区我可以从这样的行获得一些信息,这将有助于减少区域的可能的地方,我应该搜索。我不能运行调试生成,因为它的速度慢。我可以添加哪些版本,哪些帮助我调试?这个bug看起来像多线程错误,很难再现。但我不确定,因为应用程序使用来自MTA的许多不同的电子邮件。

I would like to ask community can I get from such line some information which will help decrease area of possible places where I should search. I cannot run debug build on production because of its slow speed. What can I add to release which help me debug? This bug looks like multithread bug, and hard to reproduce. But I'm not sure, because application works with a lot of different emails from MTA.

平台:Linux

编译器行:g ++ -O3 -D_REENTRANT

Compiler line: g++ -O3 -D_REENTRANT

谢谢。

。我可以包括调试信息。我想知道调试发布版本的基本方法。例如我有dump和release版本。我应该如何继续。我应该阅读什么?你能解释几个字如何调试你的应用程序,如果可能的话?谢谢。

upd.: Thanks for your answers. I can include debug information. I'd like to know base methods of debugging release builds. For example I have dump and release version. How should I continue. What should I read about that? Can you explain in few words how you debug your application if possible? Thank you.

Andy提到,在发布版本时,请保留调试符号。

As Andy mentioned, leave the debugging symbols in when you make your release builds.

如果这使得完成的可执行文件的大小不可接受地大,那么你可以制作最终可执行文件的副本,并通过 strip 运行它删除调试符号。这样,您有两个相同的可执行文件,除了一个有调试符号,另一个没有。将不带符号的一个放在生产服务器上。当它发生segfaults时,调试仍然包含调试符号的可执行文件的副本。

If this makes the size of the finished executable unacceptably large, then you can make a copy of the final executable and run it through strip to remove the debug symbols. This way you have two executables that are identical except one has debug symbols and the other does not. Put the one without symbols on the production server. When it segfaults, debug against the copy of the executable that still contains debug symbols.