From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 09/25] Make outstream be per UI
Date: Mon, 21 Mar 2016 15:27:00 -0000 [thread overview]
Message-ID: <1458573675-15478-10-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1458573675-15478-1-git-send-email-palves@redhat.com>
stderr_fileopen () references stderr directly, which doesn't work when
we have a separate UI with its own stderr-like stream. So this also
adds a "errstream" to "struct ui", and plumbs stderr_fileopen to take
a stream parameter.
---
gdb/event-top.c | 4 ++--
gdb/exceptions.c | 4 +++-
gdb/main.c | 6 +++++-
gdb/top.h | 4 ++++
gdb/ui-file.c | 4 ++--
gdb/ui-file.h | 4 ++--
6 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/gdb/event-top.c b/gdb/event-top.c
index c7dba5a..ea1e32e 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -1011,8 +1011,8 @@ gdb_setup_readline (void)
mess it up here. The sync stuff should really go away over
time. */
if (!batch_silent)
- gdb_stdout = stdio_fileopen (stdout);
- gdb_stderr = stderr_fileopen ();
+ gdb_stdout = stdio_fileopen (ui->outstream);
+ gdb_stderr = stderr_fileopen (ui->errstream);
gdb_stdlog = gdb_stderr; /* for moment */
gdb_stdtarg = gdb_stderr; /* for moment */
gdb_stdtargerr = gdb_stderr; /* for moment */
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 8ba86fc..3e5d870 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -26,6 +26,7 @@
#include "ui-out.h"
#include "serial.h"
#include "gdbthread.h"
+#include "top.h"
void
prepare_to_throw_exception (void)
@@ -37,6 +38,7 @@ prepare_to_throw_exception (void)
static void
print_flush (void)
{
+ struct ui *ui = current_ui;
struct serial *gdb_stdout_serial;
if (deprecated_error_begin_hook)
@@ -59,7 +61,7 @@ print_flush (void)
gdb_flush (gdb_stderr);
/* 3. The system-level buffer. */
- gdb_stdout_serial = serial_fdopen (1);
+ gdb_stdout_serial = serial_fdopen (fileno (ui->outstream));
if (gdb_stdout_serial)
{
serial_drain_output (gdb_stdout_serial);
diff --git a/gdb/main.c b/gdb/main.c
index eee9a8b..d070b4d 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -506,7 +506,11 @@ captured_main (void *data)
clear_quit_flag ();
saved_command_line = (char *) xstrdup ("");
+
ui->instream = stdin;
+ ui->outstream = stdout;
+ ui->errstream = stderr;
+
ui->input_fd = fileno (stdin);
#ifdef __MINGW32__
@@ -516,7 +520,7 @@ captured_main (void *data)
#endif
gdb_stdout = stdio_fileopen (stdout);
- gdb_stderr = stderr_fileopen ();
+ gdb_stderr = stderr_fileopen (stderr);
gdb_stdlog = gdb_stderr; /* for moment */
gdb_stdtarg = gdb_stderr; /* for moment */
diff --git a/gdb/top.h b/gdb/top.h
index beeb723..2c4c9f1 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -72,6 +72,10 @@ struct ui
Set to NULL if we are executing a user-defined command or
interacting via a GUI. */
FILE *instream;
+ /* Standard output stream. */
+ FILE *outstream;
+ /* Standard error stream. */
+ FILE *errstream;
/* The file descriptor for the input stream, so that we can register
it with the event loop. */
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index c86994d..d72e161 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -681,9 +681,9 @@ stderr_file_fputs (const char *linebuffer, struct ui_file *file)
#endif
struct ui_file *
-stderr_fileopen (void)
+stderr_fileopen (FILE *stream)
{
- struct ui_file *ui_file = stdio_fileopen (stderr);
+ struct ui_file *ui_file = stdio_fileopen (stream);
#ifdef __MINGW32__
/* There is no real line-buffering on Windows, see
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index a6ec135..f6df572 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -135,8 +135,8 @@ extern struct ui_file *mem_fileopen (void);
/* Open/create a STDIO based UI_FILE using the already open FILE. */
extern struct ui_file *stdio_fileopen (FILE *file);
-/* Create a ui_file from stderr. */
-extern struct ui_file *stderr_fileopen (void);
+/* Likewise, for stderr-like streams. */
+extern struct ui_file *stderr_fileopen (FILE *file);
/* Open NAME returning an STDIO based UI_FILE. */
--
2.5.0
next prev parent reply other threads:[~2016-03-21 15:27 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-21 15:21 [PATCH v2 00/25] Towards great frontend GDB consoles Pedro Alves
2016-03-21 15:21 ` [PATCH v2 01/25] Introduce "struct ui" Pedro Alves
2016-03-21 15:21 ` [PATCH v2 03/25] Make the interpreters be per UI Pedro Alves
2016-03-21 15:21 ` [PATCH v2 12/25] Make command line editing (use of readline) " Pedro Alves
2016-03-21 15:21 ` [PATCH v2 22/25] Make main_ui be heap allocated Pedro Alves
2016-03-22 10:14 ` Yao Qi
2016-05-06 11:50 ` Pedro Alves
2016-03-21 15:21 ` [PATCH v2 02/25] Make gdb_stdout&co be per UI Pedro Alves
2016-03-21 15:22 ` [PATCH v2 24/25] Add new command to create extra console/mi UI channels Pedro Alves
2016-03-21 16:31 ` Eli Zaretskii
2016-03-21 16:51 ` Pedro Alves
2016-03-21 17:12 ` Eli Zaretskii
2016-03-21 17:57 ` Pedro Alves
2016-05-26 11:43 ` Pedro Alves
2016-05-26 15:46 ` Eli Zaretskii
2016-05-26 16:03 ` Pedro Alves
2016-05-26 16:36 ` Eli Zaretskii
2016-05-26 16:41 ` Pedro Alves
2016-03-21 15:22 ` [PATCH v2 18/25] Replace the sync_execution global with a new enum prompt_state tristate Pedro Alves
2016-03-21 15:22 ` [PATCH v2 13/25] Always process target events in the main UI Pedro Alves
2016-03-22 10:26 ` Yao Qi
2016-05-06 11:53 ` Pedro Alves
2016-03-21 15:26 ` [PATCH v2 10/25] Delete def_uiout Pedro Alves
2016-03-21 15:26 ` [PATCH v2 08/25] Make input_fd be per UI Pedro Alves
2016-03-22 9:46 ` Yao Qi
2016-05-06 11:53 ` Pedro Alves
2016-03-21 15:27 ` [PATCH v2 23/25] Handle UI terminal closed Pedro Alves
2016-03-21 15:27 ` Pedro Alves [this message]
2016-03-21 15:27 ` [PATCH v2 21/25] Only send sync execution command output to the UI that ran the command Pedro Alves
2016-03-21 15:27 ` [PATCH v2 15/25] Introduce display_mi_prompt Pedro Alves
2016-03-21 15:29 ` [PATCH v2 16/25] Simplify starting the command event loop Pedro Alves
2016-03-21 15:29 ` [PATCH v2 05/25] Make the intepreters output to all UIs Pedro Alves
2016-03-22 9:33 ` Yao Qi
2016-05-06 12:19 ` Pedro Alves
2016-03-21 15:29 ` [PATCH v2 17/25] Make gdb_in_secondary_prompt_p() be per UI Pedro Alves
2016-03-21 15:29 ` [PATCH v2 11/25] Make current_ui_out " Pedro Alves
2016-03-21 15:29 ` [PATCH v2 04/25] Introduce interpreter factories Pedro Alves
2016-03-22 8:55 ` Yao Qi
2016-05-06 11:49 ` Pedro Alves
2016-03-21 15:30 ` [PATCH v2 20/25] Push thread->control.command_interp to the struct thread_fsm Pedro Alves
2016-03-21 15:30 ` [PATCH v2 25/25] Add command to list UIs Pedro Alves
2016-03-22 10:36 ` Yao Qi
2016-05-06 11:49 ` Pedro Alves
2016-03-21 15:30 ` [PATCH v2 06/25] Always run async signal handlers in the main UI Pedro Alves
2016-03-21 15:30 ` [PATCH v2 07/25] Make instream and serial_stdin be per UI Pedro Alves
2016-03-21 15:30 ` [PATCH v2 19/25] New function should_print_stop_to_console Pedro Alves
2016-03-21 15:39 ` [PATCH v2 14/25] Make target_terminal_inferior/ours almost nops on non-main UIs Pedro Alves
2016-03-21 16:34 ` [PATCH v2 00/25] Towards great frontend GDB consoles Eli Zaretskii
2016-03-21 17:02 ` Pedro Alves
2016-03-21 17:17 ` Eli Zaretskii
2016-03-21 17:43 ` Marc Khouzam
2016-03-21 18:35 ` Marc Khouzam
2016-03-21 18:51 ` Pedro Alves
2016-03-21 19:06 ` Marc Khouzam
2016-03-21 19:12 ` Pedro Alves
2016-05-06 12:58 ` Pedro Alves
2016-03-22 10:41 ` Yao Qi
2016-05-06 11:58 ` 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=1458573675-15478-10-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--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).