Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: noobiept on August 03, 2010, 08:01:29 pm

Title: Using the debugger - watch 'variable'
Post by: noobiept on August 03, 2010, 08:01:29 pm
Hi, I'm trying to use the debugger to find a mistake on my program, and I'm trying to make the program stop at some position and to look up the values of some variables.

I check this entry, http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks (http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks) but I stopped at the part where you are supposed to select a variable, right click and then click "Watch 'variable name'". I just can't see this option there. I don't know if that option is somewhere else, but I just can't find it.

thanks in advance
Title: Re: Using the debugger - watch 'variable'
Post by: oBFusCATed on August 03, 2010, 08:16:18 pm
What about your OS, CB version?

Also you should right click over your variable, if you click at an empty space it won't work, also it won't work if you right click at "obj->member".
Another way to do this is right click in the watches window and then "Add watch" or something like that.
Title: Re: Using the debugger - watch 'variable'
Post by: noobiept on August 03, 2010, 08:55:54 pm
Windows 7 / CB 10.05

Yes, I'm right clicking over the variable.
I tried the add watch but it doesn't show anything on the watches window.
Title: Re: Using the debugger - watch 'variable'
Post by: oBFusCATed on August 04, 2010, 09:48:06 am
Can you provide the debuggers debug log?

Settings -> Compiler and debugger -> Debugger -> Enable debuggers debug log (or something like that)
Title: Re: Using the debugger - watch 'variable'
Post by: noobiept on August 04, 2010, 01:27:00 pm
I checked: 'Display debugger's log' , but then don't know where it is saved.

I read again the wiki entry and find out that you can only add after you start the debug(I'm really inexperient in this).
I didn't understand this the first time I read it. Either way, after I run the debugger, I can do the: Watch 'variable'.

Then when I write something on the program to make it running it terminates normally and in the watches window it says:
tmp1 = No symbol table is loaded. Use the "file" command.

tmp1 is a variable in the program.

It seems this problem its more of a lack of experience on my part. I don't really know how to use the debugger...  :(
Title: Re: Using the debugger - watch 'variable'
Post by: MortenMacFly on August 04, 2010, 01:33:41 pm
It seems this problem its more of a lack of experience on my part. I don't really know how to use the debugger...  :(
Well, first you should start to compile your application with debugging symbols enabled (compiler switch -g) and NOT stripping the symbols (NOT using the compiler switch -s) -> see your project's build options (tab "compiler") accordingly.

After all, the debugger log is another tab in the log panel of C::B, wehre debug informartion about the debug process is piped into. There is no file, it's a UI element.
Title: Re: Using the debugger - watch 'variable'
Post by: noobiept on August 05, 2010, 11:36:31 pm
I did a bit more testing and finally got it working. Its really useful, I'll start using it more.

thanks for the help!