Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: AlexisSorbas on December 20, 2005, 04:58:46 pm

Title: how do I debug in C::B ?
Post by: AlexisSorbas 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)
Title: Re: how do I debug in C::B ?
Post by: sethjackson 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. :)
Title: Re: how do I debug in C::B ?
Post by: thomas 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 (http://wiki.codeblocks.org/index.php?title=MinGW_installation) 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... :)
Title: Re: how do I debug in C::B ?
Post by: 280Z28 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 (http://wiki.codeblocks.org/index.php?title=MinGW_installation) 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.
Title: Re: how do I debug in C::B ?
Post by: Urxae 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?
Title: Re: how do I debug in C::B ?
Post by: thomas 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.
Title: Re: how do I debug in C::B ?
Post by: rickg22 on December 20, 2005, 07:11:06 pm
:-o I see now! That's cool! :)
Title: Re: how do I debug in C::B ?
Post by: Michael 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
Title: Re: how do I debug in C::B ?
Post by: yop 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...)
Title: GDB 6.3 seems to be the right thing ....
Post by: AlexisSorbas 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)

Title: Re: how do I debug in C::B ?
Post by: 280Z28 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 )
Title: Re: how do I debug in C::B ?
Post by: grv575 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
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
Title: Re: how do I debug in C::B ?
Post by: thomas 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.

(http://img460.imageshack.us/img460/7715/debug7qf.png)