Author Topic: how do I debug in C::B ?  (Read 7113 times)

Offline AlexisSorbas

  • Single posting newcomer
  • *
  • Posts: 8
  • alien
how do I debug in C::B ?
« on: December 20, 2005, 04:58:46 pm »
I am a newbee in C::B, but I know msdev in detail, so my question is: how do I debug in C::B ?
is there a tutorial or is C::B not meant to use for debugging (I don't believe so)
The difference between genius and stupidity is that genius has its limits. - Albert Einstein

sethjackson

  • Guest
Re: how do I debug in C::B ?
« Reply #1 on: December 20, 2005, 05:00:53 pm »
You want to know how to debug C::B itself? Install RC2. Fetch the source from SVN. Compile the source. Then debug with GDB. :)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: how do I debug in C::B ?
« Reply #2 on: December 20, 2005, 05:05:20 pm »
Thanks for renaming the topic while I was typing...  :lol:


There is exactly one thing you have to know if you want to use the debugger.

--- Use gdb 6.3 ---

If you use the "recommended stable" version 5.2, the you will try and try and try, and you will end up thinking that you are too stupid to use a debugger. The "unstable" version 6.3 is perfectly stable, and it works.

Download the debugger from the MinGW site (we have a link on the Install MinGW page), and unpack it into the same folder where MinGW lives.
Then start Code::Blocks, compile your application with debugging symbols, set any breakpoints that you like and hit the F-9 key... :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: how do I debug in C::B ?
« Reply #3 on: December 20, 2005, 05:12:56 pm »
Thanks for renaming the topic while I was typing...  :lol:


There is exactly one thing you have to know if you want to use the debugger.

--- Use gdb 6.3 ---

If you use the "recommended stable" version 5.2, the you will try and try and try, and you will end up thinking that you are too stupid to use a debugger. The "unstable" version 6.3 is perfectly stable, and it works.

Download the debugger from the MinGW site (we have a link on the Install MinGW page), and unpack it into the same folder where MinGW lives.
Then start Code::Blocks, compile your application with debugging symbols, set any breakpoints that you like and hit the F-9 key... :)

:( I've been trying and trying and gave up. :(

I have 5.2.1, I'll install 6.3 today and try again.
78 280Z, "a few bolt-ons" - 12.71@109.04
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: how do I debug in C::B ?
« Reply #4 on: December 20, 2005, 05:42:13 pm »
Thanks for renaming the topic while I was typing...  :lol:


There is exactly one thing you have to know if you want to use the debugger.

--- Use gdb 6.3 ---
Wait, that's why I could never get debugging to work properly? :shock:
Installed now, will try if it works later.
Maybe there should be a note about this on the download page, perhaps near the version without MinGW or near the note that win98 users should use 5.2? (Is that still accurate by the way?)

Quote
If you use the "recommended stable" version 5.2, the you will try and try and try, and you will end up thinking that you are too stupid to use a debugger.

Yeah, I'd say that's pretty accurate :oops:. Or at least, to use a debugger in C::B.

By the way, is this a problem in gdb or C::B, or maybe just because C::B expects 6.3?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: how do I debug in C::B ?
« Reply #5 on: December 20, 2005, 05:53:39 pm »
By the way, is this a problem in gdb or C::B, or maybe just because C::B expects 6.3?
It is mostly because of pending breakpoints. gdb 6.3 has them, gdb 5.2 does not.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: how do I debug in C::B ?
« Reply #6 on: December 20, 2005, 07:11:06 pm »
:-o I see now! That's cool! :)

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: how do I debug in C::B ?
« Reply #7 on: December 20, 2005, 09:33:25 pm »
There is exactly one thing you have to know if you want to use the debugger.

--- Use gdb 6.3 ---

Sorry, for the question, but if you use gdb 6.3, then you should have Win2k and up, right? If yes, this would prevent Win98 users to use GDB. Woud this means that Win98 support will be dropped in a near future or just GDB support for Win98 will be dropped?

Michael

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: how do I debug in C::B ?
« Reply #8 on: December 20, 2005, 10:10:05 pm »
If you use the "recommended stable" version 5.2, the you will try and try and try, and you will end up thinking that you are too stupid to use a debugger.
I also thought that I was too stupid to use the debugger. I'm using 5.2.1 I'll get 6.3 when I go to work tommorow. I can see we all had our little problems with debugging  :) (I just hope that I won't have to pop up another message box labeled debug ever again...)
Life would be so much easier if we could just look at the source code.

Offline AlexisSorbas

  • Single posting newcomer
  • *
  • Posts: 8
  • alien
GDB 6.3 seems to be the right thing ....
« Reply #9 on: December 20, 2005, 11:31:40 pm »
Hi all,
thanks a lot for your tipps...
Downloaded GDB 6.3...
Now I think I have to find a document or manpage how to use this thing.
Currently I have absolutly no clue what to do with outputs like the one bellow, but IT DOES SOMETHING !
No idea how to inspect locals, globals, stack ... but I will find out.
If you guys already have more experience please don't hesitate to tell people like me more about ...
I guess codeblocks & mingw & gcc are big tools, but there should be at least a hint how to use all that stuff.
 :D

elt
, 64816
elt
, 34
elt
, 7840
elt
, 36
elt
array-section-end
}
pre-prompt
(gdb)

« Last Edit: December 20, 2005, 11:33:31 pm by AlexisSorbas »
The difference between genius and stupidity is that genius has its limits. - Albert Einstein

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: how do I debug in C::B ?
« Reply #10 on: December 21, 2005, 12:51:43 am »
Everything works like pie now! Definitely something to put on a FAQ page! (like anyone reads those :o )
78 280Z, "a few bolt-ons" - 12.71@109.04
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: how do I debug in C::B ?
« Reply #11 on: December 21, 2005, 02:13:11 am »
From what I've seen, now that CB uses pending breakpoints, you can just set a breakpoint and then hit the Debug / Continue button like any other IDE debugger.  Things to keep in mind when using the CB debugger:

1 Turn on the debugger log (Settings->Debugger Options->Display debugger's log) then close/reopen CB
2*** If the debugger seems frozen, or the Debugger (debug) log shows gdb in an endless loop, then open task manager and kill gdb.exe.  This will end the debugging session when gdb isn't responding (so the Stop Debugger button may not terminate it)

Try this:

1.  Compile the latest svn using CB
2.  run update.bat and then put a breakpoint in plugins\astyle\astyleplugin.cpp on the first line of Execute().
3.  Hit the Debug / Continue button
4.  Give it a minute - debugging an exe takes much longer than running it normally.  Now create a new wxWidgets project somewhere.
5. Open the generated main.cpp and hit Plugins->AStyle.

It should break.  This used to not work, but now gdb 6.3's pending breakpoints are used to make it break in source code that is not yet loaded...

Here's what you should get:
Code: [Select]
Selecting target: src
Compiling: done
Adding source dir: C:\Documents and Settings\coke\Desktop\1\src\
Changing directory to: devel
Adding file: devel\codeblocks.exe
Starting debugger: done
Debugger name and version: GNU gdb 6.3
No source file named C:/DOCUME~1/coke/Desktop/1/src/plugins/astyle/astyleplugin.cpp.
Breakpoint 1 (C:/DOCUME~1/coke/Desktop/1/src/plugins/astyle/astyleplugin.cpp:83) pending.
Pending breakpoint "C:/DOCUME~1/coke/Desktop/1/src/plugins/astyle/astyleplugin.cpp:83" resolved
At C:/DOCUME~1/coke/Desktop/1/src/plugins/astyle/astyleplugin.cpp:83

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: how do I debug in C::B ?
« Reply #12 on: December 21, 2005, 05:21:00 pm »
Boys, don't make it more complicated than it is... :)

Forget that output window. Look at the source code and the watches tab! Yes, it is as easy as that.

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."