[gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often

I found a few more places where we can use GDB_PY_HANDLE_EXCEPTION.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Tom de Vries
2024-08-27 09:20:18 +02:00
parent b5070480d7
commit 2f8cd40c37
12 changed files with 14 additions and 29 deletions

View File

@@ -199,8 +199,7 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return NULL;
GDB_PY_HANDLE_EXCEPTION (except);
}
gdbpy_ref<> pc_obj = gdb_py_object_from_ulongest (pc);

View File

@@ -640,8 +640,7 @@ bppy_get_commands (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return NULL;
GDB_PY_HANDLE_EXCEPTION (except);
}
return host_string_to_python_string (stb.c_str ()).release ();

View File

@@ -431,8 +431,7 @@ connpy_send_packet (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return nullptr;
GDB_PY_HANDLE_EXCEPTION (except);
}
}

View File

@@ -389,8 +389,7 @@ frame_info_to_frame_object (const frame_info_ptr &frame)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return NULL;
GDB_PY_HANDLE_EXCEPTION (except);
}
return (PyObject *) frame_obj.release ();
@@ -538,8 +537,7 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return NULL;
GDB_PY_HANDLE_EXCEPTION (except);
}
if (!var)

View File

@@ -59,8 +59,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
/* This readline callback is called without the GIL held. */
gdbpy_gil gil;
gdbpy_convert_exception (except);
return NULL;
GDB_PY_HANDLE_EXCEPTION (except);
}
/* Detect EOF (Ctrl-D). */

View File

@@ -168,8 +168,7 @@ gdbpy_execute_mi_command (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return nullptr;
GDB_PY_HANDLE_EXCEPTION (except);
}
return uiout.result ().release ();

View File

@@ -318,8 +318,7 @@ recpy_bt_insn_decoded (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return NULL;
GDB_PY_HANDLE_EXCEPTION (except);
}
return PyBytes_FromString (strfile.string ().c_str ());

View File

@@ -670,7 +670,6 @@ gdbpy_start_recording (PyObject *self, PyObject *args)
{
const char *method = NULL;
const char *format = NULL;
PyObject *ret = NULL;
if (!PyArg_ParseTuple (args, "|ss", &method, &format))
return NULL;
@@ -678,14 +677,12 @@ gdbpy_start_recording (PyObject *self, PyObject *args)
try
{
record_start (method, format, 0);
ret = gdbpy_current_recording (self, args);
return gdbpy_current_recording (self, args);
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
GDB_PY_HANDLE_EXCEPTION (except);
}
return ret;
}
/* Implementation of gdb.current_recording (self) -> gdb.Record. */

View File

@@ -74,8 +74,7 @@ py_print_bpstat (bpstat *bs, enum gdb_signal stop_signal)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return nullptr;
GDB_PY_HANDLE_EXCEPTION (except);
}
gdbpy_ref<> dict = uiout.result ();

View File

@@ -415,8 +415,7 @@ gdbpy_register_tui_window (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return nullptr;
GDB_PY_HANDLE_EXCEPTION (except);
}
Py_RETURN_NONE;

View File

@@ -2056,8 +2056,7 @@ convert_value_from_python (PyObject *obj)
}
catch (const gdb_exception &except)
{
gdbpy_convert_exception (except);
return NULL;
GDB_PY_HANDLE_EXCEPTION (except);
}
return value;

View File

@@ -972,8 +972,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
catch (const gdb_exception &ex)
{
/* We know this will always throw. */
gdbpy_convert_exception (ex);
return NULL;
GDB_PY_HANDLE_EXCEPTION (ex);
}
if (!sals.empty ())