When debugging a C program on Code::Blocks 20.03
, I press SHIFT F7
to step into
the program, then I begin pressing F7
to go to the next line
and watch
variables changing in "real time".
But Code::Blocks 20.03's debugger won't enter any functions beside main
, making it pretty useless, or forcing me to not use any function besides main
(a bad programming practice).
How can I make Code::Blocks 20.03's debugger enter the functions too?
CodePudding user response:
- Set a
breakpoint
(red circle) exactly on the line the functionmain
is defined; - Instead of pressing
F8
(the same as clickingDebug->Start/Continue
), which would make the program just run until the last line and exit (only flashing on the screen before disappearing), pressShift F7
(the same as clickingDebug->Step Into
), in order to make the debugger enter the function and not just run it completely and return its result; - Press
F7
(the same as clickingDebug->Next line
) to keep watching the program run "step-by-step"; - When any other function is called, and the debugger is on that line (yellow arrow), you may enter that other function too, by repeating step 2.
Reference: ImageCraft - CodeBlocks Debugger Functions.
Source Line Stepping
Once paused, you can continue execution:
- Debug->Start/Continue runs the program until the next breakpoint.
- Debug->next line runs the program until the next source line. If the current source line contains a function call, it will “step over” the function call.
- Debug->Step into will “step into” a function call, and pause at the next source line.
- Debug->Step out will continue program execution until the function call returns to its caller.
- Debug->Next instruction and Debug->Step into instruction are assembly debugging commands, and should not be used within the CodeBlocks IDE. Instead, the corresponding commands in the ADT should be used.