]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/python/py-param.c
d0a4850bdc04c63e5afa66973201aaabaf5c6bcc
[thirdparty/binutils-gdb.git] / gdb / python / py-param.c
1 /* GDB parameters implemented in Python
2
3 Copyright (C) 2008-2021 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20
21 #include "defs.h"
22 #include "value.h"
23 #include "python-internal.h"
24 #include "charset.h"
25 #include "gdbcmd.h"
26 #include "cli/cli-decode.h"
27 #include "completer.h"
28 #include "language.h"
29 #include "arch-utils.h"
30
31 /* Parameter constants and their values. */
32 static struct {
33 const char *name;
34 int value;
35 } parm_constants[] =
36 {
37 { "PARAM_BOOLEAN", var_boolean }, /* ARI: var_boolean */
38 { "PARAM_AUTO_BOOLEAN", var_auto_boolean },
39 { "PARAM_UINTEGER", var_uinteger },
40 { "PARAM_INTEGER", var_integer },
41 { "PARAM_STRING", var_string },
42 { "PARAM_STRING_NOESCAPE", var_string_noescape },
43 { "PARAM_OPTIONAL_FILENAME", var_optional_filename },
44 { "PARAM_FILENAME", var_filename },
45 { "PARAM_ZINTEGER", var_zinteger },
46 { "PARAM_ZUINTEGER", var_zuinteger },
47 { "PARAM_ZUINTEGER_UNLIMITED", var_zuinteger_unlimited },
48 { "PARAM_ENUM", var_enum },
49 { NULL, 0 }
50 };
51
52 /* A union that can hold anything described by enum var_types. */
53 union parmpy_variable
54 {
55 /* Hold a boolean value. */
56 bool boolval;
57
58 /* Hold an integer value. */
59 int intval;
60
61 /* Hold an auto_boolean. */
62 enum auto_boolean autoboolval;
63
64 /* Hold an unsigned integer value, for uinteger. */
65 unsigned int uintval;
66
67 /* Hold a string, for the various string types. */
68 char *stringval;
69
70 /* Hold a string, for enums. */
71 const char *cstringval;
72 };
73
74 /* A GDB parameter. */
75 struct parmpy_object
76 {
77 PyObject_HEAD
78
79 /* The type of the parameter. */
80 enum var_types type;
81
82 /* The value of the parameter. */
83 union parmpy_variable value;
84
85 /* For an enum command, the possible values. The vector is
86 allocated with xmalloc, as is each element. It is
87 NULL-terminated. */
88 const char **enumeration;
89 };
90
91 extern PyTypeObject parmpy_object_type
92 CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
93
94 /* Some handy string constants. */
95 static PyObject *set_doc_cst;
96 static PyObject *show_doc_cst;
97
98 \f
99
100 /* Get an attribute. */
101 static PyObject *
102 get_attr (PyObject *obj, PyObject *attr_name)
103 {
104 if (PyString_Check (attr_name)
105 #ifdef IS_PY3K
106 && ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
107 #else
108 && ! strcmp (PyString_AsString (attr_name), "value"))
109 #endif
110 {
111 parmpy_object *self = (parmpy_object *) obj;
112
113 return gdbpy_parameter_value (self->type, &self->value);
114 }
115
116 return PyObject_GenericGetAttr (obj, attr_name);
117 }
118
119 /* Set a parameter value from a Python value. Return 0 on success. Returns
120 -1 on error, with a python exception set. */
121 static int
122 set_parameter_value (parmpy_object *self, PyObject *value)
123 {
124 int cmp;
125
126 switch (self->type)
127 {
128 case var_string:
129 case var_string_noescape:
130 case var_optional_filename:
131 case var_filename:
132 if (! gdbpy_is_string (value)
133 && (self->type == var_filename
134 || value != Py_None))
135 {
136 PyErr_SetString (PyExc_RuntimeError,
137 _("String required for filename."));
138
139 return -1;
140 }
141 if (value == Py_None)
142 {
143 xfree (self->value.stringval);
144 if (self->type == var_optional_filename)
145 self->value.stringval = xstrdup ("");
146 else
147 self->value.stringval = NULL;
148 }
149 else
150 {
151 gdb::unique_xmalloc_ptr<char>
152 string (python_string_to_host_string (value));
153 if (string == NULL)
154 return -1;
155
156 xfree (self->value.stringval);
157 self->value.stringval = string.release ();
158 }
159 break;
160
161 case var_enum:
162 {
163 int i;
164
165 if (! gdbpy_is_string (value))
166 {
167 PyErr_SetString (PyExc_RuntimeError,
168 _("ENUM arguments must be a string."));
169 return -1;
170 }
171
172 gdb::unique_xmalloc_ptr<char>
173 str (python_string_to_host_string (value));
174 if (str == NULL)
175 return -1;
176 for (i = 0; self->enumeration[i]; ++i)
177 if (! strcmp (self->enumeration[i], str.get ()))
178 break;
179 if (! self->enumeration[i])
180 {
181 PyErr_SetString (PyExc_RuntimeError,
182 _("The value must be member of an enumeration."));
183 return -1;
184 }
185 self->value.cstringval = self->enumeration[i];
186 break;
187 }
188
189 case var_boolean:
190 if (! PyBool_Check (value))
191 {
192 PyErr_SetString (PyExc_RuntimeError,
193 _("A boolean argument is required."));
194 return -1;
195 }
196 cmp = PyObject_IsTrue (value);
197 if (cmp < 0)
198 return -1;
199 self->value.boolval = cmp;
200 break;
201
202 case var_auto_boolean:
203 if (! PyBool_Check (value) && value != Py_None)
204 {
205 PyErr_SetString (PyExc_RuntimeError,
206 _("A boolean or None is required"));
207 return -1;
208 }
209
210 if (value == Py_None)
211 self->value.autoboolval = AUTO_BOOLEAN_AUTO;
212 else
213 {
214 cmp = PyObject_IsTrue (value);
215 if (cmp < 0 )
216 return -1;
217 if (cmp == 1)
218 self->value.autoboolval = AUTO_BOOLEAN_TRUE;
219 else
220 self->value.autoboolval = AUTO_BOOLEAN_FALSE;
221 }
222 break;
223
224 case var_integer:
225 case var_zinteger:
226 case var_uinteger:
227 case var_zuinteger:
228 case var_zuinteger_unlimited:
229 {
230 long l;
231 int ok;
232
233 if (! PyInt_Check (value))
234 {
235 PyErr_SetString (PyExc_RuntimeError,
236 _("The value must be integer."));
237 return -1;
238 }
239
240 if (! gdb_py_int_as_long (value, &l))
241 return -1;
242
243 switch (self->type)
244 {
245 case var_uinteger:
246 if (l == 0)
247 l = UINT_MAX;
248 /* Fall through. */
249 case var_zuinteger:
250 ok = (l >= 0 && l <= UINT_MAX);
251 break;
252
253 case var_zuinteger_unlimited:
254 ok = (l >= -1 && l <= INT_MAX);
255 break;
256
257 case var_integer:
258 ok = (l >= INT_MIN && l <= INT_MAX);
259 if (l == 0)
260 l = INT_MAX;
261 break;
262
263 case var_zinteger:
264 ok = (l >= INT_MIN && l <= INT_MAX);
265 break;
266
267 default:
268 gdb_assert_not_reached ("unknown var_ constant");
269 }
270
271 if (! ok)
272 {
273 PyErr_SetString (PyExc_RuntimeError,
274 _("Range exceeded."));
275 return -1;
276 }
277
278 if (self->type == var_uinteger || self->type == var_zuinteger)
279 self->value.uintval = (unsigned) l;
280 else
281 self->value.intval = (int) l;
282 break;
283 }
284
285 default:
286 PyErr_SetString (PyExc_RuntimeError,
287 _("Unhandled type in parameter value."));
288 return -1;
289 }
290
291 return 0;
292 }
293
294 /* Set an attribute. Returns -1 on error, with a python exception set. */
295 static int
296 set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
297 {
298 if (PyString_Check (attr_name)
299 #ifdef IS_PY3K
300 && ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
301 #else
302 && ! strcmp (PyString_AsString (attr_name), "value"))
303 #endif
304 {
305 if (!val)
306 {
307 PyErr_SetString (PyExc_RuntimeError,
308 _("Cannot delete a parameter's value."));
309 return -1;
310 }
311 return set_parameter_value ((parmpy_object *) obj, val);
312 }
313
314 return PyObject_GenericSetAttr (obj, attr_name, val);
315 }
316
317 /* A helper function which returns a documentation string for an
318 object. */
319
320 static gdb::unique_xmalloc_ptr<char>
321 get_doc_string (PyObject *object, PyObject *attr)
322 {
323 gdb::unique_xmalloc_ptr<char> result;
324
325 if (PyObject_HasAttr (object, attr))
326 {
327 gdbpy_ref<> ds_obj (PyObject_GetAttr (object, attr));
328
329 if (ds_obj != NULL && gdbpy_is_string (ds_obj.get ()))
330 {
331 result = python_string_to_host_string (ds_obj.get ());
332 if (result == NULL)
333 gdbpy_print_stack ();
334 }
335 }
336 if (! result)
337 result.reset (xstrdup (_("This command is not documented.")));
338 return result;
339 }
340
341 /* Helper function which will execute a METHOD in OBJ passing the
342 argument ARG. ARG can be NULL. METHOD should return a Python
343 string. If this function returns NULL, there has been an error and
344 the appropriate exception set. */
345 static gdb::unique_xmalloc_ptr<char>
346 call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
347 {
348 gdb::unique_xmalloc_ptr<char> data;
349 gdbpy_ref<> result (PyObject_CallMethodObjArgs (obj, method, arg, NULL));
350
351 if (result == NULL)
352 return NULL;
353
354 if (gdbpy_is_string (result.get ()))
355 {
356 data = python_string_to_host_string (result.get ());
357 if (! data)
358 return NULL;
359 }
360 else
361 {
362 PyErr_SetString (PyExc_RuntimeError,
363 _("Parameter must return a string value."));
364 return NULL;
365 }
366
367 return data;
368 }
369
370 /* A callback function that is registered against the respective
371 add_setshow_* set_doc prototype. This function calls the Python function
372 "get_set_string" if it exists, which will return a string. That string
373 is then printed. If "get_set_string" does not exist, or returns an
374 empty string, then nothing is printed. */
375 static void
376 get_set_value (const char *args, int from_tty,
377 struct cmd_list_element *c)
378 {
379 PyObject *obj = (PyObject *) get_cmd_context (c);
380 gdb::unique_xmalloc_ptr<char> set_doc_string;
381
382 gdbpy_enter enter_py (get_current_arch (), current_language);
383 gdbpy_ref<> set_doc_func (PyString_FromString ("get_set_string"));
384
385 if (set_doc_func == NULL)
386 {
387 gdbpy_print_stack ();
388 return;
389 }
390
391 if (PyObject_HasAttr (obj, set_doc_func.get ()))
392 {
393 set_doc_string = call_doc_function (obj, set_doc_func.get (), NULL);
394 if (! set_doc_string)
395 gdbpy_handle_exception ();
396 }
397
398 const char *str = set_doc_string.get ();
399 if (str != nullptr && str[0] != '\0')
400 fprintf_filtered (gdb_stdout, "%s\n", str);
401 }
402
403 /* A callback function that is registered against the respective
404 add_setshow_* show_doc prototype. This function will either call
405 the Python function "get_show_string" or extract the Python
406 attribute "show_doc" and return the contents as a string. If
407 neither exist, insert a string indicating the Parameter is not
408 documented. */
409 static void
410 get_show_value (struct ui_file *file, int from_tty,
411 struct cmd_list_element *c,
412 const char *value)
413 {
414 PyObject *obj = (PyObject *) get_cmd_context (c);
415 gdb::unique_xmalloc_ptr<char> show_doc_string;
416
417 gdbpy_enter enter_py (get_current_arch (), current_language);
418 gdbpy_ref<> show_doc_func (PyString_FromString ("get_show_string"));
419
420 if (show_doc_func == NULL)
421 {
422 gdbpy_print_stack ();
423 return;
424 }
425
426 if (PyObject_HasAttr (obj, show_doc_func.get ()))
427 {
428 gdbpy_ref<> val_obj (PyString_FromString (value));
429
430 if (val_obj == NULL)
431 {
432 gdbpy_print_stack ();
433 return;
434 }
435
436 show_doc_string = call_doc_function (obj, show_doc_func.get (),
437 val_obj.get ());
438 if (! show_doc_string)
439 {
440 gdbpy_print_stack ();
441 return;
442 }
443
444 fprintf_filtered (file, "%s\n", show_doc_string.get ());
445 }
446 else
447 {
448 /* We have to preserve the existing < GDB 7.3 API. If a
449 callback function does not exist, then attempt to read the
450 show_doc attribute. */
451 show_doc_string = get_doc_string (obj, show_doc_cst);
452 fprintf_filtered (file, "%s %s\n", show_doc_string.get (), value);
453 }
454 }
455 \f
456
457 /* A helper function that dispatches to the appropriate add_setshow
458 function. */
459 static void
460 add_setshow_generic (int parmclass, enum command_class cmdclass,
461 gdb::unique_xmalloc_ptr<char> cmd_name,
462 parmpy_object *self,
463 const char *set_doc, const char *show_doc,
464 const char *help_doc,
465 struct cmd_list_element **set_list,
466 struct cmd_list_element **show_list)
467 {
468 set_show_commands commands;
469
470 switch (parmclass)
471 {
472 case var_boolean:
473 commands = add_setshow_boolean_cmd (cmd_name.get (), cmdclass,
474 &self->value.boolval, set_doc,
475 show_doc, help_doc, get_set_value,
476 get_show_value, set_list, show_list);
477
478 break;
479
480 case var_auto_boolean:
481 commands = add_setshow_auto_boolean_cmd (cmd_name.get (), cmdclass,
482 &self->value.autoboolval,
483 set_doc, show_doc, help_doc,
484 get_set_value, get_show_value,
485 set_list, show_list);
486 break;
487
488 case var_uinteger:
489 commands = add_setshow_uinteger_cmd (cmd_name.get (), cmdclass,
490 &self->value.uintval, set_doc,
491 show_doc, help_doc, get_set_value,
492 get_show_value, set_list, show_list);
493 break;
494
495 case var_integer:
496 commands = add_setshow_integer_cmd (cmd_name.get (), cmdclass,
497 &self->value.intval, set_doc,
498 show_doc, help_doc, get_set_value,
499 get_show_value, set_list, show_list);
500 break;
501
502 case var_string:
503 commands = add_setshow_string_cmd (cmd_name.get (), cmdclass,
504 &self->value.stringval, set_doc,
505 show_doc, help_doc, get_set_value,
506 get_show_value, set_list, show_list);
507 break;
508
509 case var_string_noescape:
510 commands = add_setshow_string_noescape_cmd (cmd_name.get (), cmdclass,
511 &self->value.stringval,
512 set_doc, show_doc, help_doc,
513 get_set_value, get_show_value,
514 set_list, show_list);
515 break;
516
517 case var_optional_filename:
518 commands = add_setshow_optional_filename_cmd (cmd_name.get (), cmdclass,
519 &self->value.stringval,
520 set_doc, show_doc, help_doc,
521 get_set_value,
522 get_show_value, set_list,
523 show_list);
524 break;
525
526 case var_filename:
527 commands = add_setshow_filename_cmd (cmd_name.get (), cmdclass,
528 &self->value.stringval, set_doc,
529 show_doc, help_doc, get_set_value,
530 get_show_value, set_list, show_list);
531 break;
532
533 case var_zinteger:
534 commands = add_setshow_zinteger_cmd (cmd_name.get (), cmdclass,
535 &self->value.intval, set_doc,
536 show_doc, help_doc, get_set_value,
537 get_show_value, set_list, show_list);
538 break;
539
540 case var_zuinteger:
541 commands = add_setshow_zuinteger_cmd (cmd_name.get (), cmdclass,
542 &self->value.uintval, set_doc,
543 show_doc, help_doc, get_set_value,
544 get_show_value, set_list,
545 show_list);
546 break;
547
548 case var_zuinteger_unlimited:
549 commands = add_setshow_zuinteger_unlimited_cmd (cmd_name.get (), cmdclass,
550 &self->value.intval,
551 set_doc, show_doc,
552 help_doc, get_set_value,
553 get_show_value, set_list,
554 show_list);
555 break;
556
557 case var_enum:
558 commands = add_setshow_enum_cmd (cmd_name.get (), cmdclass,
559 self->enumeration,
560 &self->value.cstringval, set_doc,
561 show_doc, help_doc, get_set_value,
562 get_show_value, set_list, show_list);
563 /* Initialize the value, just in case. */
564 self->value.cstringval = self->enumeration[0];
565 break;
566
567 default:
568 gdb_assert_not_reached ("Unhandled parameter class.");
569 }
570
571 /* Register Python objects in both commands' context. */
572 set_cmd_context (commands.set, self);
573 set_cmd_context (commands.show, self);
574
575 /* We (unfortunately) currently leak the command name. */
576 cmd_name.release ();
577 }
578
579 /* A helper which computes enum values. Returns 1 on success. Returns 0 on
580 error, with a python exception set. */
581 static int
582 compute_enum_values (parmpy_object *self, PyObject *enum_values)
583 {
584 Py_ssize_t size, i;
585
586 if (! enum_values)
587 {
588 PyErr_SetString (PyExc_RuntimeError,
589 _("An enumeration is required for PARAM_ENUM."));
590 return 0;
591 }
592
593 if (! PySequence_Check (enum_values))
594 {
595 PyErr_SetString (PyExc_RuntimeError,
596 _("The enumeration is not a sequence."));
597 return 0;
598 }
599
600 size = PySequence_Size (enum_values);
601 if (size < 0)
602 return 0;
603 if (size == 0)
604 {
605 PyErr_SetString (PyExc_RuntimeError,
606 _("The enumeration is empty."));
607 return 0;
608 }
609
610 gdb_argv holder (XCNEWVEC (char *, size + 1));
611 char **enumeration = holder.get ();
612
613 for (i = 0; i < size; ++i)
614 {
615 gdbpy_ref<> item (PySequence_GetItem (enum_values, i));
616
617 if (item == NULL)
618 return 0;
619 if (! gdbpy_is_string (item.get ()))
620 {
621 PyErr_SetString (PyExc_RuntimeError,
622 _("The enumeration item not a string."));
623 return 0;
624 }
625 enumeration[i] = python_string_to_host_string (item.get ()).release ();
626 if (enumeration[i] == NULL)
627 return 0;
628 }
629
630 self->enumeration = const_cast<const char**> (holder.release ());
631 return 1;
632 }
633
634 /* Object initializer; sets up gdb-side structures for command.
635
636 Use: __init__(NAME, CMDCLASS, PARMCLASS, [ENUM])
637
638 NAME is the name of the parameter. It may consist of multiple
639 words, in which case the final word is the name of the new command,
640 and earlier words must be prefix commands.
641
642 CMDCLASS is the kind of command. It should be one of the COMMAND_*
643 constants defined in the gdb module.
644
645 PARMCLASS is the type of the parameter. It should be one of the
646 PARAM_* constants defined in the gdb module.
647
648 If PARMCLASS is PARAM_ENUM, then the final argument should be a
649 collection of strings. These strings are the valid values for this
650 parameter.
651
652 The documentation for the parameter is taken from the doc string
653 for the python class.
654
655 Returns -1 on error, with a python exception set. */
656
657 static int
658 parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
659 {
660 parmpy_object *obj = (parmpy_object *) self;
661 const char *name;
662 gdb::unique_xmalloc_ptr<char> set_doc, show_doc, doc;
663 int parmclass, cmdtype;
664 PyObject *enum_values = NULL;
665 struct cmd_list_element **set_list, **show_list;
666
667 if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
668 &enum_values))
669 return -1;
670
671 if (cmdtype != no_class && cmdtype != class_run
672 && cmdtype != class_vars && cmdtype != class_stack
673 && cmdtype != class_files && cmdtype != class_support
674 && cmdtype != class_info && cmdtype != class_breakpoint
675 && cmdtype != class_trace && cmdtype != class_obscure
676 && cmdtype != class_maintenance)
677 {
678 PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument."));
679 return -1;
680 }
681
682 if (parmclass != var_boolean /* ARI: var_boolean */
683 && parmclass != var_auto_boolean
684 && parmclass != var_uinteger && parmclass != var_integer
685 && parmclass != var_string && parmclass != var_string_noescape
686 && parmclass != var_optional_filename && parmclass != var_filename
687 && parmclass != var_zinteger && parmclass != var_zuinteger
688 && parmclass != var_zuinteger_unlimited && parmclass != var_enum)
689 {
690 PyErr_SetString (PyExc_RuntimeError,
691 _("Invalid parameter class argument."));
692 return -1;
693 }
694
695 if (enum_values && parmclass != var_enum)
696 {
697 PyErr_SetString (PyExc_RuntimeError,
698 _("Only PARAM_ENUM accepts a fourth argument."));
699 return -1;
700 }
701 if (parmclass == var_enum)
702 {
703 if (! compute_enum_values (obj, enum_values))
704 return -1;
705 }
706 else
707 obj->enumeration = NULL;
708 obj->type = (enum var_types) parmclass;
709 memset (&obj->value, 0, sizeof (obj->value));
710
711 gdb::unique_xmalloc_ptr<char> cmd_name
712 = gdbpy_parse_command_name (name, &set_list, &setlist);
713 if (cmd_name == nullptr)
714 return -1;
715
716 cmd_name = gdbpy_parse_command_name (name, &show_list, &showlist);
717 if (cmd_name == nullptr)
718 return -1;
719
720 set_doc = get_doc_string (self, set_doc_cst);
721 show_doc = get_doc_string (self, show_doc_cst);
722 doc = get_doc_string (self, gdbpy_doc_cst);
723
724 Py_INCREF (self);
725
726 try
727 {
728 add_setshow_generic (parmclass, (enum command_class) cmdtype,
729 std::move (cmd_name), obj,
730 set_doc.get (), show_doc.get (),
731 doc.get (), set_list, show_list);
732 }
733 catch (const gdb_exception &except)
734 {
735 Py_DECREF (self);
736 gdbpy_convert_exception (except);
737 return -1;
738 }
739
740 return 0;
741 }
742
743 \f
744
745 /* Initialize the 'parameters' module. */
746 int
747 gdbpy_initialize_parameters (void)
748 {
749 int i;
750
751 parmpy_object_type.tp_new = PyType_GenericNew;
752 if (PyType_Ready (&parmpy_object_type) < 0)
753 return -1;
754
755 set_doc_cst = PyString_FromString ("set_doc");
756 if (! set_doc_cst)
757 return -1;
758 show_doc_cst = PyString_FromString ("show_doc");
759 if (! show_doc_cst)
760 return -1;
761
762 for (i = 0; parm_constants[i].name; ++i)
763 {
764 if (PyModule_AddIntConstant (gdb_module,
765 parm_constants[i].name,
766 parm_constants[i].value) < 0)
767 return -1;
768 }
769
770 return gdb_pymodule_addobject (gdb_module, "Parameter",
771 (PyObject *) &parmpy_object_type);
772 }
773
774 \f
775
776 PyTypeObject parmpy_object_type =
777 {
778 PyVarObject_HEAD_INIT (NULL, 0)
779 "gdb.Parameter", /*tp_name*/
780 sizeof (parmpy_object), /*tp_basicsize*/
781 0, /*tp_itemsize*/
782 0, /*tp_dealloc*/
783 0, /*tp_print*/
784 0, /*tp_getattr*/
785 0, /*tp_setattr*/
786 0, /*tp_compare*/
787 0, /*tp_repr*/
788 0, /*tp_as_number*/
789 0, /*tp_as_sequence*/
790 0, /*tp_as_mapping*/
791 0, /*tp_hash */
792 0, /*tp_call*/
793 0, /*tp_str*/
794 get_attr, /*tp_getattro*/
795 set_attr, /*tp_setattro*/
796 0, /*tp_as_buffer*/
797 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
798 "GDB parameter object", /* tp_doc */
799 0, /* tp_traverse */
800 0, /* tp_clear */
801 0, /* tp_richcompare */
802 0, /* tp_weaklistoffset */
803 0, /* tp_iter */
804 0, /* tp_iternext */
805 0, /* tp_methods */
806 0, /* tp_members */
807 0, /* tp_getset */
808 0, /* tp_base */
809 0, /* tp_dict */
810 0, /* tp_descr_get */
811 0, /* tp_descr_set */
812 0, /* tp_dictoffset */
813 parmpy_init, /* tp_init */
814 0, /* tp_alloc */
815 };