]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/python] Eliminate GDB_PY_SET_HANDLE_EXCEPTION
authorTom de Vries <tdevries@suse.de>
Tue, 24 Sep 2024 11:06:32 +0000 (13:06 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 24 Sep 2024 11:06:32 +0000 (13:06 +0200)
Result of:
...
$ search="GDB_PY_SET_HANDLE_EXCEPTION ("
$ replace="return gdbpy_handle_gdb_exception (-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.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/python/py-breakpoint.c
gdb/python/py-cmd.c
gdb/python/py-finishbreakpoint.c
gdb/python/py-param.c
gdb/python/py-utils.c
gdb/python/py-value.c
gdb/python/python-internal.h

index 43f0e967ee4efdd4037c53f445e391ea32b046a9..1edd55672645d9702c19123452a4a4d29615af9f 100644 (file)
@@ -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 (-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 (-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 (-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 (-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 (-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 (-1, except);
     }
 
   BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self);
@@ -1584,7 +1584,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 (-1, except);
     }
   return 0;
 }
index 731a94d965583e55e6717ca0ff2394b331bf569c..2bb9b8290212732558aee4ba72bd586992a577fe 100644 (file)
@@ -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 (-1, except);
     }
 
   return 0;
index d9f7c895fe7dd83ab15eb45814c6240bcf93abf3..bc53d4ed13d6c59e9b033da63561546136b8b3b0 100644 (file)
@@ -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 (-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 (-1, except);
     }
 
   self_bpfinish->py_bp.bp->frame_id = frame_id;
index 2567061cad2d5263e55f12d27c953787eddadc4c..9741782d3f145d6d1ec8e46a1225e3e535602b97 100644 (file)
@@ -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 (-1, except);
     }
 
   return 0;
index 47f65f4fd441acc060bac9a39e1f48c41b0a93bb..8064cec73a76f85bb251366d541683f519b3ba11 100644 (file)
@@ -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 (-1, except);
        }
     }
   else
index e82a4a84f9437301cfc2d1fa2145a5f907bbecc6..cce7bcbf7cb9d78b80e4ec1d73fcb591a6310b47 100644 (file)
@@ -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 (-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 (-1, ex);
     }
 
   return nonzero;
index a6ee4a927b144d1a115193547f520d9eee3e2524..d723c4d577b1d4ccade84ad15b07a340c234b5bc 100644 (file)
@@ -932,13 +932,6 @@ private:
   PyGILState_STATE m_state;
 };
 
-/* 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 (-1, Exception); \
-  } while (0)
-
 int gdbpy_print_python_errors_p (void);
 void gdbpy_print_stack (void);
 void gdbpy_print_stack_or_quit ();