Re: Python: fetch value when building gdb.Value object

Tom Tromey
2011-10-04T15:43:11Z

>>>>> "Paul" == Paul Koning <paulkoning@comcast.net> writes:

Paul> The first of those two has a traceback because the gdb.Value
Paul> arithmetic operations have a TRY_CATCH in them. The second one
Paul> has no traceback because the "nonzero" method of gdb.Value doesn't
Paul> do TRY_CATCH.

It is a bug that nonzero doesn't use TRY_CATCH.

In the Python-facing code, the rule is that any calls into gdb proper
which may throw must be wrapped in TRY_CATCH and then must have
exception-conversion code, usually just GDB_PY_HANDLE_EXCEPTION.

This rule is needed to interface properly between gdb exceptions (which
longjmp) and Python exceptions (which do not). Omitting it can lead, I
believe, to crashes.

Tom