Using a stackdump from Cygwin executable
Asked Answered
C

2

26

So I wrote buggy code that occasionally crash ... and creates a stackdump file.

Using addr2line I can figure out how the program got to the crash point by decoding the addresses from the stackdump one by one. Is there an alternative tool that can ease the debug using stack dumps? Is there a way to to load this information in Insight/Gdb?

Courante answered 26/11, 2008 at 7:47 Comment(0)
C
50

You can instruct Cygwin to start your gdb debugger just in time when an fault occurs. To achieve this, add error_start=action to the Cygwin environment variable:
export CYGWIN="$CYGWIN error_start=gdb -nw %1 %2"

Else you can have Cygwin generate a real core dump.
export CYGWIN="$CYGWIN error_start=dumper -d %1 %2"

Courante answered 6/1, 2009 at 9:26 Comment(4)
And run gdb path/to/the/binary path/to/the/core to debug it. Thanks to https://mcmap.net/q/107737/-core-dump-file-analysis-duplicate.Kassey
With this option error_start=gdb -nw %1 %2 enabled, I have gdb running, however quitting gdb just results it in starting again, how I quit it completely?Sheehy
I had to go outside and launch process explorer and kill the entire process tree in Windows.Sheehy
@Sheehy For future reference you can just type "kill" in gdb to kill the debugged process and then "quit" to quit gdb as well.Censer
S
0

Firstly, make sure you build with source debugging enabled (the using -g option):

gcc -g -o myfile myfile.c

Then Load the dump into gdb after the crash (or insight, or ddd)

gdb myfile core
Sherard answered 26/11, 2008 at 8:8 Comment(1)
gdb says that it does not recognize the file (with suffix ".stackdump") as a core dump.Censer

© 2022 - 2024 — McMap. All rights reserved.