public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/12174] New: gdb.GdbError exceptions should not be translated to RuntimeError exceptions
@ 2010-10-31 20:43 markflorisson88 at gmail dot com
  2011-03-21 13:25 ` [Bug python/12174] " pmuldoon at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: markflorisson88 at gmail dot com @ 2010-10-31 20:43 UTC (permalink / raw)
  To: gdb-prs

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

           Summary: gdb.GdbError exceptions should not be translated to
                    RuntimeError exceptions
           Product: gdb
           Version: 7.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned@sourceware.org
        ReportedBy: markflorisson88@gmail.com


When you use gdb.execute() it automatically translates any exception to
RuntimeError. At least for gdb.GdbError it should not do this, as its purpose
is to display a message to the user and not show them a big fat traceback. In
fact, I'm not sure gdb.execute() should translate exceptions at all for errors
originating in Python code.

(gdb) python
>class C(gdb.Command):
>    def invoke(self, *args):
>        raise gdb.GdbError("This is a nonexistent command!")
>C("some-command", gdb.COMMAND_NONE)                                                   
>end
(gdb) some-command
This is a nonexistent command!
(gdb) python gdb.execute("some-command")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: This is a nonexistent command!
Error while executing Python code.
(gdb)

-- 
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] 5+ messages in thread

* [Bug python/12174] gdb.GdbError exceptions should not be translated to RuntimeError exceptions
  2010-10-31 20:43 [Bug python/12174] New: gdb.GdbError exceptions should not be translated to RuntimeError exceptions markflorisson88 at gmail dot com
@ 2011-03-21 13:25 ` pmuldoon at redhat dot com
  2011-03-21 20:15 ` pmuldoon at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pmuldoon at redhat dot com @ 2011-03-21 13:25 UTC (permalink / raw)
  To: gdb-prs

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

Phil Muldoon <pmuldoon at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |pmuldoon at redhat dot com
         AssignedTo|unassigned at sourceware    |pmuldoon at redhat dot com
                   |dot org                     |

-- 
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] 5+ messages in thread

* [Bug python/12174] gdb.GdbError exceptions should not be translated to RuntimeError exceptions
  2010-10-31 20:43 [Bug python/12174] New: gdb.GdbError exceptions should not be translated to RuntimeError exceptions markflorisson88 at gmail dot com
  2011-03-21 13:25 ` [Bug python/12174] " pmuldoon at redhat dot com
@ 2011-03-21 20:15 ` pmuldoon at redhat dot com
  2011-03-21 23:19 ` markflorisson88 at gmail dot com
  2011-03-22  0:11 ` markflorisson88 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: pmuldoon at redhat dot com @ 2011-03-21 20:15 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Phil Muldoon <pmuldoon at redhat dot com> 2011-03-21 20:03:42 UTC ---
It actually took me a few hours of hacking to figure this out.  It's not
really a bug in that you will never have anything that faces Python (ie
can be called from a Python script) that will just print a message and
no stack trace.  gdb.GdbError gets converted to a GDB exception which
has its own handling mechanism within GDB.  When a GDB exception
ends up at the border between the Python API and GDB it gets converted
into a Python exception.  Python has no idea how to deal with a GDB
exception.  So in this case it went from a gdb.GdbError to a GDB
Exception back to a GdbError exception.  This is usless, but
harmless.  This is the case with gdb.execute, gdb.parse_and_eval and
a few other functions.

As far as I know, there is no Python C API to deal specifically
or alter how Python prints backtraces from exceptions.  We seem to be
able to either print it or not.

I'll leave this open for a few days in case you disagree, or know of some other
way to fix the bug. After that will close it.

-- 
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] 5+ messages in thread

* [Bug python/12174] gdb.GdbError exceptions should not be translated to RuntimeError exceptions
  2010-10-31 20:43 [Bug python/12174] New: gdb.GdbError exceptions should not be translated to RuntimeError exceptions markflorisson88 at gmail dot com
  2011-03-21 13:25 ` [Bug python/12174] " pmuldoon at redhat dot com
  2011-03-21 20:15 ` pmuldoon at redhat dot com
@ 2011-03-21 23:19 ` markflorisson88 at gmail dot com
  2011-03-22  0:11 ` markflorisson88 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: markflorisson88 at gmail dot com @ 2011-03-21 23:19 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Mark Florisson <markflorisson88 at gmail dot com> 2011-03-21 23:04:23 UTC ---
(In reply to comment #2)
> Created attachment 5321 [details]
> Preserve Python exception information through GDB code

It seems sourceware forgot about my actual comment, so here goes.

For GDB commands, the C function that is invoking the Python 'invoke' method of
Command subclasses is clearing the exception, decreffing the type, value and
traceback, and is then calling error() with the message string of the Python
exception. At this point all Python information except for the exception
message (in case this was actually a string!) is lost. So instead I propose to
leave the Python error indicator installed, and have
py-utils.c:gdbpy_convert_exception() check if a Python error indicator is set.
If so, it can simply re-raise (i.e., propagate) it.

I attached an untested patch, because unfortunately I don't have archer
compiled at this moment.

-- 
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] 5+ messages in thread

* [Bug python/12174] gdb.GdbError exceptions should not be translated to RuntimeError exceptions
  2010-10-31 20:43 [Bug python/12174] New: gdb.GdbError exceptions should not be translated to RuntimeError exceptions markflorisson88 at gmail dot com
                   ` (2 preceding siblings ...)
  2011-03-21 23:19 ` markflorisson88 at gmail dot com
@ 2011-03-22  0:11 ` markflorisson88 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: markflorisson88 at gmail dot com @ 2011-03-22  0:11 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Mark Florisson <markflorisson88 at gmail dot com> 2011-03-21 22:56:44 UTC ---
Created attachment 5321
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5321
Preserve Python exception information through GDB code

-- 
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] 5+ messages in thread

end of thread, other threads:[~2011-03-22  0:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-31 20:43 [Bug python/12174] New: gdb.GdbError exceptions should not be translated to RuntimeError exceptions markflorisson88 at gmail dot com
2011-03-21 13:25 ` [Bug python/12174] " pmuldoon at redhat dot com
2011-03-21 20:15 ` pmuldoon at redhat dot com
2011-03-21 23:19 ` markflorisson88 at gmail dot com
2011-03-22  0:11 ` markflorisson88 at gmail 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).