gdb/
[binutils-gdb.git] / gdb / python / python.c
1 /* General python/gdb code
2
3 Copyright (C) 2008, 2009, 2010 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 #include "defs.h"
21 #include "arch-utils.h"
22 #include "command.h"
23 #include "ui-out.h"
24 #include "cli/cli-script.h"
25 #include "gdbcmd.h"
26 #include "progspace.h"
27 #include "objfiles.h"
28 #include "value.h"
29 #include "language.h"
30 #include "exceptions.h"
31
32 #include <ctype.h>
33
34 /* True if we should print the stack when catching a Python error,
35 false otherwise. */
36 static int gdbpy_should_print_stack = 1;
37
38 #ifdef HAVE_PYTHON
39
40 #include "python.h"
41 #include "libiberty.h"
42 #include "cli/cli-decode.h"
43 #include "charset.h"
44 #include "top.h"
45 #include "python-internal.h"
46 #include "version.h"
47 #include "target.h"
48 #include "gdbthread.h"
49
50 static PyMethodDef GdbMethods[];
51
52 PyObject *gdb_module;
53
54 /* Some string constants we may wish to use. */
55 PyObject *gdbpy_to_string_cst;
56 PyObject *gdbpy_children_cst;
57 PyObject *gdbpy_display_hint_cst;
58 PyObject *gdbpy_doc_cst;
59
60 /* The GdbError exception. */
61 PyObject *gdbpy_gdberror_exc;
62
63 /* Architecture and language to be used in callbacks from
64 the Python interpreter. */
65 struct gdbarch *python_gdbarch;
66 const struct language_defn *python_language;
67
68 /* Restore global language and architecture and Python GIL state
69 when leaving the Python interpreter. */
70
71 struct python_env
72 {
73 PyGILState_STATE state;
74 struct gdbarch *gdbarch;
75 const struct language_defn *language;
76 };
77
78 static void
79 restore_python_env (void *p)
80 {
81 struct python_env *env = (struct python_env *)p;
82
83 PyGILState_Release (env->state);
84 python_gdbarch = env->gdbarch;
85 python_language = env->language;
86 xfree (env);
87 }
88
89 /* Called before entering the Python interpreter to install the
90 current language and architecture to be used for Python values. */
91
92 struct cleanup *
93 ensure_python_env (struct gdbarch *gdbarch,
94 const struct language_defn *language)
95 {
96 struct python_env *env = xmalloc (sizeof *env);
97
98 env->state = PyGILState_Ensure ();
99 env->gdbarch = python_gdbarch;
100 env->language = python_language;
101
102 python_gdbarch = gdbarch;
103 python_language = language;
104
105 return make_cleanup (restore_python_env, env);
106 }
107
108
109 /* Given a command_line, return a command string suitable for passing
110 to Python. Lines in the string are separated by newlines. The
111 return value is allocated using xmalloc and the caller is
112 responsible for freeing it. */
113
114 static char *
115 compute_python_string (struct command_line *l)
116 {
117 struct command_line *iter;
118 char *script = NULL;
119 int size = 0;
120 int here;
121
122 for (iter = l; iter; iter = iter->next)
123 size += strlen (iter->line) + 1;
124
125 script = xmalloc (size + 1);
126 here = 0;
127 for (iter = l; iter; iter = iter->next)
128 {
129 int len = strlen (iter->line);
130
131 strcpy (&script[here], iter->line);
132 here += len;
133 script[here++] = '\n';
134 }
135 script[here] = '\0';
136 return script;
137 }
138
139 /* Take a command line structure representing a 'python' command, and
140 evaluate its body using the Python interpreter. */
141
142 void
143 eval_python_from_control_command (struct command_line *cmd)
144 {
145 int ret;
146 char *script;
147 struct cleanup *cleanup;
148
149 if (cmd->body_count != 1)
150 error (_("Invalid \"python\" block structure."));
151
152 cleanup = ensure_python_env (get_current_arch (), current_language);
153
154 script = compute_python_string (cmd->body_list[0]);
155 ret = PyRun_SimpleString (script);
156 xfree (script);
157 if (ret)
158 {
159 gdbpy_print_stack ();
160 error (_("Error while executing Python code."));
161 }
162
163 do_cleanups (cleanup);
164 }
165
166 /* Implementation of the gdb "python" command. */
167
168 static void
169 python_command (char *arg, int from_tty)
170 {
171 struct cleanup *cleanup;
172
173 cleanup = ensure_python_env (get_current_arch (), current_language);
174 while (arg && *arg && isspace (*arg))
175 ++arg;
176 if (arg && *arg)
177 {
178 if (PyRun_SimpleString (arg))
179 {
180 gdbpy_print_stack ();
181 error (_("Error while executing Python code."));
182 }
183 }
184 else
185 {
186 struct command_line *l = get_command_line (python_control, "");
187
188 make_cleanup_free_command_lines (&l);
189 execute_control_command_untraced (l);
190 }
191
192 do_cleanups (cleanup);
193 }
194
195 \f
196
197 /* Transform a gdb parameters's value into a Python value. May return
198 NULL (and set a Python exception) on error. Helper function for
199 get_parameter. */
200 PyObject *
201 gdbpy_parameter_value (enum var_types type, void *var)
202 {
203 switch (type)
204 {
205 case var_string:
206 case var_string_noescape:
207 case var_optional_filename:
208 case var_filename:
209 case var_enum:
210 {
211 char *str = * (char **) var;
212
213 if (! str)
214 str = "";
215 return PyString_Decode (str, strlen (str), host_charset (), NULL);
216 }
217
218 case var_boolean:
219 {
220 if (* (int *) var)
221 Py_RETURN_TRUE;
222 else
223 Py_RETURN_FALSE;
224 }
225
226 case var_auto_boolean:
227 {
228 enum auto_boolean ab = * (enum auto_boolean *) var;
229
230 if (ab == AUTO_BOOLEAN_TRUE)
231 Py_RETURN_TRUE;
232 else if (ab == AUTO_BOOLEAN_FALSE)
233 Py_RETURN_FALSE;
234 else
235 Py_RETURN_NONE;
236 }
237
238 case var_integer:
239 if ((* (int *) var) == INT_MAX)
240 Py_RETURN_NONE;
241 /* Fall through. */
242 case var_zinteger:
243 return PyLong_FromLong (* (int *) var);
244
245 case var_uinteger:
246 {
247 unsigned int val = * (unsigned int *) var;
248
249 if (val == UINT_MAX)
250 Py_RETURN_NONE;
251 return PyLong_FromUnsignedLong (val);
252 }
253 }
254
255 return PyErr_Format (PyExc_RuntimeError,
256 _("Programmer error: unhandled type."));
257 }
258
259 /* A Python function which returns a gdb parameter's value as a Python
260 value. */
261
262 PyObject *
263 gdbpy_parameter (PyObject *self, PyObject *args)
264 {
265 struct cmd_list_element *alias, *prefix, *cmd;
266 char *arg, *newarg;
267 int found = -1;
268 volatile struct gdb_exception except;
269
270 if (! PyArg_ParseTuple (args, "s", &arg))
271 return NULL;
272
273 newarg = concat ("show ", arg, (char *) NULL);
274
275 TRY_CATCH (except, RETURN_MASK_ALL)
276 {
277 found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd);
278 }
279 xfree (newarg);
280 GDB_PY_HANDLE_EXCEPTION (except);
281 if (!found)
282 return PyErr_Format (PyExc_RuntimeError,
283 _("Could not find parameter `%s'."), arg);
284
285 if (! cmd->var)
286 return PyErr_Format (PyExc_RuntimeError,
287 _("`%s' is not a parameter."), arg);
288 return gdbpy_parameter_value (cmd->var_type, cmd->var);
289 }
290
291 /* Wrapper for target_charset. */
292
293 static PyObject *
294 gdbpy_target_charset (PyObject *self, PyObject *args)
295 {
296 const char *cset = target_charset (python_gdbarch);
297
298 return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
299 }
300
301 /* Wrapper for target_wide_charset. */
302
303 static PyObject *
304 gdbpy_target_wide_charset (PyObject *self, PyObject *args)
305 {
306 const char *cset = target_wide_charset (python_gdbarch);
307
308 return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
309 }
310
311 /* A Python function which evaluates a string using the gdb CLI. */
312
313 static PyObject *
314 execute_gdb_command (PyObject *self, PyObject *args)
315 {
316 char *arg;
317 PyObject *from_tty_obj = NULL;
318 int from_tty;
319 int cmp;
320 volatile struct gdb_exception except;
321
322 if (! PyArg_ParseTuple (args, "s|O!", &arg, &PyBool_Type, &from_tty_obj))
323 return NULL;
324
325 from_tty = 0;
326 if (from_tty_obj)
327 {
328 cmp = PyObject_IsTrue (from_tty_obj);
329 if (cmp < 0)
330 return NULL;
331 from_tty = cmp;
332 }
333
334 TRY_CATCH (except, RETURN_MASK_ALL)
335 {
336 /* Copy the argument text in case the command modifies it. */
337 char *copy = xstrdup (arg);
338 struct cleanup *cleanup = make_cleanup (xfree, copy);
339
340 execute_command (copy, from_tty);
341 do_cleanups (cleanup);
342 }
343 GDB_PY_HANDLE_EXCEPTION (except);
344
345 /* Do any commands attached to breakpoint we stopped at. */
346 bpstat_do_actions ();
347
348 Py_RETURN_NONE;
349 }
350
351 /* Parse a string and evaluate it as an expression. */
352 static PyObject *
353 gdbpy_parse_and_eval (PyObject *self, PyObject *args)
354 {
355 char *expr_str;
356 struct value *result = NULL;
357 volatile struct gdb_exception except;
358
359 if (!PyArg_ParseTuple (args, "s", &expr_str))
360 return NULL;
361
362 TRY_CATCH (except, RETURN_MASK_ALL)
363 {
364 result = parse_and_eval (expr_str);
365 }
366 GDB_PY_HANDLE_EXCEPTION (except);
367
368 return value_to_value_object (result);
369 }
370
371 /* Read a file as Python code. STREAM is the input file; FILE is the
372 name of the file.
373 STREAM is not closed, that is the caller's responsibility. */
374
375 void
376 source_python_script (FILE *stream, const char *file)
377 {
378 struct cleanup *cleanup;
379
380 cleanup = ensure_python_env (get_current_arch (), current_language);
381
382 /* Note: If an exception occurs python will print the traceback and
383 clear the error indicator. */
384 PyRun_SimpleFile (stream, file);
385
386 do_cleanups (cleanup);
387 }
388
389 \f
390
391 /* Printing. */
392
393 /* A python function to write a single string using gdb's filtered
394 output stream. */
395 static PyObject *
396 gdbpy_write (PyObject *self, PyObject *args)
397 {
398 char *arg;
399
400 if (! PyArg_ParseTuple (args, "s", &arg))
401 return NULL;
402 printf_filtered ("%s", arg);
403 Py_RETURN_NONE;
404 }
405
406 /* A python function to flush gdb's filtered output stream. */
407 static PyObject *
408 gdbpy_flush (PyObject *self, PyObject *args)
409 {
410 gdb_flush (gdb_stdout);
411 Py_RETURN_NONE;
412 }
413
414 /* Print a python exception trace, or print nothing and clear the
415 python exception, depending on gdbpy_should_print_stack. Only call
416 this if a python exception is set. */
417 void
418 gdbpy_print_stack (void)
419 {
420 if (gdbpy_should_print_stack)
421 {
422 PyErr_Print ();
423 /* PyErr_Print doesn't necessarily end output with a newline.
424 This works because Python's stdout/stderr is fed through
425 printf_filtered. */
426 begin_line ();
427 }
428 else
429 PyErr_Clear ();
430 }
431
432 \f
433
434 /* Return the current Progspace.
435 There always is one. */
436
437 static PyObject *
438 gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2)
439 {
440 PyObject *result;
441
442 result = pspace_to_pspace_object (current_program_space);
443 if (result)
444 Py_INCREF (result);
445 return result;
446 }
447
448 /* Return a sequence holding all the Progspaces. */
449
450 static PyObject *
451 gdbpy_progspaces (PyObject *unused1, PyObject *unused2)
452 {
453 struct program_space *ps;
454 PyObject *list;
455
456 list = PyList_New (0);
457 if (!list)
458 return NULL;
459
460 ALL_PSPACES (ps)
461 {
462 PyObject *item = pspace_to_pspace_object (ps);
463
464 if (!item || PyList_Append (list, item) == -1)
465 {
466 Py_DECREF (list);
467 return NULL;
468 }
469 }
470
471 return list;
472 }
473
474 \f
475
476 /* The "current" objfile. This is set when gdb detects that a new
477 objfile has been loaded. It is only set for the duration of a call to
478 source_python_script_for_objfile; it is NULL at other times. */
479 static struct objfile *gdbpy_current_objfile;
480
481 /* Set the current objfile to OBJFILE and then read STREAM,FILE as
482 Python code. */
483
484 void
485 source_python_script_for_objfile (struct objfile *objfile,
486 FILE *stream, const char *file)
487 {
488 struct cleanup *cleanups;
489
490 cleanups = ensure_python_env (get_objfile_arch (objfile), current_language);
491 gdbpy_current_objfile = objfile;
492
493 /* Note: If an exception occurs python will print the traceback and
494 clear the error indicator. */
495 PyRun_SimpleFile (stream, file);
496
497 do_cleanups (cleanups);
498 gdbpy_current_objfile = NULL;
499 }
500
501 /* Return the current Objfile, or None if there isn't one. */
502
503 static PyObject *
504 gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
505 {
506 PyObject *result;
507
508 if (! gdbpy_current_objfile)
509 Py_RETURN_NONE;
510
511 result = objfile_to_objfile_object (gdbpy_current_objfile);
512 if (result)
513 Py_INCREF (result);
514 return result;
515 }
516
517 /* Return a sequence holding all the Objfiles. */
518
519 static PyObject *
520 gdbpy_objfiles (PyObject *unused1, PyObject *unused2)
521 {
522 struct objfile *objf;
523 PyObject *list;
524
525 list = PyList_New (0);
526 if (!list)
527 return NULL;
528
529 ALL_OBJFILES (objf)
530 {
531 PyObject *item = objfile_to_objfile_object (objf);
532
533 if (!item || PyList_Append (list, item) == -1)
534 {
535 Py_DECREF (list);
536 return NULL;
537 }
538 }
539
540 return list;
541 }
542
543 #else /* HAVE_PYTHON */
544
545 /* Dummy implementation of the gdb "python" command. */
546
547 static void
548 python_command (char *arg, int from_tty)
549 {
550 while (arg && *arg && isspace (*arg))
551 ++arg;
552 if (arg && *arg)
553 error (_("Python scripting is not supported in this copy of GDB."));
554 else
555 {
556 struct command_line *l = get_command_line (python_control, "");
557 struct cleanup *cleanups = make_cleanup_free_command_lines (&l);
558
559 execute_control_command_untraced (l);
560 do_cleanups (cleanups);
561 }
562 }
563
564 void
565 eval_python_from_control_command (struct command_line *cmd)
566 {
567 error (_("Python scripting is not supported in this copy of GDB."));
568 }
569
570 void
571 source_python_script (FILE *stream, const char *file)
572 {
573 throw_error (UNSUPPORTED_ERROR,
574 _("Python scripting is not supported in this copy of GDB."));
575 }
576
577 #endif /* HAVE_PYTHON */
578
579 \f
580
581 /* Lists for 'maint set python' commands. */
582
583 struct cmd_list_element *set_python_list;
584 struct cmd_list_element *show_python_list;
585
586 /* Function for use by 'maint set python' prefix command. */
587
588 static void
589 set_python (char *args, int from_tty)
590 {
591 help_list (set_python_list, "maintenance set python ", -1, gdb_stdout);
592 }
593
594 /* Function for use by 'maint show python' prefix command. */
595
596 static void
597 show_python (char *args, int from_tty)
598 {
599 cmd_show_list (show_python_list, from_tty, "");
600 }
601
602 /* Initialize the Python code. */
603
604 /* Provide a prototype to silence -Wmissing-prototypes. */
605 extern initialize_file_ftype _initialize_python;
606
607 void
608 _initialize_python (void)
609 {
610 add_com ("python", class_obscure, python_command,
611 #ifdef HAVE_PYTHON
612 _("\
613 Evaluate a Python command.\n\
614 \n\
615 The command can be given as an argument, for instance:\n\
616 \n\
617 python print 23\n\
618 \n\
619 If no argument is given, the following lines are read and used\n\
620 as the Python commands. Type a line containing \"end\" to indicate\n\
621 the end of the command.")
622 #else /* HAVE_PYTHON */
623 _("\
624 Evaluate a Python command.\n\
625 \n\
626 Python scripting is not supported in this copy of GDB.\n\
627 This command is only a placeholder.")
628 #endif /* HAVE_PYTHON */
629 );
630
631 add_prefix_cmd ("python", no_class, show_python,
632 _("Prefix command for python maintenance settings."),
633 &show_python_list, "maintenance show python ", 0,
634 &maintenance_show_cmdlist);
635 add_prefix_cmd ("python", no_class, set_python,
636 _("Prefix command for python maintenance settings."),
637 &set_python_list, "maintenance set python ", 0,
638 &maintenance_set_cmdlist);
639
640 add_setshow_boolean_cmd ("print-stack", class_maintenance,
641 &gdbpy_should_print_stack, _("\
642 Enable or disable printing of Python stack dump on error."), _("\
643 Show whether Python stack will be printed on error."), _("\
644 Enables or disables printing of Python stack traces."),
645 NULL, NULL,
646 &set_python_list,
647 &show_python_list);
648
649 #ifdef HAVE_PYTHON
650 #ifdef WITH_PYTHON_PATH
651 /* Work around problem where python gets confused about where it is,
652 and then can't find its libraries, etc.
653 NOTE: Python assumes the following layout:
654 /foo/bin/python
655 /foo/lib/pythonX.Y/...
656 This must be done before calling Py_Initialize. */
657 Py_SetProgramName (concat (ldirname (python_libdir), SLASH_STRING, "bin",
658 SLASH_STRING, "python", NULL));
659 #endif
660
661 Py_Initialize ();
662 PyEval_InitThreads ();
663
664 gdb_module = Py_InitModule ("gdb", GdbMethods);
665
666 /* The casts to (char*) are for python 2.4. */
667 PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version);
668 PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
669 PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
670
671 gdbpy_gdberror_exc = PyErr_NewException ("gdb.GdbError", NULL, NULL);
672 PyModule_AddObject (gdb_module, "GdbError", gdbpy_gdberror_exc);
673
674 gdbpy_initialize_auto_load ();
675 gdbpy_initialize_values ();
676 gdbpy_initialize_frames ();
677 gdbpy_initialize_commands ();
678 gdbpy_initialize_symbols ();
679 gdbpy_initialize_symtabs ();
680 gdbpy_initialize_blocks ();
681 gdbpy_initialize_functions ();
682 gdbpy_initialize_parameters ();
683 gdbpy_initialize_types ();
684 gdbpy_initialize_pspace ();
685 gdbpy_initialize_objfile ();
686 gdbpy_initialize_breakpoints ();
687 gdbpy_initialize_lazy_string ();
688
689 PyRun_SimpleString ("import gdb");
690 PyRun_SimpleString ("gdb.pretty_printers = []");
691
692 gdbpy_to_string_cst = PyString_FromString ("to_string");
693 gdbpy_children_cst = PyString_FromString ("children");
694 gdbpy_display_hint_cst = PyString_FromString ("display_hint");
695 gdbpy_doc_cst = PyString_FromString ("__doc__");
696
697 /* Create a couple objects which are used for Python's stdout and
698 stderr. */
699 PyRun_SimpleString ("\
700 import sys\n\
701 class GdbOutputFile:\n\
702 def close(self):\n\
703 # Do nothing.\n\
704 return None\n\
705 \n\
706 def isatty(self):\n\
707 return False\n\
708 \n\
709 def write(self, s):\n\
710 gdb.write(s)\n\
711 \n\
712 def writelines(self, iterable):\n\
713 for line in iterable:\n\
714 self.write(line)\n\
715 \n\
716 def flush(self):\n\
717 gdb.flush()\n\
718 \n\
719 sys.stderr = GdbOutputFile()\n\
720 sys.stdout = GdbOutputFile()\n\
721 ");
722
723 /* Release the GIL while gdb runs. */
724 PyThreadState_Swap (NULL);
725 PyEval_ReleaseLock ();
726
727 #endif /* HAVE_PYTHON */
728 }
729
730 \f
731
732 #if HAVE_PYTHON
733
734 static PyMethodDef GdbMethods[] =
735 {
736 { "history", gdbpy_history, METH_VARARGS,
737 "Get a value from history" },
738 { "execute", execute_gdb_command, METH_VARARGS,
739 "Execute a gdb command" },
740 { "parameter", gdbpy_parameter, METH_VARARGS,
741 "Return a gdb parameter's value" },
742
743 { "breakpoints", gdbpy_breakpoints, METH_NOARGS,
744 "Return a tuple of all breakpoint objects" },
745
746 { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS,
747 "Find the default visualizer for a Value." },
748
749 { "current_progspace", gdbpy_get_current_progspace, METH_NOARGS,
750 "Return the current Progspace." },
751 { "progspaces", gdbpy_progspaces, METH_NOARGS,
752 "Return a sequence of all progspaces." },
753
754 { "current_objfile", gdbpy_get_current_objfile, METH_NOARGS,
755 "Return the current Objfile being loaded, or None." },
756 { "objfiles", gdbpy_objfiles, METH_NOARGS,
757 "Return a sequence of all loaded objfiles." },
758
759 { "selected_frame", gdbpy_selected_frame, METH_NOARGS,
760 "selected_frame () -> gdb.Frame.\n\
761 Return the selected frame object." },
762 { "frame_stop_reason_string", gdbpy_frame_stop_reason_string, METH_VARARGS,
763 "stop_reason_string (Integer) -> String.\n\
764 Return a string explaining unwind stop reason." },
765
766 { "lookup_type", (PyCFunction) gdbpy_lookup_type,
767 METH_VARARGS | METH_KEYWORDS,
768 "lookup_type (name [, block]) -> type\n\
769 Return a Type corresponding to the given name." },
770 { "lookup_symbol", (PyCFunction) gdbpy_lookup_symbol,
771 METH_VARARGS | METH_KEYWORDS,
772 "lookup_symbol (name [, block] [, domain]) -> (symbol, is_field_of_this)\n\
773 Return a tuple with the symbol corresponding to the given name (or None) and\n\
774 a boolean indicating if name is a field of the current implied argument\n\
775 `this' (when the current language is object-oriented)." },
776 { "block_for_pc", gdbpy_block_for_pc, METH_VARARGS,
777 "Return the block containing the given pc value, or None." },
778 { "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS,
779 "parse_and_eval (String) -> Value.\n\
780 Parse String as an expression, evaluate it, and return the result as a Value."
781 },
782
783 { "target_charset", gdbpy_target_charset, METH_NOARGS,
784 "target_charset () -> string.\n\
785 Return the name of the current target charset." },
786 { "target_wide_charset", gdbpy_target_wide_charset, METH_NOARGS,
787 "target_wide_charset () -> string.\n\
788 Return the name of the current target wide charset." },
789
790 { "string_to_argv", gdbpy_string_to_argv, METH_VARARGS,
791 "string_to_argv (String) -> Array.\n\
792 Parse String and return an argv-like array.\n\
793 Arguments are separate by spaces and may be quoted."
794 },
795
796 { "write", gdbpy_write, METH_VARARGS,
797 "Write a string using gdb's filtered stream." },
798 { "flush", gdbpy_flush, METH_NOARGS,
799 "Flush gdb's filtered stdout stream." },
800
801 {NULL, NULL, 0, NULL}
802 };
803
804 #endif /* HAVE_PYTHON */