News:

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

Main Menu

how to debug

Started by blut-lecker, August 05, 2006, 05:01:22 PM

Previous topic - Next topic

blut-lecker

i hope u can help me, i know this question isn't directly linked to codeblocks, but i would be happy if somebody could tell me a link to a tutorial, where i can learn to debug, especially if it would be with the codeblocks ide. And yes i know, i debug with the compiler an not with the ide

thx, blut-lecker

sethjackson

Quote from: blut-lecker on August 05, 2006, 05:01:22 PM
i hope u can help me, i know this question isn't directly linked to codeblocks, but i would be happy if somebody could tell me a link to a tutorial, where i can learn to debug, especially if it would be with the codeblocks ide. And yes i know, i debug with the compiler an not with the ide

thx, blut-lecker

Well first of all when you build your project, you have to have the debug symbols turned on for your compiler.

Just build your project with debug symbols on. Turn this on in Project -> Build options -> Compiler. Then build your project. Now do Debug -> Start Debugger. :)

The Debug menu is pretty self explanatory. Just read through the menu options, and if you need more help just ask. :)

HTH

blut-lecker

thx for your help.
if i set a breakpoint and click on run debugger, the console window opens but very fast and closes very fast, is this normal?, if yes why do i need breakpoints?
how can i read the content of a variable?, well i click on edit watches and enter i (my variable int i), so then i click on debugging windows, but i can't see the content of my variable

thx, blut-lecker

sethjackson

#3
Quote from: blut-lecker on August 05, 2006, 05:35:41 PM
thx for your help.
if i set a breakpoint and click on run debugger, the console window opens but very fast and closes very fast, is this normal?, if yes why do i need breakpoints?
how can i read the content of a variable?, well i click on edit watches and enter i (my variable int i), so then i click on debugging windows, but i can't see the content of my variable

thx, blut-lecker

Ok first the breakpoints thing. You did compile with debug symbols on right? One other possibility is that it (your code) doesn't "use" the line you put the breakpoint on.

Try this:

Code (cpp) Select

int main()
{
    int test;

    test = 1;

    return 0;
}


Now put breakpoints on all of the (code) lines (int test, test = 1, return 0). The debugger should "hit" your breakpoint. Also there is this really cool feature that you really should turn on. If you hover over an expression Code::Blocks will show the contents of it. Turn it on here: Settings -> Compiler and debugger -> Debugger -> (can't remember exactly lol) -> Evaluate expression under cursor.

EDIT:

By defualt Code::Blocks show the values of local variables, and function arguments to your local function. :)
Also you can right click on a variable, and tell Code::Blocks to watch it. :)

Make sure you aren't using RC2. There have been some really great improvements to the debugger in the recent nightly builds. :)

blut-lecker

thx a lot, know i know what u mean, because now it works, i've downloaded the cb rc2 version and know it works, it seams, that i've some problems with my nightly build version, or the compiler.
but now i can debug a bit thx a lot

edit:
well i'll try to use the nightly buid version, if it works

sethjackson

Quote from: blut-lecker on August 05, 2006, 06:08:23 PM
thx a lot, know i know what u mean, because now it works, i've downloaded the cb rc2 version and know it works, it seams, that i've some problems with my nightly build version, or the compiler.
but now i can debug a bit thx a lot

edit:
well i'll try to use the nightly buid version, if it works

Yeah nighly builds are waaaay better than RC2. :)

EDIT:

Yup they work. I build Code::Blocks from SVN trunk (Nightly builds are built from trunk too), and it works just fine here. :)

blut-lecker

could u tell me, what mingw version i should download, because, in 5.x.x the debugger isn't included and when i download it seperate it doesn't works, what version do u use?

thx
blut-lecker

blut-lecker

finally, it works also with the nightly build version, i had to use manual installation of mingw.

now finally thx;)

sethjackson

Quote from: blut-lecker on August 05, 2006, 06:12:12 PM
could u tell me, what mingw version i should download, because, in 5.x.x the debugger isn't included and when i download it seperate it doesn't works, what version do u use?

thx
blut-lecker

Well to answer your question I use MingW 3.4.5 (not to be confused with the installer verison), and GDB 6.3.
Also I manually installed MinGW. :)
Your welcome. I'm glad it works now.