User forums > Using Code::Blocks

see content of a vector in debugging

<< < (2/26) > >>

taram:
Hi,

first of all, thank all for your help and replies to my question. Sorry for my delayed answer, but I am here in Calgary and -8h behind European time :)

However, here the code which I was using for testing:

--- Code: ---#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef vector<string> vstr;

int main()
{
    vstr v;
    v.push_back("1. bla bla");
    v.push_back("2. bla bla");
    v.push_back("3. bla bla");

    int a[3] ={11, 22, 33};



    for (unsigned int f = 0; f<3; f++)
    {
        cout <<" a[" << f <<"] = " << a[f];
        cout << " and v[" << f << "] = " << v[f] << endl;
    }

    return 0;
}

--- End code ---

I played around with "Add watches" and I was not able to get a similar debugger output of a string vector compared to the output of a normal array (see screen-shot-1.png).

The only thing which was working for the string vector was the "element view" i.e. "Add wachtes --> v[0] (see screen-shot-1.png).

But  with this method you have to be very carefully, since if you enter a element which does not exist i.e. out of array range, you will get a "segmentation signal" from Code::Blocks. (see v[3] in "wachtes in screen-shot-1.png and signal in screen-shot-2.png). So for me this "element view" method is not a 100% good way, it is more a 80% provisional solution :)

However, it would be very convenient if the debugger would show the string vector similar like the array (see "a" in watches --> screen-shot-1.png).

Thanks

Martin

PS: @ Jens
special thanks to you for providing debian-repository for Code::Blocks.
I use Debain Lenny, and this is a very convenient way to be up to date with Code::Blocks nightly builds.
Small suggestion for your page http://apt.jenslody.de/ :

instead of this line:

--------------------------------------------------------------------------------------------

...The best and easiest way to add my public-key to apt's trustdb is to install the package jens-lody-debian-keyring with your preferred package-manager or apt-get.  ....

--------------------------------------------------------------------------------------------

write it more explicitly like:

--------------------------------------------------------------------------------------------

... The best and easiest way to add my public-key to apt's trustdb is to install the package jens-lody-debian-keyring with

#apt-get-get install jens-lody-debian-keyring

or

#aptitude  install jens-lody-debian-keyring

--------------------------------------------------------------------------------------------

Since most people do not read a web page they skim it.


[attachment deleted by admin]

taram:
Here screen-shot 2, since max. attachment size is 128kb

Martin

[attachment deleted by admin]

Jenna:

--- Quote from: taram on June 07, 2009, 10:49:22 pm ---However, it would be very convenient if the debugger would show the string vector similar like the array (see "a" in watches --> screen-shot-1.png).

--- End quote ---
You are right, but that seems to be a gdb issue and a workaround might not be so easy.


--- Quote from: taram on June 07, 2009, 10:49:22 pm ---PS: @ Jens
special thanks to you for providing debian-repository for Code::Blocks.
I use Debain Lenny, and this is a very convenient way to be up to date with Code::Blocks nightly builds.
Small suggestion for your page http://apt.jenslody.de/ :

--- End quote ---

(Vielen Dank)
Thank you for the suggestion, I just changed my site.

taram:
Yes, it may be an GDB issue, but I have less knowledge about it.

However may be in a future nightly build this issue will be solved... may be this issue should be forwarded to a "GDB geek" of the Code::Blocks developer crew.

Cheers

Martin

taram:
may be these links help....

http://www.stanford.edu/~afn/gdb_stl_utils/

http://help.lockergnome.com/linux/GDB-capabilities-exploring-STL-classes--ftopict279673.html

but this is beyond my "doable", since I am a newbe to GBD. hope some of the C::B developers can use this

cheers

Martin

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version