Author Topic: Using the debugger - watch 'variable'  (Read 36037 times)

Offline noobiept

  • Single posting newcomer
  • *
  • Posts: 8
Using the debugger - watch 'variable'
« 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 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using the debugger - watch 'variable'
« Reply #1 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline noobiept

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using the debugger - watch 'variable'
« Reply #2 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using the debugger - watch 'variable'
« Reply #3 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)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline noobiept

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using the debugger - watch 'variable'
« Reply #4 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...  :(

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Using the debugger - watch 'variable'
« Reply #5 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline noobiept

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using the debugger - watch 'variable'
« Reply #6 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!