This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA][patch 1/9] Yet another respin of the patch with initial Python support
> From: Tom Tromey <tromey@redhat.com>
> Date: Sat, 26 Jul 2008 11:42:12 -0600
>
> >>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
>
> Daniel> No need to talk about the internal meaning for that part - we can just
> Daniel> talk about interrupting operations with Control-C. I'm not sure how
> Daniel> to explain "other exceptions"; just "other error conditions"?
>
> How about this?
>
> When executing the @code{python} command, uncaught Python exceptions
> are translated to calls to @value{GDBN}'s @code{error} function.
> Conversely, @value{GDBN} exceptions are converted to Python
> exceptions. In particular, a user interrupt (via @kbd{C-c} or by
> typing @kbd{q} at a pagination prompt) is translated to a Python
> @code{KeyboardInterrupt} exception, and other @value{GDBN} exceptions
> -- calls to @code{error} in the C code -- are translated to Python
> @code{RuntimeError}s.
That's a step in the right direction, but only one step; more is
needed to make this palatable to the manual readers who are not GDB
hackers. We cannot mention the `error' function, for example, since
we don't want the reader to read GDB sources to understand what that
means.
Here's something that should explain what I have in mind (details
might be factually incorrect):
When executing the @code{python} command, Python exceptions uncaught
within the Python code are translated to calls to @value{GDBN}
error-reporting mechanism, which terminates the currently executing
command and prints an error message containing the Python exception
name, the associated value, and the Python call stack backtrace at
the point where the exception was raised. Example:
@smallexample
...
@end smallexample
@value{GDBN} errors that happen in GDB commands invoked by Python
code are converted to Python @code{RuntimeError} exceptions. User
interrupts (via @kbd{C-c} or by typing @kbd{q} at a pagination
prompt) is translated to a Python @code{KeyboardInterrupt}
exception. If you catch these exceptions in your Python code, your
exception handler will see @code{RuntimeError} or
@code{KeyboardInterrupt} as the exception type, @code{None} as its
value, and @value{GDBN} backtrace as the traceback.