[PATCH v2] [gdb/python] Make sure python sys.exit makes gdb exit

Tom Tromey tom@tromey.com
Fri Sep 20 20:03:36 GMT 2024


>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> +  else if (fetched_error.type_matches (PyExc_SystemExit))
Tom> +    {
Tom> +      gdbpy_ref<> value (fetched_error.value ());

Here it's more normal to write 'value = fetched_error.value ()'.

Tom> +      gdbpy_ref<> code (PyObject_GetAttrString (value.get (), "code"));

PyObject_GetAttrString can fail.  In this case it will be
NULL... and I don't think it's valid to call PyLong_Check (below)
without checking for this first.

Often in Python an unattended error result will result in a crash.

Tom> +	  /* Code == None: exit status is 0.  */

gdb style uses "CODE" to refer the value.

Tom


More information about the Gdb-patches mailing list