GDB (xrefs)
Loading...
Searching...
No Matches
py-micmd.c
Go to the documentation of this file.
1/* MI Command Set for GDB, the GNU debugger.
2
3 Copyright (C) 2019-2023 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/* GDB/MI commands implemented in Python. */
21
22#include "defs.h"
23#include "python-internal.h"
24#include "arch-utils.h"
25#include "charset.h"
26#include "language.h"
27#include "mi/mi-cmds.h"
28#include "mi/mi-parse.h"
29#include "cli/cli-cmds.h"
30#include <string>
31
32/* Debugging of Python MI commands. */
33
34static bool pymicmd_debug;
35
36/* Implementation of "show debug py-micmd". */
37
38static void
39show_pymicmd_debug (struct ui_file *file, int from_tty,
40 struct cmd_list_element *c, const char *value)
41{
42 gdb_printf (file, _("Python MI command debugging is %s.\n"), value);
43}
44
45/* Print a "py-micmd" debug statement. */
46
47#define pymicmd_debug_printf(fmt, ...) \
48 debug_prefixed_printf_cond (pymicmd_debug, "py-micmd", fmt, ##__VA_ARGS__)
49
50/* Print a "py-micmd" enter/exit debug statements. */
51
52#define PYMICMD_SCOPED_DEBUG_ENTER_EXIT \
53 scoped_debug_enter_exit (pymicmd_debug, "py-micmd")
54
55struct mi_command_py;
56
57/* Representation of a Python gdb.MICommand object. */
58
60{
61 PyObject_HEAD
62
63 /* The object representing this command in the MI command table. This
64 pointer can be nullptr if the command is not currently installed into
65 the MI command table (see gdb.MICommand.installed property). */
67
68 /* The string representing the name of this command, without the leading
69 dash. This string is never nullptr once the Python object has been
70 initialised.
71
72 The memory for this string was allocated with malloc, and needs to be
73 deallocated with free when the Python object is deallocated.
74
75 When the MI_COMMAND field is not nullptr, then the mi_command_py
76 object's name will point back to this string. */
78};
79
80/* The MI command implemented in Python. */
81
83{
84 /* Constructs a new mi_command_py object. NAME is command name without
85 leading dash. OBJECT is a reference to a Python object implementing
86 the command. This object must inherit from gdb.MICommand and must
87 implement the invoke method. */
88
89 mi_command_py (const char *name, micmdpy_object *object)
91 m_pyobj (gdbpy_ref<micmdpy_object>::new_reference (object))
92 {
93 pymicmd_debug_printf ("this = %p", this);
94 m_pyobj->mi_command = this;
95 }
96
98 {
99 /* The Python object representing a MI command contains a pointer back
100 to this c++ object. We can safely set this pointer back to nullptr
101 now, to indicate the Python object no longer references a valid c++
102 object.
103
104 However, the Python object also holds the storage for our name
105 string. We can't clear that here as our parent's destructor might
106 still want to reference that string. Instead we rely on the Python
107 object deallocator to free that memory, and reset the pointer. */
108 m_pyobj->mi_command = nullptr;
109
110 pymicmd_debug_printf ("this = %p", this);
111 };
112
113 /* Validate that CMD_OBJ, a non-nullptr pointer, is installed into the MI
114 command table correctly. This function looks up the command in the MI
115 command table and checks that the object we get back references
116 CMD_OBJ. This function is only intended for calling within a
117 gdb_assert. This function performs many assertions internally, and
118 then always returns true. */
119 static void validate_installation (micmdpy_object *cmd_obj);
120
121 /* Update M_PYOBJ to NEW_PYOBJ. The pointer from M_PYOBJ that points
122 back to this object is swapped with the pointer in NEW_PYOBJ, which
123 must be nullptr, so that NEW_PYOBJ now points back to this object.
124 Additionally our parent's name string is stored in M_PYOBJ, so we
125 swap the name string with NEW_PYOBJ.
126
127 Before this call M_PYOBJ is the Python object representing this MI
128 command object. After this call has completed, NEW_PYOBJ now
129 represents this MI command object. */
131 {
132 /* Current object has a backlink, new object doesn't have a backlink. */
133 gdb_assert (m_pyobj->mi_command != nullptr);
134 gdb_assert (new_pyobj->mi_command == nullptr);
135
136 /* Clear the current M_PYOBJ's backlink, set NEW_PYOBJ's backlink. */
137 std::swap (new_pyobj->mi_command, m_pyobj->mi_command);
138
139 /* Both object have names. */
140 gdb_assert (m_pyobj->mi_command_name != nullptr);
141 gdb_assert (new_pyobj->mi_command_name != nullptr);
142
143 /* mi_command::m_name is the string owned by the current object. */
144 gdb_assert (m_pyobj->mi_command_name == this->name ());
145
146 /* The name in mi_command::m_name is owned by the current object. Rather
147 than changing the value of mi_command::m_name (which is not accessible
148 from here) to point to the name owned by the new object, swap the names
149 of the two objects, since we know they are identical strings. */
150 gdb_assert (strcmp (new_pyobj->mi_command_name,
151 m_pyobj->mi_command_name) == 0);
152 std::swap (new_pyobj->mi_command_name, m_pyobj->mi_command_name);
153
154 /* Take a reference to the new object, drop the reference to the current
155 object. */
157 }
158
159 /* Called when the MI command is invoked. */
160 virtual void invoke(struct mi_parse *parse) const override;
161
162private:
163 /* The Python object representing this MI command. */
165};
166
167using mi_command_py_up = std::unique_ptr<mi_command_py>;
168
169extern PyTypeObject micmdpy_object_type
171
172/* Holds a Python object containing the string 'invoke'. */
173
175
176/* Convert KEY_OBJ into a string that can be used as a field name in MI
177 output. KEY_OBJ must be a Python string object, and must only contain
178 characters suitable for use as an MI field name.
179
180 If KEY_OBJ is not a string, or if KEY_OBJ contains invalid characters,
181 then an error is thrown. Otherwise, KEY_OBJ is converted to a string
182 and returned. */
183
184static gdb::unique_xmalloc_ptr<char>
186{
187 /* The key must be a string. */
188 if (!PyUnicode_Check (key_obj))
189 {
190 gdbpy_ref<> key_repr (PyObject_Repr (key_obj));
191 gdb::unique_xmalloc_ptr<char> key_repr_string;
192 if (key_repr != nullptr)
193 key_repr_string = python_string_to_target_string (key_repr.get ());
194 if (key_repr_string == nullptr)
196
197 gdbpy_error (_("non-string object used as key: %s"),
198 key_repr_string.get ());
199 }
200
201 gdb::unique_xmalloc_ptr<char> key_string
203 if (key_string == nullptr)
205
206 /* Predicate function, returns true if NAME is a valid field name for use
207 in MI result output, otherwise, returns false. */
208 auto is_valid_key_name = [] (const char *name) -> bool
209 {
210 gdb_assert (name != nullptr);
211
212 if (*name == '\0' || !isalpha (*name))
213 return false;
214
215 for (; *name != '\0'; ++name)
216 if (!isalnum (*name) && *name != '_' && *name != '-')
217 return false;
218
219 return true;
220 };
221
222 if (!is_valid_key_name (key_string.get ()))
223 {
224 if (*key_string.get () == '\0')
225 gdbpy_error (_("Invalid empty key in MI result"));
226 else
227 gdbpy_error (_("Invalid key in MI result: %s"), key_string.get ());
228 }
229
230 return key_string;
231}
232
233/* Serialize RESULT and print it in MI format to the current_uiout.
234 FIELD_NAME is used as the name of this result field.
235
236 RESULT can be a dictionary, a sequence, an iterator, or an object that
237 can be converted to a string, these are converted to the matching MI
238 output format (dictionaries as tuples, sequences and iterators as lists,
239 and strings as named fields).
240
241 If anything goes wrong while formatting the output then an error is
242 thrown.
243
244 This function is the recursive inner core of serialize_mi_result, and
245 should only be called from that function. */
246
247static void
249{
250 struct ui_out *uiout = current_uiout;
251
252 if (PyDict_Check (result))
253 {
254 PyObject *key, *value;
255 Py_ssize_t pos = 0;
256 ui_out_emit_tuple tuple_emitter (uiout, field_name);
257 while (PyDict_Next (result, &pos, &key, &value))
258 {
259 gdb::unique_xmalloc_ptr<char> key_string
260 (py_object_to_mi_key (key));
261 serialize_mi_result_1 (value, key_string.get ());
262 }
263 }
264 else if (PySequence_Check (result) && !PyUnicode_Check (result))
265 {
266 ui_out_emit_list list_emitter (uiout, field_name);
267 Py_ssize_t len = PySequence_Size (result);
268 if (len == -1)
270 for (Py_ssize_t i = 0; i < len; ++i)
271 {
272 gdbpy_ref<> item (PySequence_ITEM (result, i));
273 if (item == nullptr)
275 serialize_mi_result_1 (item.get (), nullptr);
276 }
277 }
278 else if (PyIter_Check (result))
279 {
280 gdbpy_ref<> item;
281 ui_out_emit_list list_emitter (uiout, field_name);
282 while (true)
283 {
284 item.reset (PyIter_Next (result));
285 if (item == nullptr)
286 {
287 if (PyErr_Occurred () != nullptr)
289 break;
290 }
291 serialize_mi_result_1 (item.get (), nullptr);
292 }
293 }
294 else
295 {
296 if (PyLong_Check (result))
297 {
298 int overflow = 0;
300 &overflow);
301 if (PyErr_Occurred () != nullptr)
303 if (overflow == 0)
304 {
305 uiout->field_signed (field_name, val);
306 return;
307 }
308 /* Fall through to the string case on overflow. */
309 }
310
311 gdb::unique_xmalloc_ptr<char> string (gdbpy_obj_to_string (result));
312 if (string == nullptr)
314 uiout->field_string (field_name, string.get ());
315 }
316}
317
318/* Serialize RESULT and print it in MI format to the current_uiout.
319
320 This function handles the top-level result initially returned from the
321 invoke method of the Python command implementation. At the top-level
322 the result must be a dictionary. The values within this dictionary can
323 be a wider range of types. Handling the values of the top-level
324 dictionary is done by serialize_mi_result_1, see that function for more
325 details.
326
327 If anything goes wrong while parsing and printing the MI output then an
328 error is thrown. */
329
330static void
332{
333 /* At the top-level, the result must be a dictionary. */
334
335 if (!PyDict_Check (result))
336 gdbpy_error (_("Result from invoke must be a dictionary"));
337
338 PyObject *key, *value;
339 Py_ssize_t pos = 0;
340 while (PyDict_Next (result, &pos, &key, &value))
341 {
342 gdb::unique_xmalloc_ptr<char> key_string
343 (py_object_to_mi_key (key));
344 serialize_mi_result_1 (value, key_string.get ());
345 }
346}
347
348/* Called when the MI command is invoked. PARSE contains the parsed
349 command line arguments from the user. */
350
351void
352mi_command_py::invoke (struct mi_parse *parse) const
353{
355
356 pymicmd_debug_printf ("this = %p, name = %s", this, name ());
357
358 parse->parse_argv ();
359
360 if (parse->argv == nullptr)
361 error (_("Problem parsing arguments: %s %s"), parse->command.get (),
362 parse->args ());
363
364
365 gdbpy_enter enter_py;
366
367 /* Place all the arguments into a list which we pass as a single argument
368 to the MI command's invoke method. */
369 gdbpy_ref<> argobj (PyList_New (parse->argc));
370 if (argobj == nullptr)
372
373 for (int i = 0; i < parse->argc; ++i)
374 {
375 gdbpy_ref<> str (PyUnicode_Decode (parse->argv[i],
376 strlen (parse->argv[i]),
377 host_charset (), nullptr));
378 if (PyList_SetItem (argobj.get (), i, str.release ()) < 0)
380 }
381
382 gdb_assert (this->m_pyobj != nullptr);
383 gdb_assert (PyErr_Occurred () == nullptr);
384 gdbpy_ref<> result
385 (PyObject_CallMethodObjArgs ((PyObject *) this->m_pyobj.get (), invoke_cst,
386 argobj.get (), nullptr));
387 if (result == nullptr)
389
390 if (result != Py_None)
391 serialize_mi_result (result.get ());
392}
393
394/* See declaration above. */
395
396void
398{
399 gdb_assert (cmd_obj != nullptr);
400 mi_command_py *cmd = cmd_obj->mi_command;
401 gdb_assert (cmd != nullptr);
402 const char *name = cmd_obj->mi_command_name;
403 gdb_assert (name != nullptr);
404 gdb_assert (name == cmd->name ());
405 mi_command *mi_cmd = mi_cmd_lookup (name);
406 gdb_assert (mi_cmd == cmd);
407 gdb_assert (cmd->m_pyobj == cmd_obj);
408}
409
410/* Return CMD as an mi_command_py if it is a Python MI command, else
411 nullptr. */
412
413static mi_command_py *
415{
416 return dynamic_cast<mi_command_py *> (cmd);
417}
418
419/* Uninstall OBJ, making the MI command represented by OBJ unavailable for
420 use by the user. On success 0 is returned, otherwise -1 is returned
421 and a Python exception will be set. */
422
423static int
425{
427
428 gdb_assert (obj->mi_command != nullptr);
429 gdb_assert (obj->mi_command_name != nullptr);
430
431 pymicmd_debug_printf ("name = %s", obj->mi_command_name);
432
433 /* Remove the command from the internal MI table of commands. This will
434 cause the mi_command_py object to be deleted, which will clear the
435 backlink in OBJ. */
436 bool removed = remove_mi_cmd_entry (obj->mi_command->name ());
437 gdb_assert (removed);
438 gdb_assert (obj->mi_command == nullptr);
439
440 return 0;
441}
442
443/* Install OBJ as a usable MI command. Return 0 on success, and -1 on
444 error, in which case, a Python error will have been set.
445
446 After successful completion the command name associated with OBJ will
447 be installed in the MI command table (so it can be found if the user
448 enters that command name), additionally, OBJ will have been added to
449 the gdb._mi_commands dictionary (using the command name as its key),
450 this will ensure that OBJ remains live even if the user gives up all
451 references. */
452
453static int
455{
457
458 gdb_assert (obj->mi_command == nullptr);
459 gdb_assert (obj->mi_command_name != nullptr);
460
461 pymicmd_debug_printf ("name = %s", obj->mi_command_name);
462
463 /* Look up this command name in MI_COMMANDS, a command with this name may
464 already exist. */
466 mi_command_py *cmd_py = as_mi_command_py (cmd);
467
468 if (cmd != nullptr && cmd_py == nullptr)
469 {
470 /* There is already an MI command registered with that name, and it's not
471 a Python one. Forbid replacing a non-Python MI command. */
472 PyErr_SetString (PyExc_RuntimeError,
473 _("unable to add command, name is already in use"));
474 return -1;
475 }
476
477 if (cmd_py != nullptr)
478 {
479 /* There is already a Python MI command registered with that name, swap
480 in the new gdb.MICommand implementation. */
481 cmd_py->swap_python_object (obj);
482 }
483 else
484 {
485 /* There's no MI command registered with that name at all, create one. */
486 mi_command_py_up mi_cmd (new mi_command_py (obj->mi_command_name, obj));
487
488 /* Add the command to the gdb internal MI command table. */
489 bool result = insert_mi_cmd_entry (std::move (mi_cmd));
490 gdb_assert (result);
491 }
492
493 return 0;
494}
495
496/* Implement gdb.MICommand.__init__. The init method takes the name of
497 the MI command as the first argument, which must be a string, starting
498 with a single dash. */
499
500static int
501micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
502{
504
505 micmdpy_object *cmd = (micmdpy_object *) self;
506
507 static const char *keywords[] = { "name", nullptr };
508 const char *name;
509
510 if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "s", keywords,
511 &name))
512 return -1;
513
514 /* Validate command name */
515 const int name_len = strlen (name);
516 if (name_len == 0)
517 {
518 PyErr_SetString (PyExc_ValueError, _("MI command name is empty."));
519 return -1;
520 }
521 else if ((name_len < 2) || (name[0] != '-') || !isalnum (name[1]))
522 {
523 PyErr_SetString (PyExc_ValueError,
524 _("MI command name does not start with '-'"
525 " followed by at least one letter or digit."));
526 return -1;
527 }
528 else
529 {
530 for (int i = 2; i < name_len; i++)
531 {
532 if (!isalnum (name[i]) && name[i] != '-')
533 {
534 PyErr_Format
535 (PyExc_ValueError,
536 _("MI command name contains invalid character: %c."),
537 name[i]);
538 return -1;
539 }
540 }
541
542 /* Skip over the leading dash. For the rest of this function the
543 dash is not important. */
544 ++name;
545 }
546
547 /* If this object already has a name set, then this object has been
548 initialized before. We handle this case a little differently. */
549 if (cmd->mi_command_name != nullptr)
550 {
551 /* First, we don't allow the user to change the MI command name.
552 Supporting this would be tricky as we would need to delete the
553 mi_command_py from the MI command table, however, the user might
554 be trying to perform this reinitialization from within the very
555 command we're about to delete... it all gets very messy.
556
557 So, for now at least, we don't allow this. This doesn't seem like
558 an excessive restriction. */
559 if (strcmp (cmd->mi_command_name, name) != 0)
560 {
561 PyErr_SetString
562 (PyExc_ValueError,
563 _("can't reinitialize object with a different command name"));
564 return -1;
565 }
566
567 /* If there's already an object registered with the MI command table,
568 then we're done. That object must be a mi_command_py, which
569 should reference back to this micmdpy_object. */
570 if (cmd->mi_command != nullptr)
571 {
573 return 0;
574 }
575 }
576 else
577 cmd->mi_command_name = xstrdup (name);
578
579 /* Now we can install this mi_command_py in the MI command table. */
580 return micmdpy_install_command (cmd);
581}
582
583/* Called when a gdb.MICommand object is deallocated. */
584
585static void
587{
589
590 micmdpy_object *cmd = (micmdpy_object *) obj;
591
592 /* If the Python object failed to initialize, then the name field might
593 be nullptr. */
594 pymicmd_debug_printf ("obj = %p, name = %s", cmd,
595 (cmd->mi_command_name == nullptr
596 ? "(null)" : cmd->mi_command_name));
597
598 /* As the mi_command_py object holds a reference to the micmdpy_object,
599 the only way the dealloc function can be called is if the mi_command_py
600 object has been deleted, in which case the following assert will
601 hold. */
602 gdb_assert (cmd->mi_command == nullptr);
603
604 /* Free the memory that holds the command name. */
605 xfree (cmd->mi_command_name);
606 cmd->mi_command_name = nullptr;
607
608 /* Finally, free the memory for this Python object. */
609 Py_TYPE (obj)->tp_free (obj);
610}
611
612/* Python initialization for the MI commands components. */
613
616{
617 micmdpy_object_type.tp_new = PyType_GenericNew;
618 if (PyType_Ready (&micmdpy_object_type) < 0)
619 return -1;
620
621 if (gdb_pymodule_addobject (gdb_module, "MICommand",
623 < 0)
624 return -1;
625
626 invoke_cst = PyUnicode_FromString ("invoke");
627 if (invoke_cst == nullptr)
628 return -1;
629
630 return 0;
631}
632
633/* Cleanup just before GDB shuts down the Python interpreter. */
634
635static void
637{
638 /* mi_command_py objects hold references to micmdpy_object objects. They must
639 be dropped before the Python interpreter is finalized. Do so by removing
640 those MI command entries, thus deleting the mi_command_py objects. */
642 {
643 return as_mi_command_py (cmd) != nullptr;
644 });
645}
646
647/* Get the gdb.MICommand.name attribute, returns a string, the name of this
648 MI command. */
649
650static PyObject *
651micmdpy_get_name (PyObject *self, void *closure)
652{
653 struct micmdpy_object *micmd_obj = (struct micmdpy_object *) self;
654
655 gdb_assert (micmd_obj->mi_command_name != nullptr);
656 std::string name_str = string_printf ("-%s", micmd_obj->mi_command_name);
657 return PyUnicode_FromString (name_str.c_str ());
658}
659
660/* Get the gdb.MICommand.installed property. Returns true if this MI
661 command is installed into the MI command table, otherwise returns
662 false. */
663
664static PyObject *
665micmdpy_get_installed (PyObject *self, void *closure)
666{
667 struct micmdpy_object *micmd_obj = (struct micmdpy_object *) self;
668
669 if (micmd_obj->mi_command == nullptr)
670 Py_RETURN_FALSE;
671 Py_RETURN_TRUE;
672}
673
674/* Set the gdb.MICommand.installed property. The property can be set to
675 either true or false. Setting the property to true will cause the
676 command to be installed into the MI command table (if it isn't
677 already), while setting this property to false will cause the command
678 to be removed from the MI command table (if it is present). */
679
680static int
681micmdpy_set_installed (PyObject *self, PyObject *newvalue, void *closure)
682{
683 struct micmdpy_object *micmd_obj = (struct micmdpy_object *) self;
684
685 bool installed_p = PyObject_IsTrue (newvalue);
686 if (installed_p == (micmd_obj->mi_command != nullptr))
687 return 0;
688
689 if (installed_p)
690 return micmdpy_install_command (micmd_obj);
691 else
692 return micmdpy_uninstall_command (micmd_obj);
693}
694
695/* The gdb.MICommand properties. */
696
698 { "name", micmdpy_get_name, nullptr, "The command's name.", nullptr },
700 "Is this command installed for use.", nullptr },
701 { nullptr } /* Sentinel. */
702};
703
704/* The gdb.MICommand descriptor. */
705
706PyTypeObject micmdpy_object_type = {
707 PyVarObject_HEAD_INIT (nullptr, 0) "gdb.MICommand", /*tp_name */
708 sizeof (micmdpy_object), /*tp_basicsize */
709 0, /*tp_itemsize */
710 micmdpy_dealloc, /*tp_dealloc */
711 0, /*tp_print */
712 0, /*tp_getattr */
713 0, /*tp_setattr */
714 0, /*tp_compare */
715 0, /*tp_repr */
716 0, /*tp_as_number */
717 0, /*tp_as_sequence */
718 0, /*tp_as_mapping */
719 0, /*tp_hash */
720 0, /*tp_call */
721 0, /*tp_str */
722 0, /*tp_getattro */
723 0, /*tp_setattro */
724 0, /*tp_as_buffer */
725 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags */
726 "GDB mi-command object", /* tp_doc */
727 0, /* tp_traverse */
728 0, /* tp_clear */
729 0, /* tp_richcompare */
730 0, /* tp_weaklistoffset */
731 0, /* tp_iter */
732 0, /* tp_iternext */
733 0, /* tp_methods */
734 0, /* tp_members */
735 micmdpy_object_getset, /* tp_getset */
736 0, /* tp_base */
737 0, /* tp_dict */
738 0, /* tp_descr_get */
739 0, /* tp_descr_set */
740 0, /* tp_dictoffset */
741 micmdpy_init, /* tp_init */
742 0, /* tp_alloc */
743};
744
746void
748{
750 ("py-micmd", class_maintenance, &pymicmd_debug,
751 _("Set Python micmd debugging."),
752 _("Show Python micmd debugging."),
753 _("When on, Python micmd debugging is enabled."),
754 nullptr,
757}
758
constexpr string_view get()
Definition 70483.cc:49
const char *const name
void xfree(void *)
const char * host_charset(void)
Definition charset.c:416
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
Definition ui-out.c:511
void field_signed(const char *fldname, LONGEST value)
Definition ui-out.c:437
struct cmd_list_element * showdebuglist
Definition cli-cmds.c:167
struct cmd_list_element * setdebuglist
Definition cli-cmds.c:165
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:809
@ class_maintenance
Definition command.h:65
mi_command * mi_cmd_lookup(const char *command)
Definition mi-cmds.c:364
void remove_mi_cmd_entries(remove_mi_cmd_entries_ftype callback)
Definition mi-cmds.c:134
bool remove_mi_cmd_entry(const std::string &name)
Definition mi-cmds.c:122
bool insert_mi_cmd_entry(mi_command_up command)
Definition mi-cmds.c:106
static void show_pymicmd_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition py-micmd.c:39
static int micmdpy_init(PyObject *self, PyObject *args, PyObject *kwargs)
Definition py-micmd.c:501
static void micmdpy_dealloc(PyObject *obj)
Definition py-micmd.c:586
static int micmdpy_install_command(micmdpy_object *obj)
Definition py-micmd.c:454
static void serialize_mi_result(PyObject *result)
Definition py-micmd.c:331
void _initialize_py_micmd()
Definition py-micmd.c:747
PyTypeObject micmdpy_object_type
Definition py-micmd.c:706
#define PYMICMD_SCOPED_DEBUG_ENTER_EXIT
Definition py-micmd.c:52
static PyObject * micmdpy_get_installed(PyObject *self, void *closure)
Definition py-micmd.c:665
static int micmdpy_set_installed(PyObject *self, PyObject *newvalue, void *closure)
Definition py-micmd.c:681
#define pymicmd_debug_printf(fmt,...)
Definition py-micmd.c:47
static PyObject * invoke_cst
Definition py-micmd.c:174
static void gdbpy_finalize_micommands()
Definition py-micmd.c:636
std::unique_ptr< mi_command_py > mi_command_py_up
Definition py-micmd.c:167
static gdb_PyGetSetDef micmdpy_object_getset[]
Definition py-micmd.c:697
static PyObject * micmdpy_get_name(PyObject *self, void *closure)
Definition py-micmd.c:651
static void serialize_mi_result_1(PyObject *result, const char *field_name)
Definition py-micmd.c:248
static gdb::unique_xmalloc_ptr< char > py_object_to_mi_key(PyObject *key_obj)
Definition py-micmd.c:185
static mi_command_py * as_mi_command_py(mi_command *cmd)
Definition py-micmd.c:414
static bool pymicmd_debug
Definition py-micmd.c:34
static int micmdpy_uninstall_command(micmdpy_object *obj)
Definition py-micmd.c:424
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_micommands()
Definition py-micmd.c:615
int value
Definition py-param.c:79
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
Definition py-ref.h:42
static gdbpy_ref field_name(struct type *type, int field)
Definition py-type.c:234
gdb::unique_xmalloc_ptr< char > python_string_to_target_string(PyObject *obj)
Definition py-utils.c:114
void gdbpy_error(const char *fmt,...)
Definition py-utils.c:348
gdb::unique_xmalloc_ptr< char > gdbpy_obj_to_string(PyObject *obj)
Definition py-utils.c:173
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
Definition py-utils.c:334
void gdbpy_handle_exception()
Definition py-utils.c:369
PyObject * gdb_module
long gdb_py_longest
#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
#define GDBPY_INITIALIZE_FILE(INIT,...)
#define gdb_py_long_as_long_and_overflow
static int gdb_PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, const char **keywords,...)
void swap_python_object(micmdpy_object *new_pyobj)
Definition py-micmd.c:130
gdbpy_ref< micmdpy_object > m_pyobj
Definition py-micmd.c:164
virtual void invoke(struct mi_parse *parse) const override
Definition py-micmd.c:352
mi_command_py(const char *name, micmdpy_object *object)
Definition py-micmd.c:89
static void validate_installation(micmdpy_object *cmd_obj)
Definition py-micmd.c:397
const char * name() const
Definition mi-cmds.h:162
mi_command(const char *name, int *suppress_notification)
Definition mi-cmds.c:177
char ** argv
Definition mi-parse.h:75
int argc
Definition mi-parse.h:76
void parse_argv()
Definition mi-parse.c:110
gdb::unique_xmalloc_ptr< char > command
Definition mi-parse.h:71
const char * args()
Definition mi-parse.c:224
PyObject_HEAD struct mi_command_py * mi_command
Definition py-micmd.c:66
char * mi_command_name
Definition py-micmd.c:77
Definition value.h:130
#define current_uiout
Definition ui-out.h:40
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
int PyObject
Definition varobj.c:41
#define nullptr
Definition x86-cpuid.h:28