gdb::unique_xmalloc_ptr<char> exp_holder;
const char *exp = NULL;
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
- struct gdb_exception except;
BPPY_SET_REQUIRE_VALID (self_bp);
}
catch (gdb_exception &ex)
{
- except = std::move (ex);
+ GDB_PY_SET_HANDLE_EXCEPTION (ex);
}
- GDB_PY_SET_HANDLE_EXCEPTION (except);
-
return 0;
}
bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure)
{
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
- struct gdb_exception except;
BPPY_SET_REQUIRE_VALID (self_bp);
}
catch (gdb_exception &ex)
{
- except = std::move (ex);
+ GDB_PY_SET_HANDLE_EXCEPTION (ex);
}
- GDB_PY_SET_HANDLE_EXCEPTION (except);
-
return 0;
}
infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
{
inferior_object *inf = (inferior_object *) self;
- struct gdb_exception except;
Py_ssize_t buf_len;
const gdb_byte *buffer;
CORE_ADDR addr, length;
}
catch (gdb_exception &ex)
{
- except = std::move (ex);
+ GDB_PY_HANDLE_EXCEPTION (ex);
}
- GDB_PY_HANDLE_EXCEPTION (except);
-
Py_RETURN_NONE;
}
infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
{
inferior_object *inf = (inferior_object *) self;
- struct gdb_exception except;
CORE_ADDR start_addr, length;
static const char *keywords[] = { "address", "length", "pattern", NULL };
PyObject *start_addr_obj, *length_obj;
}
catch (gdb_exception &ex)
{
- except = std::move (ex);
+ GDB_PY_HANDLE_EXCEPTION (ex);
}
- GDB_PY_HANDLE_EXCEPTION (except);
-
if (found)
return gdb_py_object_from_ulongest (found_addr).release ();
else
catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
- return nullptr;
}
}
static PyObject *
valpy_getitem (PyObject *self, PyObject *key)
{
- struct gdb_exception except;
value_object *self_value = (value_object *) self;
gdb::unique_xmalloc_ptr<char> field;
struct type *base_class_type = NULL, *field_type = NULL;
}
catch (gdb_exception &ex)
{
- except = std::move (ex);
+ GDB_PY_HANDLE_EXCEPTION (ex);
}
- GDB_PY_HANDLE_EXCEPTION (except);
-
return result;
}
static int
valpy_nonzero (PyObject *self)
{
- struct gdb_exception except;
value_object *self_value = (value_object *) self;
struct type *type;
int nonzero = 0; /* Appease GCC warning. */
}
catch (gdb_exception &ex)
{
- except = std::move (ex);
+ /* This is not documented in the Python documentation, but if
+ this function fails, return -1 as slot_nb_nonzero does (the
+ default Python nonzero function). */
+ GDB_PY_SET_HANDLE_EXCEPTION (ex);
}
- /* This is not documented in the Python documentation, but if this
- function fails, return -1 as slot_nb_nonzero does (the default
- Python nonzero function). */
- GDB_PY_SET_HANDLE_EXCEPTION (except);
-
return nonzero;
}
PyGILState_STATE m_state;
};
-/* Use this after a TRY_EXCEPT to throw the appropriate Python
- exception. */
+/* Use this in a 'catch' block to convert the exception to a Python
+ exception and return nullptr. */
#define GDB_PY_HANDLE_EXCEPTION(Exception) \
do { \
- if (Exception.reason < 0) \
- { \
- gdbpy_convert_exception (Exception); \
- return NULL; \
- } \
+ gdbpy_convert_exception (Exception); \
+ return nullptr; \
} while (0)
-/* Use this after a TRY_EXCEPT to throw the appropriate Python
- exception. This macro is for use inside setter functions. */
+/* Use this in a 'catch' block to convert the exception to a Python
+ exception and return -1. */
#define GDB_PY_SET_HANDLE_EXCEPTION(Exception) \
do { \
- if (Exception.reason < 0) \
- { \
- gdbpy_convert_exception (Exception); \
- return -1; \
- } \
+ gdbpy_convert_exception (Exception); \
+ return -1; \
} while (0)
int gdbpy_print_python_errors_p (void);