Core dump analysis using gdb

16,160

Solution 1

  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.

Solution 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
Share:
16,160

Related videos on Youtube

avd
Author by

avd

Updated on April 15, 2022

Comments

  • avd
    avd about 2 years

    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?

  • avd
    avd over 14 years
    How to modify cygwin environment variable?
  • Martin B
    Martin B over 14 years
    see 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.
  • avd
    avd over 14 years
    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->...) ?
  • Martin B
    Martin B over 14 years
    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.
  • avd
    avd over 14 years
    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.
  • Martin B
    Martin B over 14 years
    Try CYGWIN=error_start=c:\cygwin\bin\dumper.exe. See also mail-archive.com/[email protected]/msg77667.html for more advice.
  • avd
    avd over 14 years
    Thank you very much for the answer. Got it finally by adding "set CYGWIN=error_start=c:\cygwin\bin\dumper.exe"
  • Lumi
    Lumi over 12 years
    When using Bash and export, you need to quote the backslashes: export CYGWIN='error_start=C:\Opt\Cygwin\bin\dumper.exe'