From b0e7d28eae1fa1a91932e47d8cf5decf96c2bc59 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 22 Dec 2023 11:43:26 -0700 Subject: Remove 'if' from GDB_PY_HANDLE_EXCEPTION This removes the embedded 'if' from GDB_PY_HANDLE_EXCEPTION and GDB_PY_SET_HANDLE_EXCEPTION. I believe this 'if' was necessary with the old gdb try/catch macros, but it no longer is: these should only ever be called from a 'catch' block, where it's already known that an exception was thrown. Simon pointed out, though, that in a few spots, these were in facts called outside of 'catch' blocks. This patch cleans up these spots. I also found one spot where a redundant 'return nullptr' could be removed. --- gdb/python/py-inferior.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'gdb/python/py-inferior.c') diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index caf6c1b..c25519c 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -586,7 +586,6 @@ static PyObject * 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; @@ -625,11 +624,9 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) } catch (gdb_exception &ex) { - except = std::move (ex); + GDB_PY_HANDLE_EXCEPTION (ex); } - GDB_PY_HANDLE_EXCEPTION (except); - Py_RETURN_NONE; } @@ -645,7 +642,6 @@ static PyObject * 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; @@ -702,11 +698,9 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) } 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 -- cgit v1.1