aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2019-04-26 20:52:16 +0200
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2019-05-31 17:11:38 +0200
commitb8fd091888383703f5d708c597c496d7b9e47a21 (patch)
tree24b079241f130a85492987818551fb815961a2c8 /gdb/top.c
parent68bb5386b84af4031175bf186269eb6b54b8611d (diff)
downloadbinutils-b8fd091888383703f5d708c597c496d7b9e47a21.zip
binutils-b8fd091888383703f5d708c597c496d7b9e47a21.tar.gz
binutils-b8fd091888383703f5d708c597c496d7b9e47a21.tar.bz2
Add function execute_command_to_ui_file
2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdbcmd.h (execute_command_to_ui_file): New declaration. top.c (execute_command_to_ui_file): New function, mostly a copy of execute_command_to_string. (execute_command_to_string): Implement by calling execute_command_to_ui_file.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 518c5eb..4f55d6a 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -665,13 +665,12 @@ execute_command (const char *p, int from_tty)
cleanup_if_error.release ();
}
-/* 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
+/* Run execute_command for P and FROM_TTY. Sends its output to FILE,
+ do not display it to the screen. BATCH_FLAG will be
temporarily set to true. */
-std::string
-execute_command_to_string (const char *p, int from_tty,
- bool term_out)
+void
+execute_command_to_ui_file (struct ui_file *file, const char *p, int from_tty)
{
/* GDB_STDOUT should be better already restored during these
restoration callbacks. */
@@ -679,26 +678,36 @@ execute_command_to_string (const char *p, int from_tty,
scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
- string_file str_file (term_out);
-
{
- current_uiout->redirect (&str_file);
+ current_uiout->redirect (file);
ui_out_redirect_pop redirect_popper (current_uiout);
scoped_restore save_stdout
- = make_scoped_restore (&gdb_stdout, &str_file);
+ = make_scoped_restore (&gdb_stdout, file);
scoped_restore save_stderr
- = make_scoped_restore (&gdb_stderr, &str_file);
+ = make_scoped_restore (&gdb_stderr, file);
scoped_restore save_stdlog
- = make_scoped_restore (&gdb_stdlog, &str_file);
+ = make_scoped_restore (&gdb_stdlog, file);
scoped_restore save_stdtarg
- = make_scoped_restore (&gdb_stdtarg, &str_file);
+ = make_scoped_restore (&gdb_stdtarg, file);
scoped_restore save_stdtargerr
- = make_scoped_restore (&gdb_stdtargerr, &str_file);
+ = make_scoped_restore (&gdb_stdtargerr, file);
execute_command (p, 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. */
+
+std::string
+execute_command_to_string (const char *p, int from_tty,
+ bool term_out)
+{
+ string_file str_file (term_out);
+ execute_command_to_ui_file (&str_file, p, from_tty);
return std::move (str_file.string ());
}