aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2010-08-07 15:00:39 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2010-08-07 15:00:39 +0000
commit5da1313be24d27eef6103a478f75345723e65614 (patch)
tree0c318f59ab4f7315ffe7d6ce240f1edef083217d /gdb/top.c
parent8574ee7158424df46e8e7f9b4937f24345ee343a (diff)
downloadgdb-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/top.c')
-rw-r--r--gdb/top.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 81a2b35..b29e68d 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -458,6 +458,39 @@ execute_command (char *p, int from_tty)
}
}
+/* Run execute_command for P and FROM_TTY. Capture its output into the
+ returned string, do not display it to the screen. BATCH_FLAG will be
+ temporarily set to true. */
+
+char *
+execute_command_to_string (char *p, int from_tty)
+{
+ struct ui_file *str_file;
+ struct cleanup *cleanup;
+ char *retval;
+
+ /* GDB_STDOUT should be better already restored during these
+ restoration callbacks. */
+ cleanup = set_batch_flag_and_make_cleanup_restore_page_info ();
+
+ 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;
+
+ execute_command (p, from_tty);
+
+ retval = ui_file_xstrdup (str_file, NULL);
+
+ do_cleanups (cleanup);
+
+ return retval;
+}
+
/* Read commands from `instream' and execute them
until end of file or error reading instream. */