/* GDB parameters implemented in Python
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "completer.h"
#include "language.h"
#include "arch-utils.h"
-#include "py-ref.h"
/* Parameter constants and their values. */
struct parm_constant
/* A union that can hold anything described by enum var_types. */
union parmpy_variable
{
- /* Hold an integer value, for boolean and integer types. */
+ /* Hold a boolean value. */
+ bool boolval;
+
+ /* Hold an integer value. */
int intval;
/* Hold an auto_boolean. */
cmp = PyObject_IsTrue (value);
if (cmp < 0)
return -1;
- self->value.intval = cmp;
+ self->value.boolval = cmp;
break;
case var_auto_boolean:
{
set_doc_string = call_doc_function (obj, set_doc_func.get (), NULL);
if (! set_doc_string)
- {
- gdbpy_print_stack ();
- return;
- }
+ gdbpy_handle_exception ();
}
const char *str = set_doc_string.get ();
case var_boolean:
add_setshow_boolean_cmd (cmd_name, cmdclass,
- &self->value.intval, set_doc, show_doc,
+ &self->value.boolval, set_doc, show_doc,
help_doc, get_set_value, get_show_value,
set_list, show_list);
Py_INCREF (self);
- TRY
+ try
{
add_setshow_generic (parmclass, (enum command_class) cmdtype,
cmd_name, obj,
set_doc.get (), show_doc.get (),
doc.get (), set_list, show_list);
}
- CATCH (except, RETURN_MASK_ALL)
+ catch (const gdb_exception &except)
{
xfree (cmd_name);
Py_DECREF (self);
- PyErr_Format (except.reason == RETURN_QUIT
- ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
- "%s", except.message);
+ gdbpy_convert_exception (except);
return -1;
}
- END_CATCH
return 0;
}