Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@redhat.com>
To: gdb-patches@sources.redhat.com
Cc: Pierre Muller <muller@cerbere.u-strasbg.fr>,
	Daniel Jacobowitz <drow@mvista.com>,
	Andrew Cagney <ac131313@redhat.com>,
	fnasser@redhat.com
Subject: Re: [RFA] cli-out.c new function
Date: Wed, 06 Nov 2002 11:16:00 -0000	[thread overview]
Message-ID: <15817.26835.444106.438405@localhost.redhat.com> (raw)
In-Reply-To: <15817.23234.419911.464165@localhost.redhat.com>

Elena Zannoni writes:
 >  > 
 >  > See the following threads:
 >  > [RFC/RFA] avoid spurious Watchpoint X output on cygwin native target.
 >  > http://sources.redhat.com/ml/gdb-patches/2002-07/msg00323.html
 >  > 
 >  > and
 >  > RFA: Make cli-out follow gdb_stdout
 >  > http://sources.redhat.com/ml/gdb-patches/2002-07/msg00366.html
 >  > as well as
 >  > (which is a different thread, probably because I didn't use Relpy...)
 >  > http://sources.redhat.com/ml/gdb-patches/2002-08/msg00549.html
 >  > 
 >  > But honestly, I don't know if the this new function solves the
 >  > problem...
 > 
 > Ulgh, we seem to have hit a wall. I see that the same concerns about
 > your solutions apply to this one. I guess that in my case using
 > catch_exception should work, because the current code does this:
 > 
 >   old_stream = cli_out_set_stream (cli_uiout, gdb_stdout);
 >   result = safe_execute_command (cli_uiout, command_str, 1);
 >   cli_out_set_stream (cli_uiout, old_stream);
 > 
 > I could change that into a catch_exceptions call. In fact,
 > safe_execute_command *IS* a wrapper around catch_exceptions already.
 > 
 > The general problem is not solved, however.
 > 
 > Elena


OK, I think I figured out how to solve the problem in my case.

BTW, is there a cli_out_free kind of function?

Elena

Index: cli-interp.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/Attic/cli-interp.c,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 cli-interp.c
--- cli-interp.c	4 Nov 2002 23:27:31 -0000	1.1.2.10
+++ cli-interp.c	6 Nov 2002 19:10:31 -0000
@@ -39,8 +39,7 @@ static struct gdb_interpreter *cli_inter
 
 /* Longjmp-safe wrapper for "execute_command" */
 static int do_captured_execute_command (struct ui_out *uiout, void *data);
-static enum gdb_rc safe_execute_command (struct ui_out *uiout, char *command,
-					 int from_tty);
+static enum gdb_rc safe_execute_command (char *command, int from_tty);
 struct captured_execute_command_args
 {
   char *command;
@@ -83,19 +82,7 @@ cli_interpreter_display_prompt_p (void)
 static int
 cli_interpreter_exec (void *data, char *command_str)
 {
-  int result;
-  struct ui_file *old_stream;
-
-  /* gdb_stdout could change between the time cli_uiout was initialized
-     and now. Since we're probably using a different interpreter which has
-     a new ui_file for gdb_stdout, use that one instead of the default.
-  
-     It is important that it gets reset everytime, since the user could
-     set gdb to use a different interpreter. */
-  old_stream = cli_out_set_stream (cli_uiout, gdb_stdout);
-  result = safe_execute_command (cli_uiout, command_str, 1);
-  cli_out_set_stream (cli_uiout, old_stream);
-  return result;
+  return safe_execute_command (command_str, 1);
 }
 
 static int
@@ -108,12 +95,20 @@ do_captured_execute_command (struct ui_o
 }
 
 static enum gdb_rc
-safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
+safe_execute_command (char *command, int from_tty)
 {
+  /* gdb_stdout could change between the time cli_uiout was
+     initialized and now. Since we're probably using a different
+     interpreter which has a new ui_file for gdb_stdout, use that one
+     instead of the default.  Catch exception will execute with
+     command_uiout as output stream.  It is important that it gets
+     reset everytime, since the user could set gdb to use a different
+     interpreter. */
+  struct ui_out *command_uiout = cli_out_new (gdb_stdout);
   struct captured_execute_command_args args;
   args.command = command;
   args.from_tty = from_tty;
-  return catch_exceptions (uiout, do_captured_execute_command, &args,
+  return catch_exceptions (command_uiout, do_captured_execute_command, &args,
 			   NULL, RETURN_MASK_ALL);
 }



  reply	other threads:[~2002-11-06 19:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-05 15:26 Elena Zannoni
2002-11-05 19:25 ` Daniel Jacobowitz
2002-11-06  1:08   ` Pierre Muller
2002-11-06 10:16     ` Elena Zannoni
2002-11-06 11:16       ` Elena Zannoni [this message]
2002-11-05 23:00 ` Eli Zaretskii
2002-11-06 11:26   ` Elena Zannoni

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=15817.26835.444106.438405@localhost.redhat.com \
    --to=ezannoni@redhat.com \
    --cc=ac131313@redhat.com \
    --cc=drow@mvista.com \
    --cc=fnasser@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=muller@cerbere.u-strasbg.fr \
    /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