public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 4/4] Remove interp_name
Date: Mon, 30 Apr 2018 05:12:00 -0000	[thread overview]
Message-ID: <20180430051207.19979-5-tom@tromey.com> (raw)
In-Reply-To: <20180430051207.19979-1-tom@tromey.com>

This removes the interp_name function.  It is only used a few spots --
one of which was only calling it on "this".  It's simpler to remove
it; and should class interp become opaque in the future, it will be
just as easy to update the two remaining spots to use an accessor.

ChangeLog
2018-04-29  Tom Tromey  <tom@tromey.com>

	* interps.c (interp_name): Remove.
	* mi/mi-interp.c (mi_interp::init): Update.
	* interps.h (interp_name): Remove.
	(~scoped_restore_interp): Update.
	* tui/tui.c (tui_enable): Update.
---
 gdb/ChangeLog      | 8 ++++++++
 gdb/interps.c      | 8 --------
 gdb/interps.h      | 4 +---
 gdb/mi/mi-interp.c | 2 --
 gdb/tui/tui.c      | 2 +-
 5 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/gdb/interps.c b/gdb/interps.c
index 5884625856..8ec9744fdf 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -274,14 +274,6 @@ scoped_restore_interp::set_interp (const char *name)
   return old_interp;
 }
 
-/* Returns the interpreter's name.  */
-
-const char *
-interp_name (struct interp *interp)
-{
-  return interp->name;
-}
-
 /* Returns true if the current interp is the passed in name.  */
 int
 current_interp_named_p (const char *interp_name)
diff --git a/gdb/interps.h b/gdb/interps.h
index 694149a6ca..a689be5625 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -98,8 +98,6 @@ extern struct interp *interp_lookup (struct ui *ui, const char *name);
    interpreter fails to initialize.  */
 extern void set_top_level_interpreter (const char *name);
 
-extern const char *interp_name (struct interp *interp);
-
 /* Temporarily set the current interpreter, and reset it on
    destruction.  */
 class scoped_restore_interp
@@ -113,7 +111,7 @@ public:
 
   ~scoped_restore_interp ()
   {
-    set_interp (interp_name (m_interp));
+    set_interp (m_interp->name);
   }
 
   scoped_restore_interp (const scoped_restore_interp &) = delete;
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 99ce1eb5d6..e52d797973 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -113,7 +113,6 @@ void
 mi_interp::init (bool top_level)
 {
   mi_interp *mi = this;
-  const char *name;
   int mi_version;
 
   /* Store the current output channel, so that we can create a console
@@ -129,7 +128,6 @@ mi_interp::init (bool top_level)
   mi->targ = new mi_console_file (mi->raw_stdout, "@", '"');
   mi->event_channel = new mi_console_file (mi->raw_stdout, "=", 0);
 
-  name = interp_name (this);
   /* INTERP_MI selects the most recent released version.  "mi2" was
      released as part of GDB 6.0.  */
   if (strcmp (name, INTERP_MI) == 0)
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 7943a61676..9e2520b4fc 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -415,7 +415,7 @@ tui_enable (void)
 
       /* If the top level interpreter is not the console/tui (e.g.,
 	 MI), enabling curses will certainly lose.  */
-      interp = interp_name (top_level_interpreter ());
+      interp = top_level_interpreter ()->name;
       if (strcmp (interp, INTERP_TUI) != 0)
 	error (_("Cannot enable the TUI when the interpreter is '%s'"), interp);
 
-- 
2.13.6

  parent reply	other threads:[~2018-04-30  5:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  5:12 [RFA 0/4] minor interp-related cleanups Tom Tromey
2018-04-30  5:12 ` [RFA 1/4] Use scoped_restore in a couple of interp-related places Tom Tromey
2018-05-25 18:06   ` Pedro Alves
2018-04-30  5:12 ` [RFA 2/4] Change the as_*_interp functions to use dynamic_cast Tom Tromey
2018-05-25 18:12   ` Pedro Alves
2018-04-30  5:12 ` Tom Tromey [this message]
2018-05-25 18:41   ` [RFA 4/4] Remove interp_name Pedro Alves
2018-05-25 18:47     ` Tom Tromey
2018-05-25 19:36       ` Pedro Alves
2018-04-30  5:12 ` [RFA 3/4] Remove interp_ui_out Tom Tromey
2018-05-25 18:37   ` Pedro Alves
2018-05-25 17:34 ` [RFA 0/4] minor interp-related 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=20180430051207.19979-5-tom@tromey.com \
    --to=tom@tromey.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).