[2/4,gdb/python] Eliminate GDB_PY_SET_HANDLE_EXCEPTION

Message ID 20240827094230.14969-2-tdevries@suse.de
State Superseded
Headers
Series [1/4,gdb/python] Add gdbpy_handle_gdb_exception |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries Aug. 27, 2024, 9:42 a.m. UTC
  Result of:
...
$ search="GDB_PY_SET_HANDLE_EXCEPTION"
$ replace="return gdbpy_handle_gdb_exception<int, -1>"
$ sed -i \
    "s/$search/$replace/" \
    gdb/python/*.c
...

Also remove the now unused GDB_PY_SET_HANDLE_EXCEPTION.

No functional changes.

Tested on x86_64-linux.
---
 gdb/python/py-breakpoint.c       | 14 +++++++-------
 gdb/python/py-cmd.c              |  2 +-
 gdb/python/py-finishbreakpoint.c |  4 ++--
 gdb/python/py-param.c            |  2 +-
 gdb/python/py-utils.c            |  2 +-
 gdb/python/py-value.c            |  4 ++--
 gdb/python/python-internal.h     |  7 -------
 7 files changed, 14 insertions(+), 21 deletions(-)
  

Patch

diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 013c3fadabf..e4f43e930d8 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -207,7 +207,7 @@  bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
     }
   catch (const gdb_exception &except)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   return 0;
@@ -394,7 +394,7 @@  bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
 	}
       catch (const gdb_exception &except)
 	{
-	  GDB_PY_SET_HANDLE_EXCEPTION (except);
+	  return gdbpy_handle_gdb_exception<int, -1> (except);
 	}
 
       if (! valid_id)
@@ -484,7 +484,7 @@  bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
     }
   catch (const gdb_exception &except)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   return 0;
@@ -613,7 +613,7 @@  bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
     }
   catch (const gdb_exception &ex)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (ex);
+      return gdbpy_handle_gdb_exception<int, -1> (ex);
     }
 
   return 0;
@@ -678,7 +678,7 @@  bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure)
     }
   catch (const gdb_exception &ex)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (ex);
+      return gdbpy_handle_gdb_exception<int, -1> (ex);
     }
 
   return 0;
@@ -1054,7 +1054,7 @@  bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   catch (const gdb_exception &except)
     {
       bppy_pending_object = NULL;
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self);
@@ -1595,7 +1595,7 @@  bplocpy_set_enabled (PyObject *py_self, PyObject *newvalue, void *closure)
     }
   catch (const gdb_exception &except)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
   return 0;
 }
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 2ce2c90d805..917b6c823c5 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -541,7 +541,7 @@  cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
     }
   catch (const gdb_exception &except)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   return 0;
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index ed3c4a5d90e..e7059b8977a 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -217,7 +217,7 @@  bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
     }
   catch (const gdb_exception &except)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   if (PyErr_Occurred ())
@@ -317,7 +317,7 @@  bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
     }
   catch (const gdb_exception &except)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   self_bpfinish->py_bp.bp->frame_id = frame_id;
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index e7032f7758c..d7537bb151f 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -885,7 +885,7 @@  parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
   catch (const gdb_exception &except)
     {
       Py_DECREF (self);
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   return 0;
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 47f65f4fd44..17617cbf1a7 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -247,7 +247,7 @@  get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
 	}
       catch (const gdb_exception &except)
 	{
-	  GDB_PY_SET_HANDLE_EXCEPTION (except);
+	  return gdbpy_handle_gdb_exception<int, -1> (except);
 	}
     }
   else
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 37d5716b6d8..e9f151bfa7c 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -997,7 +997,7 @@  value_has_field (struct value *v, PyObject *field)
     }
   catch (const gdb_exception &except)
     {
-      GDB_PY_SET_HANDLE_EXCEPTION (except);
+      return gdbpy_handle_gdb_exception<int, -1> (except);
     }
 
   return has_field;
@@ -1709,7 +1709,7 @@  valpy_nonzero (PyObject *self)
       /* 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);
+      return gdbpy_handle_gdb_exception<int, -1> (ex);
     }
 
   return nonzero;
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index ce365323d27..d3077713ca2 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -939,13 +939,6 @@  class gdbpy_gil
     return gdbpy_handle_gdb_exception<nullptr_t, nullptr> (Exception);	\
   } while (0)
 
-/* 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 {								\
-    return gdbpy_handle_gdb_exception<int, -1> (Exception);	\
-  } while (0)
-
 int gdbpy_print_python_errors_p (void);
 void gdbpy_print_stack (void);
 void gdbpy_print_stack_or_quit ();