windows 有没有办法在运行用 MinGW 编译的程序时生成 gdb 可读的核心转储?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5814568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:44:18  来源:igfitidea点击:

is there a way to generate a gdb-readable coredump when running programs compiled with MinGW?

cwindowsgdbmingw

提问by user168715

I'm trying to debug a Windows program compiled using MinGW's gcc that only ever segfaults when run outsideof gdb (probably some race condition... lovely.) The problem is, when the program crashes and I'm not running GDB, I can't get a stack trace... I have the option to open up the program in MSVC when it crashes, but MSVC can't read gcc's debugging symbols and so the stack trace it gives me is useless.

我正在尝试调试使用 MinGW 的 gcc 编译的 Windows 程序,该程序仅gdb之外运行时才会出现段错误(可能是某些竞争条件......可爱。)问题是,当程序崩溃并且我没有运行 GDB 时,我无法获得堆栈跟踪...当程序崩溃时,我可以选择在 MSVC 中打开该程序,但 MSVC 无法读取 gcc 的调试符号,因此它给我的堆栈跟踪毫无用处。

Is there a way to get Windows to create a core dump that I can then later open in MinGW's gdb? Alternatively, is there a way to take MSVC's stack trace (which has raw addresses but no symbols) and use gcc to get a human-readable trace?

有没有办法让 Windows 创建一个核心转储,然后我可以在 MinGW 的 gdb 中打开它?或者,有没有办法获取 MSVC 的堆栈跟踪(具有原始地址但没有符号)并使用 gcc 来获取人类可读的跟踪?

采纳答案by sherpya

windows does not create core files (on linux they are dumped by the kernel iirc) you can try to attach with gdb with the crash dialog opened but I doubt it will work

windows 不创建核心文件(在 linux 上它们由内核 iirc 转储)您可以尝试在打开崩溃对话框的情况下使用 gdb 附加,但我怀疑它会起作用

if you use msvc instead you can create a minidump debuggable in visualstudio but there is no way to create same dump with gcc

如果您改用 msvc,则可以在 Visualstudio 中创建一个可调试的小型转储,但无法使用 gcc 创建相同的转储

google made a software that you may find useful, but I'm not sure it can produce stuff with gcc

谷歌制作了一个你可能会觉得有用的软件,但我不确定它是否可以用 gcc 生成东西

http://code.google.com/p/google-breakpad/

http://code.google.com/p/google-breakpad/

or you can set drmingw as jit debugger

或者您可以将 drmingw 设置为 jit 调试器

drmingw -i

I'm sure it is possible to get something like a backtrace also on mingw, since mingw compiled llvm is able to dump a trace

我确信在 mingw 上也有可能得到类似回溯的东西,因为 mingw 编译的 llvm 能够转储跟踪

http://code.google.com/p/backtrace-mingw/

http://code.google.com/p/backtrace-mingw/

looks like simpler but I've not tested it

看起来更简单,但我没有测试过

compile with -g3 (and if you can -O0)

用 -g3 编译(如果可以的话 -O0)