From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 07/14] Use member initialization in 'struct ui'
Date: Fri, 12 Aug 2022 18:54:35 -0600 [thread overview]
Message-ID: <20220813005442.4163512-8-tromey@adacore.com> (raw)
In-Reply-To: <20220813005442.4163512-1-tromey@adacore.com>
This changes 'struct ui' to use member initialization. This is
simpler to understand.
---
gdb/top.c | 13 ++-----------
gdb/top.h | 18 +++++++++---------
2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/gdb/top.c b/gdb/top.c
index 655bcd77598..b63804b14d1 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -295,26 +295,17 @@ unbuffer_stream (FILE *stream)
/* See top.h. */
ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
- : next (nullptr),
- num (++highest_ui_num),
- call_readline (nullptr),
- input_handler (nullptr),
- command_editing (0),
- interp_info (nullptr),
- async (0),
- secondary_prompt_depth (0),
+ : num (++highest_ui_num),
stdin_stream (instream_),
instream (instream_),
outstream (outstream_),
errstream (errstream_),
input_fd (fileno (instream)),
m_input_interactive_p (ISATTY (instream)),
- prompt_state (PROMPT_NEEDED),
m_gdb_stdout (new pager_file (new stdio_file (outstream))),
m_gdb_stdin (new stdio_file (instream)),
m_gdb_stderr (new stderr_file (errstream)),
- m_gdb_stdlog (m_gdb_stderr),
- m_current_uiout (nullptr)
+ m_gdb_stdlog (m_gdb_stderr)
{
buffer_init (&line_buffer);
diff --git a/gdb/top.h b/gdb/top.h
index cb3abb80d84..6634738c1a0 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -61,7 +61,7 @@ struct ui
DISABLE_COPY_AND_ASSIGN (ui);
/* Pointer to next in singly-linked list. */
- struct ui *next;
+ struct ui *next = nullptr;
/* Convenient handle (UI number). Unique across all UIs. */
int num;
@@ -76,19 +76,19 @@ struct ui
point of invocation. In the special case in which the character
read is newline, the function invokes the INPUT_HANDLER callback
(see below). */
- void (*call_readline) (gdb_client_data);
+ void (*call_readline) (gdb_client_data) = nullptr;
/* The function to invoke when a complete line of input is ready for
processing. */
- void (*input_handler) (gdb::unique_xmalloc_ptr<char> &&);
+ void (*input_handler) (gdb::unique_xmalloc_ptr<char> &&) = nullptr;
/* True if this UI is using the readline library for command
editing; false if using GDB's own simple readline emulation, with
no editing support. */
- int command_editing;
+ int command_editing = 0;
/* Each UI has its own independent set of interpreters. */
- struct ui_interp_info *interp_info;
+ struct ui_interp_info *interp_info = nullptr;
/* True if the UI is in async mode, false if in sync mode. If in
sync mode, a synchronous execution command (e.g, "next") does not
@@ -98,11 +98,11 @@ struct ui
the top event loop. For the main UI, this starts out disabled,
until all the explicit command line arguments (e.g., `gdb -ex
"start" -ex "next"') are processed. */
- int async;
+ int async = 0;
/* The number of nested readline secondary prompts that are
currently active. */
- int secondary_prompt_depth;
+ int secondary_prompt_depth = 0;
/* The UI's stdin. Set to stdin for the main UI. */
FILE *stdin_stream;
@@ -127,7 +127,7 @@ struct ui
bool m_input_interactive_p;
/* See enum prompt_state's description. */
- enum prompt_state prompt_state;
+ enum prompt_state prompt_state = PROMPT_NEEDED;
/* The fields below that start with "m_" are "private". They're
meant to be accessed through wrapper macros that make them look
@@ -145,7 +145,7 @@ struct ui
struct ui_file *m_gdb_stdlog;
/* The current ui_out. */
- struct ui_out *m_current_uiout;
+ struct ui_out *m_current_uiout = nullptr;
/* Register the UI's input file descriptor in the event loop. */
void register_file_handler ();
--
2.34.1
next prev parent reply other threads:[~2022-08-13 0:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-13 0:54 [PATCH 00/14] Minor ui / interp cleanups Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 01/14] Remove some dead code Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 02/14] Free ui::line_buffer Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 03/14] Use ui_out_redirect_pop in more places Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 04/14] Remove the "for moment" comments Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 05/14] Remove obsolete filtering comment Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 06/14] Remove two unused members from mi_interp Tom Tromey via Gdb-patches
2022-08-13 0:54 ` Tom Tromey via Gdb-patches [this message]
2022-08-13 0:54 ` [PATCH 08/14] Use scoped_restore in safe_parse_type Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 09/14] Remove tui_out_new Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 10/14] Remove a ui-related memory leak Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 11/14] TUI stdout buffering cleanup Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 12/14] Remove a call to clear_interpreter_hooks Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 13/14] Fix "source" with interpreter-exec Tom Tromey via Gdb-patches
2022-08-13 1:58 ` Enze Li via Gdb-patches
2022-08-15 17:28 ` Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 14/14] Fix interpreter-exec crash Tom Tromey via Gdb-patches
2022-08-31 17:13 ` [PATCH 00/14] Minor ui / interp cleanups Tom Tromey
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=20220813005442.4163512-8-tromey@adacore.com \
--to=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/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