aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-utils.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-05-20 20:24:49 +0000
committerTom Tromey <tromey@redhat.com>2013-05-20 20:24:49 +0000
commitb86af38a5a769f23d1af78761c654d68703c6237 (patch)
treef0b939b8e2ee986c74feff7b493e679a6a226b10 /gdb/python/py-utils.c
parente19d3afbf8ff364534b0be74980377113082d02f (diff)
downloadgdb-b86af38a5a769f23d1af78761c654d68703c6237.zip
gdb-b86af38a5a769f23d1af78761c654d68703c6237.tar.gz
gdb-b86af38a5a769f23d1af78761c654d68703c6237.tar.bz2
* python/py-inferior.c (gdbpy_inferiors): Update. Hoist
get_addr_from_python calls out of TRY_CATCH. (infpy_write_memory, infpy_search_memory): Likewise. * python/py-utils.c (get_addr_from_python): Return negative value on error. Use TRY_CATCH. * python/python-internal.h (get_addr_from_python): Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
Diffstat (limited to 'gdb/python/py-utils.c')
-rw-r--r--gdb/python/py-utils.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 9188e38..eac161f 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -313,39 +313,46 @@ gdbpy_convert_exception (struct gdb_exception exception)
/* Converts OBJ to a CORE_ADDR value.
- Returns 1 on success or 0 on failure, with a Python exception set. This
- function can also throw GDB exceptions.
+ Returns 0 on success or -1 on failure, with a Python exception set.
*/
int
get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
{
if (gdbpy_is_value_object (obj))
- *addr = value_as_address (value_object_to_value (obj));
+ {
+ volatile struct gdb_exception except;
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ *addr = value_as_address (value_object_to_value (obj));
+ }
+ GDB_PY_SET_HANDLE_EXCEPTION (except);
+ }
else
{
PyObject *num = PyNumber_Long (obj);
gdb_py_ulongest val;
if (num == NULL)
- return 0;
+ return -1;
val = gdb_py_long_as_ulongest (num);
Py_XDECREF (num);
if (PyErr_Occurred ())
- return 0;
+ return -1;
if (sizeof (val) > sizeof (CORE_ADDR) && ((CORE_ADDR) val) != val)
{
PyErr_SetString (PyExc_ValueError,
_("Overflow converting to address."));
- return 0;
+ return -1;
}
*addr = val;
}
- return 1;
+ return 0;
}
/* Convert a LONGEST to the appropriate Python object -- either an