public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/12425] New: Confusing python backtrace on iterator end
@ 2011-01-21 11:11 mjw at redhat dot com
  2011-01-25 21:52 ` [Bug python/12425] " tromey at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mjw at redhat dot com @ 2011-01-21 11:11 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug python/12425] Confusing python backtrace on iterator end
  2011-01-21 11:11 [Bug python/12425] New: Confusing python backtrace on iterator end mjw at redhat dot com
@ 2011-01-25 21:52 ` tromey at redhat dot com
  2011-01-28 17:18 ` tromey at redhat dot com
  2011-01-28 18:35 ` mjw at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at redhat dot com @ 2011-01-25 21:52 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=12425

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com
         AssignedTo|unassigned at sourceware    |tromey at redhat dot com
                   |dot org                     |

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2011-01-25 21:52:25 UTC ---
This works better with cvs head.
I will post some more details tomorrow; I'm not totally
sure whether some of my local patches improve this or not.

-- 
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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug python/12425] Confusing python backtrace on iterator end
  2011-01-21 11:11 [Bug python/12425] New: Confusing python backtrace on iterator end mjw at redhat dot com
  2011-01-25 21:52 ` [Bug python/12425] " tromey at redhat dot com
@ 2011-01-28 17:18 ` tromey at redhat dot com
  2011-01-28 18:35 ` mjw at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at redhat dot com @ 2011-01-28 17:18 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=12425

--- Comment #2 from Tom Tromey <tromey at redhat dot com> 2011-01-28 17:17:54 UTC ---
With cvs head gdb I get:

(gdb) p it
$1 = {
  first = 
    <error reading variable: Cannot access memory at address 0xfffffff5>, 
  second = {
    a = 134524960, 
    b = 1
  }
}

I think that seems a lot more reasonable.

-- 
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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug python/12425] Confusing python backtrace on iterator end
  2011-01-21 11:11 [Bug python/12425] New: Confusing python backtrace on iterator end mjw at redhat dot com
  2011-01-25 21:52 ` [Bug python/12425] " tromey at redhat dot com
  2011-01-28 17:18 ` tromey at redhat dot com
@ 2011-01-28 18:35 ` mjw at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mjw at redhat dot com @ 2011-01-28 18:35 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=12425

--- Comment #3 from Mark Wielaard <mjw at redhat dot com> 2011-01-28 18:35:34 UTC ---
(In reply to comment #2)
> With cvs head gdb I get:
> 
> (gdb) p it
> $1 = {
>   first = 
>     <error reading variable: Cannot access memory at address 0xfffffff5>, 
>   second = {
>     a = 134524960, 
>     b = 1
>   }
> }
> 
> I think that seems a lot more reasonable.

Yes, much more reasonable, thanks.

Although I think it is still a but too verbose.
Ideally (for me) the default would just have a short indicator
(say "<???>") that tells me the value couldn't be determined.
Then if I would like to see why that is (p /v maybe) it would
display all the extra explanations.

-- 
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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-28 18:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-21 11:11 [Bug python/12425] New: Confusing python backtrace on iterator end mjw at redhat dot com
2011-01-25 21:52 ` [Bug python/12425] " tromey at redhat dot com
2011-01-28 17:18 ` tromey at redhat dot com
2011-01-28 18:35 ` mjw at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).