From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: gdb-patches@sourceware.org
Cc: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Subject: [RFAv3 3/6] Add function execute_command_to_ui_file
Date: Sat, 04 May 2019 16:18:00 -0000 [thread overview]
Message-ID: <20190504161753.15530-4-philippe.waroquiers@skynet.be> (raw)
In-Reply-To: <20190504161753.15530-1-philippe.waroquiers@skynet.be>
2019-05-04 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.
---
gdb/gdbcmd.h | 2 ++
gdb/top.c | 35 ++++++++++++++++++++++-------------
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
index 5d0e697d83..1b47719f18 100644
--- a/gdb/gdbcmd.h
+++ b/gdb/gdbcmd.h
@@ -139,6 +139,8 @@ extern void execute_command (const char *, int);
as cli_styling. */
extern std::string execute_command_to_string (const char *p, int from_tty,
bool term_out);
+extern void execute_command_to_ui_file (struct ui_file *file,
+ const char *p, int from_tty);
extern void print_command_line (struct command_line *, unsigned int,
struct ui_file *);
diff --git a/gdb/top.c b/gdb/top.c
index 70f685ffad..900c3fc3e2 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 (¤t_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 ());
}
--
2.20.1
next prev parent reply other threads:[~2019-05-04 16:18 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-04 16:18 [RFAv3 0/6] Implement | (pipe) command Philippe Waroquiers
2019-05-04 16:18 ` Philippe Waroquiers [this message]
2019-05-04 16:18 ` [RFAv3 2/6] Improve process exit status macros on MinGW Philippe Waroquiers
2019-05-27 17:33 ` Pedro Alves
2019-05-27 18:38 ` Eli Zaretskii
2019-05-29 12:38 ` Pedro Alves
2019-05-29 15:03 ` Eli Zaretskii
2019-05-30 10:26 ` Philippe Waroquiers
2019-12-17 17:00 ` Eli Zaretskii
2019-12-17 17:51 ` Pedro Alves
2019-12-18 17:08 ` Eli Zaretskii
2019-12-18 17:42 ` Pedro Alves
2019-12-18 18:33 ` Eli Zaretskii
2019-12-25 15:57 ` Eli Zaretskii
2020-01-03 19:59 ` Pedro Alves
2020-01-03 20:08 ` Pedro Alves
2020-01-03 20:34 ` Eli Zaretskii
2020-01-06 11:57 ` Pedro Alves
2020-01-06 16:17 ` Eli Zaretskii
2020-01-06 18:51 ` Pedro Alves
2020-01-06 19:26 ` Eli Zaretskii
2020-01-06 18:59 ` Hannes Domani via gdb-patches
2020-01-06 19:34 ` Eli Zaretskii
2020-01-06 19:38 ` Hannes Domani via gdb-patches
2020-01-06 19:55 ` Eli Zaretskii
2020-01-03 17:04 ` Pedro Alves
2019-05-04 16:18 ` [RFAv3 5/6] Test the | (pipe) command Philippe Waroquiers
2019-05-27 17:49 ` Pedro Alves
2019-05-04 16:18 ` [RFAv3 4/6] Implement " Philippe Waroquiers
2019-05-27 17:48 ` Pedro Alves
2019-05-27 17:55 ` Pedro Alves
2019-05-04 16:18 ` [RFAv3 1/6] Add previous_saved_command_line to allow a command to repeat a previous command Philippe Waroquiers
2019-05-27 17:29 ` Pedro Alves
2019-05-04 16:18 ` [RFAv3 6/6] NEWS and documentation for | (pipe) command Philippe Waroquiers
2019-05-04 16:26 ` Eli Zaretskii
2019-05-04 16:33 ` Eli Zaretskii
2019-05-27 17:51 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190504161753.15530-4-philippe.waroquiers@skynet.be \
--to=philippe.waroquiers@skynet.be \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).