[python] [patch] PR 12174 (preserve gdb.GdbError behaviour)

Tom Tromey tromey@redhat.com
Thu May 19 18:11:00 GMT 2011


Sorry about the delay on this.

Tom> It seems to me that what we really want is some unification between the
Tom> Python and GDB exception mechanisms.  That is, a way to preserve the
Tom> exception across the GDB/Python boundary.

Tom> This would provide some benefits; e.g., the current patch loses subtype
Tom> information from the GdbError.

Phil> At this point I'm not sure why this subtype information is relevant.

Suppose the user's Python code defines a new subclass of GdbError that
includes some extra state.  If this is thrown across the gdb boundary,
then with your patch, then when the exception re-enters Python the
subclass and extra state will have been stripped away.

Phil> I was unsure if I should call print_exception in gdb.execute or whether
Phil> just to let the Python exception propagate.

Tom> I think it has to propagate.  If it was ok to print the exception here,
Tom> then we wouldn't need this patch at all.

Phil> This part just merely replicates what the user wants, a gdb.GdbError
Phil> that just prints out a message without a trace-back.  The use case of
Phil> running a script in one way producing one result for exceptions, and
Phil> another way producing another was what I wanted to avoid.

Yes, but maybe the caller wants to catch the exception and ignore it.  I
think the right thing to do here is simply propagate all exceptions.
The caller can either ignore them (letting one of its callers make the
decision) or handle them.  If gdb.execute sometimes prints an exception
trace, then callers have no good way to catch those exceptions (they are
swallowed) or even filter the "good" output from the "bad".

Tom



More information about the Gdb-patches mailing list