9

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

  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".

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

unwind
  • 391,730
  • 64
  • 469
  • 606
avd
  • 13,993
  • 32
  • 78
  • 99

2 Answers2

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

    error_start=x:\path\to\dumper.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.

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

    gdb myexecutable --core=mycorefile

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

Martin B
  • 23,670
  • 6
  • 53
  • 72
  • How to modify cygwin environment variable? – avd Feb 01 '10 at 11:51
  • see http://en.wikipedia.org/wiki/Environment_variable. If you're using Cygwin, I would strongly recommend that you read up on some Unix basics -- you're going to need them. – Martin B Feb 01 '10 at 11:55
  • Actually I know the concept of environment variable. I understood what u r saying, setting environment variable named "error_start". I am asking where should I define the new environment variable? at the same place (my computer->properties->...) ? – avd Feb 01 '10 at 11:58
  • 1
    That's an option -- but a better place is probably in cygwin.bat, since the variable is specific to Cygwin. Or, for testing, just set the variable from the bash shell (using the `export` command) just before you run the executable you're testing. – Martin B Feb 01 '10 at 12:17
  • I did this in cygwin shell before running my executable. "export error_start=/c/cygwin/bin/dumper.exe". Still it did not generate the core file. – avd Feb 01 '10 at 12:34
  • 2
    Try `CYGWIN=error_start=c:\cygwin\bin\dumper.exe`. See also http://www.mail-archive.com/cygwin@cygwin.com/msg77667.html for more advice. – Martin B Feb 01 '10 at 12:37
  • Thank you very much for the answer. Got it finally by adding "set CYGWIN=error_start=c:\cygwin\bin\dumper.exe" – avd Feb 01 '10 at 12:41
  • 2
    When using Bash and `export`, you need to quote the backslashes: `export CYGWIN='error_start=C:\Opt\Cygwin\bin\dumper.exe'` – Lumi Feb 05 '12 at 10:28
2
  1. Yes, cygwin creates a.exe.stackdump files by default. You need to configure it to create cores as well (Martin's answer covers that).
  2. A simple tutorial on core dump debugging can be found here
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395