使用 gdb 进行核心转储分析

2022-01-12 00:00:00 cygwin segmentation-fault gdb c++

我有几个关于核心转储的问题.我在 Windows 上有 gdb,使用 Cygwin.

I have a couple of questions regarding core dumps. I have gdb on Windows, using Cygwin.

  1. 核心转储文件的位置在哪里?它是一个 .exe.stackdump 文件吗?(这是崩溃后生成的唯一文件)我在其他论坛上读到核心转储文件名为core".但我没有看到任何名为core"的文件.

  1. What is the location of core dump file? Is it a.exe.stackdump file? (This is the only file that generated after crash) I read on other forums that the core dump file is named "core". But I don't see any file with name "core".

打开和理解核心转储文件的命令是什么?

What is the command for opening and understanding core dump file?

推荐答案

  1. 您需要配置 Cygwin 以通过包含来生成核心转储

  1. You need to configure Cygwin to produce core dumps by including

error_start=x:path odumper.exe

在您的 CYGWIN 环境变量中(参见 这里 在自卸车"部分了解更多信息).如果你不这样做,你只会得到一个堆栈跟踪――不过,这也可以帮助你诊断问题.

error_start=x:path odumper.exe

in your CYGWIN environment variable (see here in section "dumper" for more information). If you didn't do this, you will only get a stacktrace -- which may also help you in diagnosing the problem, though.

按如下方式启动 gdb 以将其附加到核心转储文件:

Start gdb as follows to attach it to a core dump file:

gdb myexecutable --core=mycorefile

您现在可以使用常用的 gdb 命令来打印堆栈跟踪、检查变量的值等等.

gdb myexecutable --core=mycorefile

You can now use the usual gdb commands to print a stacktrace, examine the values of variables, and so on.

相关文章