105 if (PyString_Check (attr_name)
107 && ! PyUnicode_CompareWithASCIIString (attr_name,
"value"))
109 && ! strcmp (PyString_AsString (attr_name),
"value"))
117 return PyObject_GenericGetAttr (obj, attr_name);
135 ||
value != Py_None))
137 PyErr_SetString (PyExc_RuntimeError,
138 _(
"String required for filename."));
142 if (
value == Py_None)
144 xfree (self->value.stringval);
146 self->value.stringval = xstrdup (
"");
148 self->value.stringval = NULL;
157 xfree (self->value.stringval);
158 self->value.stringval =
string.release ();
168 PyErr_SetString (PyExc_RuntimeError,
169 _(
"ENUM arguments must be a string."));
177 for (i = 0;
self->enumeration[i]; ++i)
178 if (! strcmp (self->enumeration[i], str.get ()))
180 if (! self->enumeration[i])
182 PyErr_SetString (PyExc_RuntimeError,
183 _(
"The value must be member of an enumeration."));
186 self->value.cstringval =
self->enumeration[i];
191 if (! PyBool_Check (
value))
193 PyErr_SetString (PyExc_RuntimeError,
194 _(
"A boolean argument is required."));
197 cmp = PyObject_IsTrue (
value);
200 self->value.intval = cmp;
204 if (! PyBool_Check (
value) &&
value != Py_None)
206 PyErr_SetString (PyExc_RuntimeError,
207 _(
"A boolean or None is required"));
211 if (
value == Py_None)
215 cmp = PyObject_IsTrue (
value);
232 if (! PyInt_Check (
value))
234 PyErr_SetString (PyExc_RuntimeError,
235 _(
"The value must be integer."));
259 PyErr_SetString (PyExc_RuntimeError,
260 _(
"Range exceeded."));
264 self->value.intval = (int) l;
269 PyErr_SetString (PyExc_RuntimeError,
270 _(
"Unhandled type in parameter value."));
279 set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
281 if (PyString_Check (attr_name)
283 && ! PyUnicode_CompareWithASCIIString (attr_name,
"value"))
285 && ! strcmp (PyString_AsString (attr_name),
"value"))
290 PyErr_SetString (PyExc_RuntimeError,
291 _(
"Cannot delete a parameter's value."));
297 return PyObject_GenericSetAttr (obj, attr_name, val);
308 if (PyObject_HasAttr (
object, attr))
310 gdbpy_ref<> ds_obj (PyObject_GetAttr (
object, attr));
320 result.reset (xstrdup (
_(
"This command is not documented.")));
332 gdbpy_ref<> result (PyObject_CallMethodObjArgs (obj, method, arg, NULL));
345 PyErr_SetString (PyExc_RuntimeError,
346 _(
"Parameter must return a string value."));
367 gdbpy_ref<> set_doc_func (PyString_FromString (
"get_set_string"));
369 if (set_doc_func == NULL)
375 if (PyObject_HasAttr (obj, set_doc_func.
get ()))
378 if (! set_doc_string)
410 gdbpy_ref<> show_doc_func (PyString_FromString (
"get_show_string"));
412 if (show_doc_func == NULL)
418 if (PyObject_HasAttr (obj, show_doc_func.
get ()))
430 if (! show_doc_string)
454 char *set_doc,
char *show_doc,
char *help_doc,
459 const char *tmp_name = NULL;
466 &self->value.intval, set_doc, show_doc,
468 set_list, show_list);
474 &self->value.autoboolval,
475 set_doc, show_doc, help_doc,
477 set_list, show_list);
482 &self->value.uintval, set_doc, show_doc,
484 set_list, show_list);
489 &self->value.intval, set_doc, show_doc,
491 set_list, show_list);
break;
495 &self->value.stringval, set_doc, show_doc,
497 set_list, show_list);
break;
501 &self->value.stringval,
502 set_doc, show_doc, help_doc,
504 set_list, show_list);
510 &self->value.stringval, set_doc,
518 &self->value.stringval, set_doc, show_doc,
520 set_list, show_list);
break;
524 &self->value.intval, set_doc, show_doc,
526 set_list, show_list);
531 &self->value.cstringval, set_doc, show_doc,
533 set_list, show_list);
535 self->value.cstringval =
self->enumeration[0];
542 param =
lookup_cmd (&tmp_name, *show_list,
"", 0, 1);
547 param =
lookup_cmd (&tmp_name, *set_list,
"", 0, 1);
561 PyErr_SetString (PyExc_RuntimeError,
562 _(
"An enumeration is required for PARAM_ENUM."));
566 if (! PySequence_Check (enum_values))
568 PyErr_SetString (PyExc_RuntimeError,
569 _(
"The enumeration is not a sequence."));
573 size = PySequence_Size (enum_values);
578 PyErr_SetString (PyExc_RuntimeError,
579 _(
"The enumeration is empty."));
584 char **enumeration = holder.
get ();
586 for (i = 0; i <
size; ++i)
588 gdbpy_ref<> item (PySequence_GetItem (enum_values, i));
594 PyErr_SetString (PyExc_RuntimeError,
595 _(
"The enumeration item not a string."));
599 if (enumeration[i] == NULL)
603 self->enumeration =
const_cast<const char**
> (holder.
release ());
635 char *set_doc, *show_doc, *
doc;
637 int parmclass, cmdtype;
638 PyObject *enum_values = NULL;
641 if (! PyArg_ParseTuple (args,
"sii|O", &
name, &cmdtype, &parmclass,
652 PyErr_Format (PyExc_RuntimeError,
_(
"Invalid command class argument."));
663 PyErr_SetString (PyExc_RuntimeError,
664 _(
"Invalid parameter class argument."));
668 if (enum_values && parmclass !=
var_enum)
670 PyErr_SetString (PyExc_RuntimeError,
671 _(
"Only PARAM_ENUM accepts a fourth argument."));
706 doc, set_list, show_list);
716 ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
717 "%s", except.message);
779 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
780 "GDB parameter object",
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
void add_setshow_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void set_cmd_context(struct cmd_list_element *cmd, void *context)
static int parmpy_init(PyObject *self, PyObject *args, PyObject *kwds)
void * get_cmd_context(struct cmd_list_element *cmd)
PyTypeObject parmpy_object_type
static PyObject * get_attr(PyObject *obj, PyObject *attr_name)
void add_setshow_integer_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void add_setshow_auto_boolean_cmd(const char *name, enum command_class theclass, enum auto_boolean *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int gdbpy_is_string(PyObject *obj)
static gdb::unique_xmalloc_ptr< char > get_doc_string(PyObject *object, PyObject *attr)
static PyObject * show_doc_cst
void * memset(T *s, int c, size_t n)=delete
static int set_attr(PyObject *obj, PyObject *attr_name, PyObject *val)
struct cmd_list_element * lookup_cmd(const char **line, struct cmd_list_element *list, const char *cmdtype, int allow_unknown, int ignore_help_classes)
void add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
#define PyVarObject_HEAD_INIT(type, size)
static void get_set_value(const char *args, int from_tty, struct cmd_list_element *c)
const char ** enumeration
PyTypeObject parmpy_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("parmpy_object")
struct cmd_list_element * setlist
void add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int gdbpy_initialize_parameters(void)
#define CATCH(EXCEPTION, MASK)
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
void fprintf_filtered(struct ui_file *stream, const char *format,...)
void add_setshow_zinteger_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void get_show_value(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
struct cmd_list_element * showlist
struct cmd_list_element * add_setshow_string_noescape_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
PyObject * gdbpy_parameter_value(enum var_types type, void *var)
void add_setshow_string_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct gdbarch * get_current_arch(void)
char * gdbpy_parse_command_name(const char *name, struct cmd_list_element ***base_list, struct cmd_list_element **start_list)
gdb::unique_xmalloc_ptr< char > python_string_to_host_string(PyObject *obj)
static PyObject * set_doc_cst
static int set_parameter_value(parmpy_object *self, PyObject *value)
static void add_setshow_generic(int parmclass, enum command_class cmdclass, char *cmd_name, parmpy_object *self, char *set_doc, char *show_doc, char *help_doc, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
const struct language_defn * current_language
PyObject_HEAD enum var_types type
union parmpy_variable value
struct parm_constant parm_constants[]
void gdbpy_print_stack(void)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static int compute_enum_values(parmpy_object *self, PyObject *enum_values)
int gdb_py_int_as_long(PyObject *obj, long *result)
void add_setshow_optional_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static gdb::unique_xmalloc_ptr< char > call_doc_function(PyObject *obj, PyObject *method, PyObject *arg)
struct parmpy_object parmpy_object
enum auto_boolean autoboolval