From patchwork Mon Mar 21 15:20:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 11424 Received: (qmail 91485 invoked by alias); 21 Mar 2016 15:21:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91349 invoked by uid 89); 21 Mar 2016 15:21:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=notifications, exports, 686, streams X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 21 Mar 2016 15:21:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B52E8711D0 for ; Mon, 21 Mar 2016 15:21:19 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2LFLGPU019569 for ; Mon, 21 Mar 2016 11:21:19 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 02/25] Make gdb_stdout&co be per UI Date: Mon, 21 Mar 2016 15:20:52 +0000 Message-Id: <1458573675-15478-3-git-send-email-palves@redhat.com> In-Reply-To: <1458573675-15478-1-git-send-email-palves@redhat.com> References: <1458573675-15478-1-git-send-email-palves@redhat.com> We need to have these send output to the proper UI. However, this patch still make them look like globals. Kind of like __thread variables, if you will. Changing everything throughout to write something like current_ui->gdb_stdout instead would be massive overkill, IMNSHO. I left gdb_stdtargin/stdtarg/stdtargerr global, but maybe that was a mistake -- IIRC, MI formats target i/o differently, so if we have a separate MI channel, then I guess target output should go there instead of to gdb's stdout. OTOH, maybe GDB should send that instead to "set inferior-tty", instead of multiplexing it over MI. Likely wouldn't work on all hosts though... --- gdb/main.c | 4 ---- gdb/top.c | 15 +++++++++++++++ gdb/top.h | 17 +++++++++++++++++ gdb/utils.h | 19 ++++++++++++++----- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/gdb/main.c b/gdb/main.c index 93ed98f..44d1a90 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -68,10 +68,6 @@ static int gdb_datadir_provided = 0; the possibly relocated path to python's lib directory. */ char *python_libdir = 0; -struct ui_file *gdb_stdout; -struct ui_file *gdb_stderr; -struct ui_file *gdb_stdlog; -struct ui_file *gdb_stdin; /* Target IO streams. */ struct ui_file *gdb_stdtargin; struct ui_file *gdb_stdtarg; diff --git a/gdb/top.c b/gdb/top.c index 913284a..ec10a34 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -85,6 +85,21 @@ extern void initialize_all_files (void); #define DEFAULT_PROMPT "(gdb) " #endif +/* Generate a function that exports a pointer to a field of the + current UI. */ + +#define gen_ret_current_ui_field_ptr(type, name) \ +type * \ +current_ui_## name ## _ptr (void) \ +{ \ + return ¤t_ui->m_ ## name; \ +} + +gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stdout) +gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stdin) +gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stderr) +gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stdlog) + /* Initialization file name for gdb. This is host-dependent. */ const char gdbinit[] = GDBINIT; diff --git a/gdb/top.h b/gdb/top.h index fc4e90a..d404427 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -49,6 +49,23 @@ struct ui /* The function to invoke when a complete line of input is ready for processing. */ void (*input_handler) (char *); + + /* The fields below that start with "m_" are "private". They're + meant to be accessed through wrapper macros that make them look + like globals. */ + + /* The ui_file streams. */ + /* Normal results */ + struct ui_file *m_gdb_stdout; + /* Input stream */ + struct ui_file *m_gdb_stdin; + /* Serious error notifications */ + struct ui_file *m_gdb_stderr; + /* Log/debug/trace messages that should bypass normal stdout/stderr + filtering. For moment, always call this stream using + *_unfiltered. In the very near future that restriction shall be + removed - either call shall be unfiltered. (cagney 1999-06-13). */ + struct ui_file *m_gdb_stdlog; }; extern struct ui *current_ui; diff --git a/gdb/utils.h b/gdb/utils.h index 0687c86..bf77d7d 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -156,18 +156,27 @@ extern void reinitialize_more_filter (void); extern int pagination_enabled; -/* Global ui_file streams. These are all defined in main.c. */ +extern struct ui_file **current_ui_gdb_stdout_ptr (void); +extern struct ui_file **current_ui_gdb_stdin_ptr (void); +extern struct ui_file **current_ui_gdb_stderr_ptr (void); +extern struct ui_file **current_ui_gdb_stdlog_ptr (void); + +/* The current top level's ui_file streams. */ + /* Normal results */ -extern struct ui_file *gdb_stdout; +#define gdb_stdout (*current_ui_gdb_stdout_ptr ()) /* Input stream */ -extern struct ui_file *gdb_stdin; +#define gdb_stdin (*current_ui_gdb_stdin_ptr ()) /* Serious error notifications */ -extern struct ui_file *gdb_stderr; +#define gdb_stderr (*current_ui_gdb_stderr_ptr ()) /* Log/debug/trace messages that should bypass normal stdout/stderr filtering. For moment, always call this stream using *_unfiltered. In the very near future that restriction shall be removed - either call shall be unfiltered. (cagney 1999-06-13). */ -extern struct ui_file *gdb_stdlog; +#define gdb_stdlog (*current_ui_gdb_stdlog_ptr ()) + +/* Truly global ui_file streams. These are all defined in main.c. */ + /* Target output that should bypass normal stdout/stderr filtering. For moment, always call this stream using *_unfiltered. In the very near future that restriction shall be removed - either call