Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug standalone file in Code::Blocks?

I'm programming using Code::Blocks. I set some breakpoints, but Code::Blocks seems to ignore them when I run the program.

By 'start the program' I mean simply clicking build_and_run (Build and run).

I checked under Debug and saw that F8 isn't available (Start / Continue):

Debug_Menu

The program compiles and runs fine, it just ignores breakpoints. Does anybody know how to solve this?

Note: I checked here and I think the suggested answer isn't relevant for me, because in Compiler settings I have just "C:\MinGW" under Compiler's installation directory.

edit:

I'm using Windows 8 (64bit), Code::Blocks 12.11

like image 799
Alaa M. Avatar asked May 03 '14 08:05

Alaa M.


People also ask

How do you debug a single file in Code::Blocks?

In Code::Blocks, go into your Settings menu, then click Compiler . Make sure Global compiler settings is selected in the sidebar, then switch to the Toolchain executables tab. Your Debugger entry should say something like GDB/CDB debugger: default. If it does, OK out of this dialog.

How do you debug line by code in line blocks?

Again click on (Debug-> start/continue) It will show a console window. Put input on it. Now press Enter button. Click on (Debug-> Next line) or press F7 for line by line debugging.

How do you get logs and others in Code::Blocks?

You just need to hit F2 to enable the "log & others" pane.


3 Answers

I guess you were trying to debug a standalone file (file not belonging to a project). Code::Blocks doesn't support debugging such files. Try including the file to be compiled as a part of an empty project or something.

like image 122
Ciado Avatar answered Oct 23 '22 18:10

Ciado


In Code::Blocks, go into your Settings menu, then click Compiler. Make sure Global compiler settings is selected in the sidebar, then switch to the Toolchain executables tab. Your Debugger entry should say something like GDB/CDB debugger: default. If it does, OK out of this dialog.

Go back into the Settings menu and select Debugger. In the GDB/CDB debugger tree on the left, select Default. Make sure the Executable path textbox is set to your gdb.exe - in your case, the correct path will probably be something like C:\MinGW\bin\gdb.exe. Make sure the Debugger Type is set to GDB. Then hit OK.

Now your debugger (GDB) should be set up. Restart Code::Blocks if you like (I've had it glitch out before, crash, and lose whatever settings I changed since last restart), then go into the Debug menu and Start/Continue should be enabled.

like image 26
cf stands with Monica Avatar answered Oct 23 '22 18:10

cf stands with Monica


remember about this: http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks#Path_with_spaces

Breakpoints could not work if the path/folder you've placed your project contains spaces or other special characters. To be safe use English letters, digits and '_'.

like image 3
murison Avatar answered Oct 23 '22 18:10

murison