Author Topic: how to debug  (Read 6168 times)

blut-lecker

  • Guest
how to debug
« 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

sethjackson

  • Guest
Re: how to debug
« Reply #1 on: August 05, 2006, 05:14:36 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

  • Guest
Re: how to debug
« Reply #2 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

sethjackson

  • Guest
Re: how to debug
« Reply #3 on: August 05, 2006, 05:41:24 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
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. :)
« Last Edit: August 05, 2006, 05:43:40 pm by sethjackson »

blut-lecker

  • Guest
Re: how to debug
« Reply #4 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

sethjackson

  • Guest
Re: how to debug
« Reply #5 on: August 05, 2006, 06:10:28 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

  • Guest
Re: how to debug
« Reply #6 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

blut-lecker

  • Guest
Re: how to debug
« Reply #7 on: August 05, 2006, 06:57:13 pm »
finally, it works also with the nightly build version, i had to use manual installation of mingw.

now finally thx;)

sethjackson

  • Guest
Re: how to debug
« Reply #8 on: August 06, 2006, 02:28:40 am »
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.