This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: [python] [patch] Pretty printers for std::*::{const_,}iterator
- From: Paul Pluzhnikov <ppluzhnikov at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: archer at sourceware dot org
- Date: Wed, 17 Dec 2008 13:35:08 -0800
- Subject: Re: [python] [patch] Pretty printers for std::*::{const_,}iterator
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1229549710; bh=ltHTdOV/U/iWHP33bH4El5ShS0U=;h=DomainKey-Signature:MIME-Version:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type: Content-Transfer-Encoding; b=yYfaLCAKVETXizeQIAFReBhfC0U/8yJLn3NuhFBCXUtb1A3E71VuIb8ztc/Njei4f3+l0e2uXTnq8DNFN5Z0PA==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=mime-version:in-reply-to:references:date:message-id:subject:from:to:cc:content-type:content-transfer-encoding;b=VILMsNv1cazclemxM5E2EJrmHI4ln8SeX6fKaLBhf6whVf3SsS1V1BnXYfpofjZ8gPWzKIRPsYJFNORJJdSjUQ==
- References: <20081217011710.A2752147635@localhost> <m3ljueo7cm.fsf@fleche.redhat.com>
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