Author Topic: Breakpoints don't work  (Read 7399 times)

Offline C:B_newbie

  • Multiple posting newcomer
  • *
  • Posts: 10
Breakpoints don't work
« on: November 29, 2017, 12:57:13 pm »
Hi guys,

I am trying to use the debugger for the first time, I am new to CB and C++ in general.

When I set a Breakpoint, even at the beginning of my program, it simply gets ignored during runtime.

What I tried:
-global compiler settings --> mark "produce debugging symbols",  unmark "strip all symbols from binary"
-build options: --> same.  however, when clicking on 'release' in the tree there, it is marked conversely
-cleared the path to project from all free spaces / non ASCII symbols
-clean+rebuild

I have version 16.01.

I would appreciate the help :)
Regards!

Online Commaster

  • Almost regular
  • **
  • Posts: 171
Re: Breakpoints don't work
« Reply #1 on: November 29, 2017, 01:12:14 pm »
Are you using "Run"? Don't use Run, use the Debug menu -> Start/Continue.

Offline C:B_newbie

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Breakpoints don't work
« Reply #2 on: November 30, 2017, 06:00:26 pm »
Yes I know, I am using the red button, not the green one  :-\
« Last Edit: November 30, 2017, 06:39:23 pm by C:B_newbie »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Breakpoints don't work
« Reply #3 on: November 30, 2017, 06:26:38 pm »
Activate the full debugger log and post the log from the debugger tab here.
To activate full debugger logging: Settings -> Debugger -> Enable full debugger logging

Offline C:B_newbie

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Breakpoints don't work
« Reply #4 on: November 30, 2017, 06:47:49 pm »
Assuming the 'log' is then displayed in the lower part of the GUI where the compiler also gives warnings and so on:

Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Users\2D_Fluid_I\
Adding source dir: C:\Users\2D_Fluid_I\
Adding file: C:\Users\2D_Fluid_I\bin\Debug\2D_Fluid_I.exe
Changing directory to: C:/Users/2D_Fluid_I/.
Set variable: PATH=.;C:\MinGW\bin;C:\MinGW;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\ThinkPad\Bluetooth Software;C:\Program Files\Common Files\Lenovo;C:\Program Files\Common Files\Ulead Systems\Mpeg;C:\Program Files\Windows Live\Shared;C:\Program Files\Lenovo\Client Security Solution;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\OpenVPN\bin;C:\Users\René\AppData\Local\Programs\MiKTeX 2.9\miktex\bin;C:\MinGW\msys\bin;C:\MinGW\lib;C:\MinGW\SFML\lib

[debug]Command-line: C:\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/Users/2D_Fluid_I/bin/Debug/2D_Fluid_I.exe
[debug]Working dir : C:\Users\2D_Fluid_I

Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/Users/2D_Fluid_I/bin/Debug/2D_Fluid_I.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from C:/Users/2D_Fluid_I/bin/Debug/2D_Fluid_I.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.10.1
[debug]Copyright (C) 2015 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "i686-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.10.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> set follow-fork-mode child
[debug]>>>>>>cb_gdb:
[debug]> directory C:/Users/2D_Fluid_I/
[debug]Source directories searched: C:/Users/2D_Fluid_I;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/Users/2D_Fluid_I/main.cpp:147"
[debug]No source file named C:/Users/2D_Fluid_I/main.cpp.
[debug]Breakpoint 2 ("C:/Users/2D_Fluid_I/main.cpp:147") pending.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\Users\2D_Fluid_I\bin\Debug\2D_Fluid_I.exe

Child process PID: 10052

[debug][New Thread 10052.0x23e4]
[debug][Inferior 1 (process 10052) exited with code 03]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 10052) exited with code 03]

[debug]> quit

Debugger finished with status 0

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Breakpoints don't work
« Reply #5 on: November 30, 2017, 09:17:15 pm »
Bleh, this again.

Can you try to run the commands in a gdb started from the command line?
If you do it  can you try the following variations of commands:
Code
> break C:/Users/2D_Fluid_I/main.cpp:147
> break C:\Users\2D_Fluid_I\main.cpp:147
> break "C:\Users\2D_Fluid_I\main.cpp:147"
And share the output of all of them.
Make sure to run all the commands before the break command.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline C:B_newbie

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Breakpoints don't work
« Reply #6 on: December 04, 2017, 02:14:46 pm »
Sorry for the late reply.

What is gdb? Do you want me to enter these lines in a command window? From the system or is there one from Code Blocks?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Breakpoints don't work
« Reply #7 on: December 04, 2017, 06:46:06 pm »
What is gdb? Do you want me to enter these lines in a command window? From the system or is there one from Code Blocks?

gdb is the command to run the GCC Debugger.
Run it from the cmd.exe prompt (command window) 
There is no Code::Blocks command prompt/window; there might be one with what ever compiler you are using.

I do not use the command line debugger enough to give any more advise.

Tim S.
« Last Edit: December 04, 2017, 07:09:18 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline C:B_newbie

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Breakpoints don't work
« Reply #8 on: December 04, 2017, 07:24:34 pm »
Hmm, I would need further instructions on how to run Code Blocks with the Windows terminal :(

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Breakpoints don't work
« Reply #9 on: December 04, 2017, 08:07:14 pm »
Everything you need is in the debug log. Just copy, paste and adjust.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Breakpoints don't work
« Reply #10 on: December 04, 2017, 10:05:59 pm »
I try to describe the steps a bit more in detail, maybe this helps. (also you can learn a bit how to use the debugger with the command line)

1) Test if the debugger is in the path:
1.1) Press the window button and the r key (WIN+r). A window will pop up. Type "cmd" and hit the ENTER key
1.2) Now the console (cmd) pops up with the base path "C:\User\USERNAME". We now have to navigate to the project folder. You can do this by typing "cd PATH\TO\YOUR\PROJECT". You can use the tab key to complete the path. So if your project path is C:\User\USERNAME\Documents\MyProject you can type "cd c:\U" and press the tab key and windows will complete the path to "cd c:\User" then you can enter the \U for the next path "cd c:\User\U" and hit tab and windows will complete to "cd C:\User\USERNAME" and so on. If there are multiple folders with the same name you can hit multiple times tab and windows will cycle through them. Here it is handy to not have any white spaces in your path. I recommend always to not use white spaces in any path.
You should navigate to your project/bin folder where your exe is.
1.3) Now lets start gdb by entering "gdb EXECUTABLENAME"
1.4) If there is a error:
Code
'gdb' is not recognized as an internal or external command,
operable program or batch file.
You have to add gdb to your path:
1.4.1) Search for gdb on your pc. If you have installed the bundled codeblocks with mingw, gdb.exe is in the one subdirectory of the codeblocks installation folder. Search for it and remember the path.
1.4.2) Go back to your cmd window and type "set PATH=%PATH%;PATH_TO_GDB" and hit enter
Now if you type "gdb EXECUTABLENAME" and Enter you should see
Code
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from 123.exe...done.
2) Now you have to enter all commands that codeblocks executes during startup. You can find this commands in the log you posted. The commands are after the line
Code
>>>>>>cb_gdb:
So your log is like this:
Code
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.10.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
you have to enter
Code
set width 0
in the gdb window and press enter. Sadly you have to do this for all commands (not really but for simplicity lets enter all):
Code
set confirm off
set width 0
set height 0
set breakpoint pending on
set print asm-demangle on
set unwindonsignal on
set print elements 0
set new-console on
set disassembly-flavor att
catch throw
source C:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
set follow-fork-mode child
directory C:/Users/2D_Fluid_I/

additionally obfuscated asked you to enter this additional commands at one time (not at the same time, enter one of the following line and go with the next step, after that does not work come back here and try the next line):
Code
break C:/Users/2D_Fluid_I/main.cpp:147
break C:\Users\2D_Fluid_I\main.cpp:147
break "C:\Users\2D_Fluid_I\main.cpp:147"
2.1) Now lets run the debugger by typing
Code
run
and hit enter
2.2) GDB will run now until it hits a breakpoint. You can see if it hits a breakpoint by the following message:
Code
Breakpoint 1, main () at \tmp\123\main.cpp:7
If this worked please tell us the command you entered from the top. If it does not work try a other command from obfuscated.
2.3) To stop gdb simply type "quit" and hit ENTER

I hope this makes things more clear.