Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Joel Brobecker <brobecker@adacore.com>
Cc: marc.khouzam@ericsson.com, stanshebs@earthlink.net,
	gdb-patches@sourceware.org
Subject: Re: GDB/MI and ">" prompts
Date: Tue, 08 May 2012 18:51:00 -0000	[thread overview]
Message-ID: <83pqae1pb2.fsf@gnu.org> (raw)
In-Reply-To: <20120508155123.GA15555@adacore.com>

> Date: Tue, 8 May 2012 08:51:23 -0700
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: 'Stan Shebs' <stanshebs@earthlink.net>,
> 	"'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>,
> 	'Eli Zaretskii' <eliz@gnu.org>
> 
> Thanks for doing the testing, Mark!
> 
> Stan said:
> > > If Eclipse is good, then this is OK to commit.
> 
> Mark reported:
> > So, it seems ok for an Eclipse perspective.
> 
> So it seems Eli is good to go!

Thanks.  Here's what I actually committed:

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.14219
diff -u -p -r1.14219 ChangeLog
--- gdb/ChangeLog	8 May 2012 14:07:06 -0000	1.14219
+++ gdb/ChangeLog	8 May 2012 18:48:12 -0000
@@ -1,3 +1,16 @@
+2012-05-08  Eli Zaretskii  <eliz@gnu.org>
+
+	Display the ">" prompt in interactive mode while reading canned
+	commands, even when the current interpreter is MI.
+
+	* interps.c (interp_set_temp): New function.
+
+	* interps.h (interp_set_temp): Add prototype.
+
+	* cli/cli-script.c (restore_interp): New cleanup function.
+	(read_command_lines): Temporarily override the current interpreter
+	with CLI and arrange for restoring the original one.
+
 2012-05-12  Joel Sherrill <joel.sherrill@oarcorp.com>
 
 	* microblaze-rom.c (_initialize_picobug_rom): Add prototype.
Index: gdb/interps.c
===================================================================
RCS file: /cvs/src/src/gdb/interps.c,v
retrieving revision 1.44
diff -u -p -r1.44 interps.c
--- gdb/interps.c	4 Jan 2012 08:17:05 -0000	1.44
+++ gdb/interps.c	8 May 2012 18:48:12 -0000
@@ -253,6 +253,18 @@ interp_ui_out (struct interp *interp)
   return current_interpreter->procs->ui_out_proc (current_interpreter);
 }
 
+/* Temporarily overrides the current interpreter.  */
+struct interp *
+interp_set_temp (const char *name)
+{
+  struct interp *interp = interp_lookup (name);
+  struct interp *old_interp = current_interpreter;
+
+  if (interp)
+    current_interpreter = interp;
+  return old_interp;
+}
+
 /* Returns the interpreter's cookie.  */
 
 void *
Index: gdb/interps.h
===================================================================
RCS file: /cvs/src/src/gdb/interps.h,v
retrieving revision 1.22
diff -u -p -r1.22 interps.h
--- gdb/interps.h	4 Jan 2012 08:17:05 -0000	1.22
+++ gdb/interps.h	8 May 2012 18:48:12 -0000
@@ -69,6 +69,7 @@ extern struct interp *interp_lookup (con
 extern struct ui_out *interp_ui_out (struct interp *interp);
 extern void *interp_data (struct interp *interp);
 extern const char *interp_name (struct interp *interp);
+extern struct interp *interp_set_temp (const char *name);
 
 extern int current_interp_named_p (const char *name);
 extern int current_interp_display_prompt_p (void);
Index: gdb/cli/cli-script.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
retrieving revision 1.74
diff -u -p -r1.74 cli-script.c
--- gdb/cli/cli-script.c	24 Jan 2012 20:56:33 -0000	1.74
+++ gdb/cli/cli-script.c	8 May 2012 18:48:12 -0000
@@ -1178,6 +1178,12 @@ recurse_read_control_structure (char * (
   return ret;
 }
 
+static void
+restore_interp (void *arg)
+{
+  interp_set_temp (interp_name ((struct interp *)arg));
+}
+
 /* Read lines from the input stream and accumulate them in a chain of
    struct command_line's, which is then returned.  For input from a
    terminal, the special command "end" is used to mark the end of the
@@ -1210,8 +1216,21 @@ read_command_lines (char *prompt_arg, in
 	}
     }
 
-  head = read_command_lines_1 (read_next_line, parse_commands,
-			       validator, closure);
+
+  /* Reading commands assumes the CLI behavior, so temporarily
+     override the current interpreter with CLI.  */
+  if (current_interp_named_p (INTERP_CONSOLE))
+    head = read_command_lines_1 (read_next_line, parse_commands,
+				 validator, closure);
+  else
+    {
+      struct interp *old_interp = interp_set_temp (INTERP_CONSOLE);
+      struct cleanup *old_chain = make_cleanup (restore_interp, old_interp);
+
+      head = read_command_lines_1 (read_next_line, parse_commands,
+				   validator, closure);
+      do_cleanups (old_chain);
+    }
 
   if (deprecated_readline_end_hook && from_tty && input_from_terminal_p ())
     {


  reply	other threads:[~2012-05-08 18:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <83vckviv3b.fsf@gnu.org>
     [not found] ` <20120419154853.GM25623@adacore.com>
     [not found]   ` <83sjfzitxx.fsf@gnu.org>
     [not found]     ` <83r4vjitnj.fsf@gnu.org>
     [not found]       ` <20120419185329.GO25623@adacore.com>
     [not found]         ` <83mx67ikxm.fsf@gnu.org>
2012-04-22 16:52           ` Eli Zaretskii
2012-04-28 14:54             ` Eli Zaretskii
2012-04-30 16:26               ` Joel Brobecker
2012-04-30 16:55               ` Stan Shebs
2012-04-30 17:18                 ` Eli Zaretskii
2012-05-02 15:56                   ` Marc Khouzam
2012-05-02 17:04                     ` Eli Zaretskii
2012-05-08 15:39                 ` Marc Khouzam
2012-05-08 15:51                   ` Joel Brobecker
2012-05-08 18:51                     ` Eli Zaretskii [this message]
2012-05-08 18:51                   ` Eli Zaretskii

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=83pqae1pb2.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=marc.khouzam@ericsson.com \
    --cc=stanshebs@earthlink.net \
    /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