ask some gdb skills
I'm a beginer on using gdb debug. Following is the debug process. when enter "c" ,the program is run and printf an prompt to tell me to enter some command ,but how to know where the program is go to? I want the program stop and watch where the program run to. thanks.
You need to "step" or set a "breakpoint" because "continue" (your c command) simply says to continue running and it will run to it hits a "breakpoint". If you are running a GUI, look at "ddd" which is QUI wrapper to gdb.
If you stop the program with ctrl-c when it waiting for you input after the prompt (or indeed whenever you want to stop the program), control will be returned to gdb which will tell you where the program has stopped. You can then continue with the 'c' (continue) gdb command if you want to continue running the program, or run it step by step using the 'n' (next) and 's' (step) gdb commands.
The difference between 'n' and 's' is that 'n' steps to the next line while running function calls at full speed, whereas 's' steps into functions that are called. Often you want to step into function that you have written yourself, but not library calls such as printf.