Author Topic: Codeblocks degugging with watch window?  (Read 11404 times)

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Codeblocks degugging with watch window?
« on: March 09, 2014, 08:20:45 am »
Hi
I know this is a very common problem as I can find questions about it all over the web.  I'm using Code::blocks 13.12.  I downloaded this as the setup file which also incorporates MinGW for windows xp.

I know how to open the watch window via the menu and I have typed in the name of the variables I want to watch (hitting enter after each one).  I then set breakpoints at each variable and run the debugger.  No windows pop up to display the variable value, just a small window asking me if I want to save this debugging configuration as a default.

I noticed that after I run the debugger and it stops at the break point I can right click on the variable I'm watching (in my code) and see the item 'watch (variable name)'   so I click on this and it creates another identical variable in the watch window (the one I just typed into the watch window).

The little button which appears beside the variable in the watch window can't be accessed while the debugger is running though if I open the watch windows 'watch raw (variable name's) value' nothing is displayed in this box until the end of the process.  At the end of the debugging process I get the message
"No symbol table is loaded.  Use the "file" command."  .  I have checked the menu item under view and gone to perspectives where I can see the options GDB:CDB Debugger Default and Codeblocks default.  I've tried running the debugger with either selected but it doesn't make any difference.

Would anyone know what I'm doing wrong? 

Thanks


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12006
    • Travis build status
Re: Codeblocks degugging with watch window?
« Reply #1 on: March 09, 2014, 12:11:27 pm »
Can you post the full debugger's log? (you have to enable it in the settings)

Keep in mind that:
1. you can inspect values of variables only when C::B has stopped on a breakpoint
2. the variable must be in scope to be inspected

Have you look at this page: http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks
(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 dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codeblocks degugging with watch window?
« Reply #2 on: March 10, 2014, 04:23:22 am »
Hi
Thanks for coming back.  Your link was a big help.  A few points I didn't read over before has fixed the problem.  It was in my build option settings I hadn't selected -g or turned off optimization.

Also, my project file path had spaces in it, so the break points weren't working.
I enabled the debuggers log as you asked above.  Just wanted to see what it would display. I've pasted it below just for the exercise.    

I'm just wondering, I've copied this from the Debugger tab next to the Cscope tab.  I thought there may have been an html file output like the build log does.  There doesn't seem to be, should there be?
There's a bit of extra junk below too :-\.

Also... I can't delete my old watches from the watch window.  I right click on the window and select 'Delete all' and nothing happens.  Every new project contains these old watches.   Would you know what the problem is?   

Code: [Select]
Building to ensure sources are up-to-date
Selecting target:
Release
Adding source dir: C:\CodeBlocksFiles\testDebugger\
Adding source dir: C:\CodeBlocksFiles\testDebugger\
Adding file: C:\CodeBlocksFiles\testDebugger\bin\Release\testDebugger.exe
Changing directory to: C:/CodeBlocksFiles/testDebugger/.
[debug]Command-line: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/CodeBlocksFiles/testDebugger/bin/Release/testDebugger.exe
[debug]Working dir : C:\CodeBlocksFiles\testDebugger

Starting debugger: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/CodeBlocksFiles/testDebugger/bin/Release/testDebugger.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from C:\CodeBlocksFiles\testDebugger\bin\Release\testDebugger.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.1
[debug]Copyright (C) 2013 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/CodeBlocksFiles/testDebugger/
[debug]Source directories searched: C:/CodeBlocksFiles/testDebugger;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/CodeBlocksFiles/testDebugger/main.cpp:10"
[debug]Breakpoint 2 at 0x4013bb: file C:\CodeBlocksFiles\testDebugger\main.cpp, line 10.
[debug]>>>>>>cb_gdb:
[debug]> break "C:/CodeBlocksFiles/testDebugger/main.cpp:11"
[debug]Breakpoint 3 at 0x4013f1: file C:\CodeBlocksFiles\testDebugger\main.cpp, line 11.
[debug]>>>>>>cb_gdb:
[debug]> break "C:/CodeBlocksFiles/testDebugger/main.cpp:16"
[debug]Breakpoint 4 at 0x401472: file C:\CodeBlocksFiles\testDebugger\main.cpp, line 16.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:/CodeBlocksFiles/testDebugger/bin/Release/testDebugger.exe

Child process PID: 2352

[debug][New Thread 2352.0xa74]
[debug]Breakpoint 2, main () at C:\CodeBlocksFiles\testDebugger\main.cpp:10
[debug]C:\CodeBlocksFiles\testDebugger\main.cpp:10:126:beg:0x4013bb
[debug]>>>>>>cb_gdb:

At C:\CodeBlocksFiles\testDebugger\main.cpp:10

[debug]> info locals
[debug]a = {
[debug]  static npos = <optimized out>,
[debug]  _M_dataplus = {
[debug]    <std::allocator<char>> = {
[debug]      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
[debug]    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
[debug]    _M_p = 0x3e2adc "Test1"
[debug]  }
[debug]}
[debug]b = {
[debug]  static npos = <optimized out>,
[debug]  _M_dataplus = {
[debug]    <std::allocator<char>> = {
[debug]      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
[debug]    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
[debug]    _M_p = 0x22ffe0 "|xw\201|"
[debug]  }
[debug]}
[debug]c = 2009288233
[debug]d = -1
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> whatis d
[debug]type = int
[debug]>>>>>>cb_gdb:
[debug]> output d
[debug]-1>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.
[debug]Breakpoint 3, main () at C:\CodeBlocksFiles\testDebugger\main.cpp:11
[debug]C:\CodeBlocksFiles\testDebugger\main.cpp:11:151:beg:0x4013f1
[debug]>>>>>>cb_gdb:

At C:\CodeBlocksFiles\testDebugger\main.cpp:11

[debug]> info locals
[debug]a = {
[debug]  static npos = <optimized out>,
[debug]  _M_dataplus = {
[debug]    <std::allocator<char>> = {
[debug]      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
[debug]    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
[debug]    _M_p = 0x3e2adc "Test1"
[debug]  }
[debug]}
[debug]b = {
[debug]  static npos = <optimized out>,
[debug]  _M_dataplus = {
[debug]    <std::allocator<char>> = {
[debug]      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
[debug]    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
[debug]    _M_p = 0x3e2b0c "Test2"
[debug]  }
[debug]}
[debug]c = 2009288233
[debug]d = -1
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> whatis d
[debug]type = int
[debug]>>>>>>cb_gdb:
[debug]> output d
[debug]-1>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.
[debug]Breakpoint 4, main () at C:\CodeBlocksFiles\testDebugger\main.cpp:16
[debug]C:\CodeBlocksFiles\testDebugger\main.cpp:16:255:beg:0x401472
[debug]>>>>>>cb_gdb:

At C:\CodeBlocksFiles\testDebugger\main.cpp:16

[debug]> info locals
[debug]a = {
[debug]  static npos = <optimized out>,
[debug]  _M_dataplus = {
[debug]    <std::allocator<char>> = {
[debug]      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
[debug]    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
[debug]    _M_p = 0x3e2adc "Test1"
[debug]  }
[debug]}
[debug]b = {
[debug]  static npos = <optimized out>,
[debug]  _M_dataplus = {
[debug]    <std::allocator<char>> = {
[debug]      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
[debug]    members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
[debug]    _M_p = 0x3e2b0c "Test2"
[debug]  }
[debug]}
[debug]c = 1
[debug]d = 2
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> whatis d
[debug]type = int
[debug]>>>>>>cb_gdb:
[debug]> output d
[debug]2>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.
[debug][Inferior 1 (process 2352) exited normally]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 2352) exited normally]

[debug]> quit

Debugger finished with status 0
« Last Edit: March 10, 2014, 04:38:42 am by dominover »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12006
    • Travis build status
Re: Codeblocks degugging with watch window?
« Reply #3 on: March 10, 2014, 10:33:57 am »
There doesn't seem to be, should there be?
No

There's a bit of extra junk below too :-\.
Disable the debug log again.

Also... I can't delete my old watches from the watch window.  I right click on the window and select 'Delete all' and nothing happens.  Every new project contains these old watches.   Would you know what the problem is?   
Are they named "Function arguments" and "Locals"? If yes they cannot be deleted, but you can disable them in the settings.
(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!]