I am newbie on cygwin(and linux).
When I tried to run my executable file based on C language, segmentation fault occured, and I take stackdump file. but, I don't know how to use it for debugging.
I have been searching for the way how to debug using stackdump file, but I cound't find it. Any small tips are very useful to me. thanks for reading my poor english (english is not my 1st language).
First: you need to compile your program passing to gcc the flag
-ggdb
otherwise the stackdump info is useless. I suggest to pass also the-O0
flag so that debugging with gdb will be more easy as the code will not be optimized.Second: the stackdump provide the addresses present in the stack, in this example on 32bit we have two addresses:
The address can be coming from your programs or from loaded shared libs.
To convert the address to code position, use
addr2line
. Example:In this case the high address told me that the crash was in a shared lib and not in the program. You can use
ldd
to identify to what the addresses belong:If the address is lower than dll's one, it belongs to your program; If it belongs to shared lib you need to installl the relative *debuginfo package for recovering the location information.