User forums > General (but related to Code::Blocks)

how I can debug file multiple times without closing cmd?


Dr Wish:
The annoying problem is when I do debug and run my cpp file a cmd will open but I can not debug again because I have to close the cmd.
How I can debug multiple times without closing the cmd every time?

You start debugging with the red right-pointing triangle.  Hover over that for a second.  In the tool-tip that pops up you will see its description as "Debug / Continue".  Start your program using that and when you hit a break-point do what you want to do and then press it again to continue.  First click starts the program with your attached debugger and at a break point(s) subsequent clicks continue execution of your program.

Now i remember i wanted to answer to this question too.

What do you mean by

--- Quote --- I can not debug again because I have to close the cmd
--- End quote ---
Do you want to restart the program within the debugger?

To achieve this there are multiple ways:
1) Write your program in a way you can easily restart it by setting a variable (for example use state machines with the first state reseting all variable to a default value). Now you can simply change this variable in the watches window.

2) If you are on linux you can use the checkpoint feature of gdb: this is not supported by codeblocks yet, so you have to type the commands by hand in the gdb input field at the bottom. I have planed to add this for a long time, but there are other things to fix for gdb first...

3) Jump back to the beginning of main. This can be dangerous, because variables are not initialized like at the startup of your program. This is also not supported by codeblocks directly but you can type "jump main()" in the gdb command line at the bottom...
NOTE: this method has many pitfalls:
* Memory leaks
* does not work on multi threaded apps
* Open files remain open
* ecc....

sorry for the late reply, i hope this helped...


[0] Message Index

Go to full version