Author Topic: Debugging Questions  (Read 7240 times)

Offline lehe

  • Multiple posting newcomer
  • *
  • Posts: 35
Debugging Questions
« on: January 28, 2009, 05:14:36 pm »
Hi,
In Code::Blocks 8.02:
1. how can I bring out the output window while debugging? So that I can see the output of cout etc.
2. how to watch all the elements in an array conveniently instead of indexing them one by one in Watch window?
3. is it possible to get the declaration of functions by hovering my mouse over them. Similarly, how can I get the value of a variable by just hovering my mouse over them?
4. I cannot step inside some library functions e.g. GNU C library functions though I think I should be able to. Neither can I get the declaration of the functions. How to deal with it?

Another question is with gdb not Codeblocks at all. In the following code:

  for(int i = 0; i < argc; i++)
    cout << (i > 0 ? "  " : "") << argv << (i < argc - 1 ? " \\" : "")
         << endl;

I try to use next to step over, but always step into some other source file as I get the information:

517      __ostream_insert(__out, __s,
(gdb)
444         { return __check_facet(_M_ctype).widen(__c); }
(gdb)
53         if (!__f)
(gdb)
873      if (_M_widen_ok)
(gdb)
1169        __tmp[__i] = __i;
(gdb)
1168      for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
(gdb)
1169        __tmp[__i] = __i;
(gdb)
1168      for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
(gdb)
1169        __tmp[__i] = __i;

If I try to step out, I get:

(gdb) finish
"finish" not meaningful in the outermost frame.

Thanks for your help!
« Last Edit: January 28, 2009, 05:34:46 pm by lehe »

Offline lehe

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Debugging Questions
« Reply #1 on: January 29, 2009, 04:33:27 pm »
Can anyone help with some of my questions please? Thanks a lot!

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Debugging Questions
« Reply #2 on: January 29, 2009, 09:39:42 pm »
1. how can I bring out the output window while debugging? So that I can see the output of cout etc.
2. how to watch all the elements in an array conveniently instead of indexing them one by one in Watch window?
3. is it possible to get the declaration of functions by hovering my mouse over them. Similarly, how can I get the value of a variable by just hovering my mouse over them?
4. I cannot step inside some library functions e.g. GNU C library functions though I think I should be able to. Neither can I get the declaration of the functions. How to deal with it?

Another question is with gdb not Codeblocks at all. In the following code:

  for(int i = 0; i < argc; i++)
    cout << (i > 0 ? "  " : "") << argv << (i < argc - 1 ? " \\" : "")
         << endl;

I try to use next to step over, but always step into some other source file as I get the information:


1.  Make sure you have declared your app as "Console application" in the projects "Properties -> Build targets -> Debug -> Type:" (right click your project in the management pane.

2. try to add it to the watches window, right click it, chose "Edit watch" and check "Watch as array". "Start:" is the startindex, you want to see, "Count:" the number of elements to be shown. You might want to change "Settings -> Compiler and debugger -> Debugger settings -> Display array on a single line -> If number ..." to fit your needs.

3. On the same tab (see 3.) you can check "Evaluate expressions under cursor".

4. To step into system libs, you need the debugging versions to be installed and link your app against them.

gdb works fine with your code on my machine (compiled with gcc 4.2 on debian unstable/experimental 64-bit). Do you have debugging versions of the standard C/C++ and or system libs installed ?

To your knowledge, I did not test it with 8.02, but with svn r5422.

Offline lehe

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Debugging Questions
« Reply #3 on: January 30, 2009, 12:30:45 am »
Hi Jens,
Many thanks again!

Is it possible to get the declaration of a function by just using mouse hovering over it in Code::Blocks?

Is it possible to specify Source Directories of some library for debugging in Code::Blocks?

I think I might want to upgrade my Codeblocks from 8.02 to some higher version. I did not find the version you mentioned in this forum or your website. In your website for version  8.02svn5382 http://apt.jenslody.de/pool/main/c/codeblocks/,  are all those files needed for installation except those named with amd64 for my ubuntu is 32bit?

Regarding the last question of GDB, what I want is not to step into the implementation of cout in C++ standard library, but to step over by using "next", however I still ends up with stepping-into and cannot step-out by using "finish".

Thanks in advance!
« Last Edit: January 30, 2009, 05:46:37 pm by lehe »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Debugging Questions
« Reply #4 on: January 30, 2009, 05:57:44 pm »
I think I might want to upgrade my Codeblocks from 8.02 to some higher version. I did not find the version you mentioned in this forum or your website. In your website for version  8.02svn5382 http://apt.jenslody.de/pool/main/c/codeblocks/,  are all those files needed for installation except those named with amd64 for my ubuntu is 32bit?

No, just put setup your apt-configuration as described on my site.

The package codeblocks is needed of course and codeblocks-contrib is highly recommended (it includes for example wxSmith), if you choses this two packages if (for example) synaptic, the pacjkages they depend on will be installed automatically.

Depending on your ubuntu-version, you might have to add the apt.wxwidgets.org archive to your package sources file, too.
You should have a look here to make sure you use the correct archive (not the debian-etch one) on wxwidgets.org : http://wiki.wxpython.org/InstallingOnUbuntuOrDebian

Offline lehe

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Debugging Questions
« Reply #5 on: February 01, 2009, 06:26:20 am »
Thanks! I just installed svn5382. 

I still have some difficulty. While using some libraries,  I often want to see declarations of their functions.  For some of them, I right-click and try jumping to their declarations but nothing is found, even if the include directories have been correctly specified and the header files have been successfully found by the compiler. Also placing the mouse on functions sometimes don't give declaration. What should I do?

Regards!
« Last Edit: February 01, 2009, 06:31:59 am by lehe »