I have a c project compiled with GCC.When I run my test.exe program ends with "test.exe has stopped working" but compiled successfully.How can I debug my program and how can find where is my mistake?
Technique 1: I tried to printf("Successful 1..."),printf("Successful 2...") on the beginning of every single line of code but this method is frustrating.Are there tools(gdb...) to debug my code line by line for me?
printf("Successful 1...")
//code
printf("Successful 2...")
//code
How can I debug my program line by line with GDB? Can I go to the error line directly with GDB?
Edit 1: I use gdb and type run command and get following output which is not helpful(segmentation fault but where?):
Starting program: C:\Users\q\..././bin/test.exe
[New Thread 3292.0x22b8]
[New Thread 3292.0x1fb8]
Program received signal SIGSEGV, Segmentation fault.
0x7696e3e3 in ungetwc () from C:\WINDOWS\SysWOW64\msvcrt.dll
Edit 2: How to debug using gdb? doesn't contain helpful answer to my question.Not possible duplicate of my answer
Edit 3:(bt method output) I have program that contain 6 source and 6 header files.And every header and source files contain three and more than function pointers that perform some action.I tried debug with gdb bt and get following output:
#1 0x00000001 in ?? ()
#2 0x00000073 in ?? ()
#3 0x00000032 in ?? ()
#4 0x00000000 in ?? ()
My makefile:
all: compile run
compile :
gcc -I ./include/ -o ./lib/... .o -c ./src/... .c
gcc -I ./include/ -o ./lib/... .o -c ./src/... .c
gcc -I ./include/ -o ./lib/... .o -c ./src/... .c
gcc -I ./include/ -o ./lib/... .o -c ./src/... .c
gcc -I ./include/ -o ./lib/... .o -c ./src/... .c
gcc -I ./include/ -o ./bin/test ./lib/... .o ./lib/... .o ./lib/... .o ./lib/... .o ./lib/... .o ./src/test.c
run:
gdb ./bin/test.exe