News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

problem with debugging

Started by delta1994, October 28, 2012, 06:35:05 AM

Previous topic - Next topic

delta1994

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!

MortenMacFly

post the full build log and the debug log.

BTW: You can also just try a nightly. 10/05 is rather old.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

delta1994

Quote from: 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.
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.

MortenMacFly

Quote from: delta1994 on October 28, 2012, 07:24:25 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

delta1994

Quote from: MortenMacFly on October 28, 2012, 08:57:00 AM
Quote from: delta1994 on October 28, 2012, 07:24:25 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...
I also have set the breakpoints(not these things you quoted),and this is the result of re_build.

MortenMacFly

Quote from: delta1994 on October 28, 2012, 03:07:47 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

delta1994

Quote from: MortenMacFly on October 28, 2012, 07:48:10 PM
Quote from: delta1994 on October 28, 2012, 03:07:47 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.
Sorry for my misunderstanding.I will try.

delta1994

Quote from: MortenMacFly on October 28, 2012, 07:48:10 PM
Quote from: delta1994 on October 28, 2012, 03:07:47 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.
I set the debug flags and tried again,but it didn't work as well.

Jenna

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.

delta1994

Quote from: jens 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.
With the -o3 removed,it works now.Thank you for your help and patience!