Code::Blocks Forums

User forums => Help => Topic started by: delta1994 on October 28, 2012, 06:35:05 am

Title: problem with debugging
Post by: delta1994 on October 28, 2012, 06:35:05 am
I have installed the code::blocks with "codeblocks-10.05mingw-setup.exe" downloaded directly from the official website,and when I try to debug my problem,I set a breakpoint at the first line of the main function,which is a function for data-inputting from keyboard.After I clicked the "debug/continue" bottom,the program did not pause at the breakpoint.Instead,it directly asked me to input the data.I have chosen the "debug" model,not the "release" model,and I'm frustrated with this problem.Who can offer me a solution!
Title: Re: problem with debugging
Post by: MortenMacFly on October 28, 2012, 06:55:47 am
post the full build log and the debug log.

BTW: You can also just try a nightly. 10/05 is rather old.
Title: Re: problem with debugging
Post by: delta1994 on October 28, 2012, 07:24:25 am
post the full build log and the debug log.

BTW: You can also just try a nightly. 10/05 is rather old.
build log is as follows.
-------------- Clean: Debug in heapsort ---------------

Cleaned "heapsort - Debug"

-------------- Build: Debug in heapsort ---------------

mingw32-g++.exe -Wall -fexceptions  -g  -O3 -g    -c D:\programs\heapsort\main.cpp -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\heapsort.exe obj\Debug\main.o   
Output size is 579.19 KB
Process terminated with status 0 (0 minutes, 10 seconds)
0 errors, 0 warnings

debugging log is as follows.

Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: D:\programs\heapsort\
Adding source dir: D:\programs\heapsort\
Adding file: bin\Debug\heapsort.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 5.2.1
Program exited normally.
Debugger finished with status 0
(Note:Although I have set a breakpoint,the program did not pause there.)

I want to try the new version,but our teacher insists that we use 10/05.
Title: Re: problem with debugging
Post by: MortenMacFly on October 28, 2012, 08:57:00 am
mingw32-g++.exe -Wall -fexceptions  -g  -O3 -g    -c D:\programs\heapsort\main.cpp -o obj\Debug\main.o
Do not mix optimisation with debug flags and try again (don't forget to re-build the project)... Post the log again here...
Title: Re: problem with debugging
Post by: delta1994 on October 28, 2012, 03:07:47 pm
mingw32-g++.exe -Wall -fexceptions  -g  -O3 -g    -c D:\programs\heapsort\main.cpp -o obj\Debug\main.o
Do not mix optimisation with debug flags and try again (don't forget to re-build the project)... Post the log again here...
I also have set the breakpoints(not these things you quoted),and this is the result of re_build.
Title: Re: problem with debugging
Post by: MortenMacFly on October 28, 2012, 07:48:10 pm
I also have set the breakpoints(not these things you quoted),
? :o

I meant you need to correct your compiler's flags not to mix the debug (-g) with optimisation (-o3) flags. This has nothing to do with debugging in the first place, but compiling correctly for debugging purposes.
Title: Re: problem with debugging
Post by: delta1994 on November 02, 2012, 06:48:33 am
I also have set the breakpoints(not these things you quoted),
? :o

I meant you need to correct your compiler's flags not to mix the debug (-g) with optimisation (-o3) flags. This has nothing to do with debugging in the first place, but compiling correctly for debugging purposes.
Sorry for my misunderstanding.I will try.
Title: Re: problem with debugging
Post by: delta1994 on November 02, 2012, 07:11:53 am
I also have set the breakpoints(not these things you quoted),
? :o

I meant you need to correct your compiler's flags not to mix the debug (-g) with optimisation (-o3) flags. This has nothing to do with debugging in the first place, but compiling correctly for debugging purposes.
I set the debug flags and tried again,but it didn't work as well.
Title: Re: problem with debugging
Post by: Jenna on November 02, 2012, 08:11:11 am
The debug-flag is set (-g), but you also have to remove the optimization flags(s). -O3 in your case.
Debugging optimized code might work or not, depending on whhat the compiler really does, but it's very likely not to work.
Title: Re: problem with debugging
Post by: delta1994 on November 02, 2012, 08:50:25 am
The debug-flag is set (-g), but you also have to remove the optimization flags(s). -O3 in your case.
Debugging optimized code might work or not, depending on whhat the compiler really does, but it's very likely not to work.
With the -o3 removed,it works now.Thank you for your help and patience!