This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [python] [patch] Pretty printers for std::*::{const_,}iterator


On Wed, Dec 17, 2008 at 12:49 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:
>
> Paul> Attached patch allows one to print std::*::iterator as easily as
> Paul> the containers themselves.
>
> Are there iterators where "print *i" does not work?

The "print *i" doesn't work so often in our real code, I was
surprised to find out it sometimes works at all :)

Here is what I see using current archer-tromey-python:

/// -- cut ---
#include <list>
#include <map>
#include <deque>
#include <vector>
#include <string>
#include <stack>
#include <ext/slist>

using namespace std;

int main()
{
    list<int> li;
    list<string> ls;
    vector<int> vi;
    map<int, int> mi;
    map<string, int> msi;
    map<int, string> mis;
    deque<int> di;
    stack<int> si;
    __gnu_cxx::slist<string> lss;

    li.push_back(1);
    vi.push_back(2);
    mi[3] = 4;
    di.push_back(5);
    msi["Hello"] = 6;
    mis[7] = "Hello";
    ls.push_back("Goodby");
    lss.push_front("Xyzzy");
    si.push(7);

    list<int>::iterator lit = li.begin();
    list<int>::const_iterator clit = li.begin();
    list<int>::iterator elit = li.end();
    list<int>::iterator xelit;

    vector<int>::iterator vit = vi.begin();
    vector<int>::const_iterator cvit = vi.begin();

    map<int, int>::iterator mit = mi.begin();
    map<int, int>::const_iterator cmit = mi.begin();

    map<string, int>::iterator msit = msi.begin();
    map<string, int>::const_iterator cmsit = msi.begin();

    map<int, string>::iterator mist = mis.begin();
    map<int, string>::const_iterator cmist = mis.begin();

    deque<int>::iterator dit = di.begin();
    deque<int>::const_iterator cdit = di.begin();

    list<string>::iterator lsit = ls.begin();
    list<string>::const_iterator clsit = ls.begin();

    __gnu_cxx::slist<string>::iterator lssit = lss.begin();
    __gnu_cxx::slist<string>::const_iterator clssit = lss.begin();

    return 0;
}
/// -- cut ---

Compiled with gcc-4.3.1:

(gdb) b 59
Breakpoint 1 at 0x400946: file stl.cc, line 59.
(gdb) r

Breakpoint 1, main () at stl.cc:59
59          return 0;
(gdb) print *lit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *clit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *vit
$1 = (int &) @0x40d2e0: 2
(gdb) print *cvit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *mit
$2 = (class std::pair<int const, int> &) @0x40d320: {first = 3, second = 4}
(gdb) print *cmit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *msit
$3 = (class std::pair<std::basic_string<char, std::char_traits<char>,
      std::allocator<char> > const, int> &) @0x40d380: {first =
{static npos = 18446744073709551615,
    _M_dataplus = {<std::allocator<char>> =
{<__gnu_cxx::new_allocator<char>> = {<No data fields>},
     <No data fields>}, _M_p = 0x40d348 "Hello"}}, second = 6}
(gdb) print *cmsit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *mist
$4 = (class std::pair<int const, std::basic_string<char,
       std::char_traits<char>, std::allocator<char> > > &) @0x40d3c0:
{first = 7, second = {static npos =
    18446744073709551615, _M_dataplus = {<std::allocator<char>> =
{<__gnu_cxx::new_allocator<char>> =
    {<No data fields>}, <No data fields>}, _M_p = 0x40d3f8 "Hello"}}}
(gdb) print *cmist
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *dit
$5 = (int &) @0x40d060: 5
(gdb) print *cdit
$6 = (const int &) @0x40d060: 5
(gdb) print *lsit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *clsit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *lssit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb) print *clssit
One of the arguments you tried to pass to operator* could not be
converted to what the function wants.
(gdb)

So, it doesn't work in 10 out of 16 cases :(


-- 
Paul Pluzhnikov


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]