diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-08-07 15:00:39 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-08-07 15:00:39 +0000 |
commit | 5da1313be24d27eef6103a478f75345723e65614 (patch) | |
tree | 0c318f59ab4f7315ffe7d6ce240f1edef083217d /gdb/python | |
parent | 8574ee7158424df46e8e7f9b4937f24345ee343a (diff) | |
download | gdb-5da1313be24d27eef6103a478f75345723e65614.zip gdb-5da1313be24d27eef6103a478f75345723e65614.tar.gz gdb-5da1313be24d27eef6103a478f75345723e65614.tar.bz2 |
gdb/
* defs.h (make_cleanup_restore_uinteger, make_cleanup_restore_ui_file)
(make_cleanup_restore_page_info)
(set_batch_flag_and_make_cleanup_restore_page_info): New declarations.
* gdbcmd.h (execute_command_to_string): New declaration.
* python/python.c (struct restore_ui_file_closure, restore_ui_file)
(make_cleanup_restore_ui_file): Move to utils.c
(execute_gdb_command) <to_string>: Move ...
* top.c (execute_command_to_string): ... here. Call
set_batch_flag_and_make_cleanup_restore_page_info.
* utils.c (make_cleanup_restore_integer): New source file blank line.
(make_cleanup_restore_uinteger): New.
(struct restore_ui_file_closure, do_restore_ui_file)
(make_cleanup_restore_ui_file): Move here from python/python.c.
(init_page_info) <batch_flag>
(do_restore_page_info_cleanup, make_cleanup_restore_page_info)
(set_batch_flag_and_make_cleanup_restore_page_info): New.
gdb/testsuite/
* gdb.python/python.exp (show height, set height 10)
(verify pagination beforehand, verify pagination beforehand: q)
(gdb.execute does not page, verify pagination afterwards)
(verify pagination afterwards: q): New.
gdb/doc/
* gdb.texinfo (Mode Options) <-batch>
(Basic Python) <gdb.execute>: Describe setting width and height.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/python.c | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c index 6680126..7346fba 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -309,33 +309,6 @@ gdbpy_target_wide_charset (PyObject *self, PyObject *args) return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL); } -struct restore_ui_file_closure -{ - struct ui_file **variable; - struct ui_file *value; -}; - -static void -restore_ui_file (void *p) -{ - struct restore_ui_file_closure *closure = p; - - *(closure->variable) = closure->value; -} - -/* Remember the current value of *VARIABLE and make it restored when - the cleanup is run. */ -struct cleanup * -make_cleanup_restore_ui_file (struct ui_file **variable) -{ - struct restore_ui_file_closure *c = XNEW (struct restore_ui_file_closure); - - c->variable = variable; - c->value = *variable; - - return make_cleanup_dtor (restore_ui_file, (void *) c, xfree); -} - /* A Python function which evaluates a string using the gdb CLI. */ static PyObject * @@ -376,27 +349,15 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) /* Copy the argument text in case the command modifies it. */ char *copy = xstrdup (arg); struct cleanup *cleanup = make_cleanup (xfree, copy); - struct ui_file *str_file = NULL; if (to_string) + result = execute_command_to_string (copy, from_tty); + else { - str_file = mem_fileopen (); - - make_cleanup_restore_ui_file (&gdb_stdout); - make_cleanup_restore_ui_file (&gdb_stderr); - make_cleanup_ui_file_delete (str_file); - - gdb_stdout = str_file; - gdb_stderr = str_file; + result = NULL; + execute_command (copy, from_tty); } - execute_command (copy, from_tty); - - if (str_file) - result = ui_file_xstrdup (str_file, NULL); - else - result = NULL; - do_cleanups (cleanup); } GDB_PY_HANDLE_EXCEPTION (except); |