This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug python/12425] New: Confusing python backtrace on iterator end
- From: "mjw at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Fri, 21 Jan 2011 11:11:39 +0000
- Subject: [Bug python/12425] New: Confusing python backtrace on iterator end
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=12425
Summary: Confusing python backtrace on iterator end
Product: gdb
Version: archer
Status: NEW
Severity: normal
Priority: P2
Component: python
AssignedTo: unassigned@sourceware.org
ReportedBy: mjw@redhat.com
Take the following silly example:
#include <map>
#include <string>
struct foo
{
int a;
int b;
};
int main(int argc, char **argv)
{
std::map<std::string, foo> map;
foo f = { 1, 2 };
map.insert (std::pair<std::string, foo> ("first", f));
std::map<std::string, foo>::iterator it = map.begin ();
it++;
return 0;
}
GNU gdb (GDB) Fedora (7.2-26.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/foo...done.
(gdb) break main
Breakpoint 1 at 0x400b5d: file foo.cpp, line 12.
(gdb) n
The program is not being run.
(gdb) r
Starting program: /tmp/foo
Breakpoint 1, main (argc=1, argv=0x7fffffffe278) at foo.cpp:12
12 std::map<std::string, foo> map;
(gdb) n
14 foo f = { 1, 2 };
(gdb) n
15 map.insert (std::pair<std::string, foo> ("first", f));
(gdb) n
17 std::map<std::string, foo>::iterator it = map.begin ();
(gdb) n
18 it++;
(gdb) p it
$1 = {first = "first", second = {a = 1, b = 2}}
(gdb) n
20 return 0;
(gdb) p it
$2 = {first = Traceback (most recent call last):
File "/usr/lib64/../share/gcc-4.5.1/python/libstdcxx/v6/printers.py", line
549, in to_string
return self.val['_M_dataplus']['_M_p'].lazy_string (length = len)
RuntimeError: Cannot access memory at address 0xffffffffffffffe9
, second = {a = -7944, b = 32767}}
It isn't so much surprising that the printing fails, since we are now at it ==
map.end(). But you might see this sometimes when you forgot, or when taking an
iterator when a map is empty so map.begin () == map.end ().
It would be nice to not get that RuntimeError and partial python backtrace.
It doesn't really add any information, except that the string couldn't be
shown.
Ideally it would detect the iterator ran out and just report that. If that
isn't possible then please don't print these internal python printer errors
that are just confusing and don't add any useful information.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.