Author Topic: problem with debugging  (Read 6950 times)

Offline delta1994

  • Single posting newcomer
  • *
  • Posts: 6
problem with debugging
« 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!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: problem with debugging
« Reply #1 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline delta1994

  • Single posting newcomer
  • *
  • Posts: 6
Re: problem with debugging
« Reply #2 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: problem with debugging
« Reply #3 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline delta1994

  • Single posting newcomer
  • *
  • Posts: 6
Re: problem with debugging
« Reply #4 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: problem with debugging
« Reply #5 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline delta1994

  • Single posting newcomer
  • *
  • Posts: 6
Re: problem with debugging
« Reply #6 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.

Offline delta1994

  • Single posting newcomer
  • *
  • Posts: 6
Re: problem with debugging
« Reply #7 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: problem with debugging
« Reply #8 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.

Offline delta1994

  • Single posting newcomer
  • *
  • Posts: 6
Re: problem with debugging
« Reply #9 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!