This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] Always flush MI output
- To: gdb-patches at sources dot redhat dot com
- Subject: [patch] Always flush MI output
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Thu, 12 Jul 2001 01:53:45 -0400
Hello,
This fixes the bug reported by David Whedon. Another way to reproduce
the problem is:
gdb -i=mi | cat
Andrew
> Hi,
>
> I think I found a buglet in the gdbmi interface. I've been going back and forth
> on this but I'm fairly convinced my little code is right.
>
> It appears as though we're not getting raw_stdout flushed properly. I have
> observed this behavior with gdb 5.0 as well as current (updated yesterday) cvs.
> The wierd thing is that it looks like gdbmi is intentianally not flushing the
> way I think it should, which causes me to doubt myself.
>
> Here is an example of bad behavior (the example program is included later in the
> message):
>
> $ gcc gdbmi_bug.c
> $ ./a.out
> |GNU gdb 5.0 (MI_OUT)|
> |Copyright 2001 Free Software Foundation, Inc.|
> |GDB is free software, covered by the GNU General Public License, and you are|
> |welcome to change it and/or distribute copies of it under certain conditions.|
> |Type "show copying" to see the conditions.|
> |There is absolutely no warranty for GDB. Type "show warranty" for details.|
> Error reading from gdb
> We timeout out, that's a bug!
> $
>
>
>
2001-07-12 Andrew Cagney <ac131313@redhat.com>
* mi-main.c (mi_execute_command): Flush output after ``(gdb)''
prompt. Bug reported by David Whedon.
(mi_execute_async_cli_command): Ditto.
(mi_exec_async_cli_cmd_continuation): Ditto.
(mi_command_loop): Ditto.
Index: mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.21
diff -p -r1.21 mi-main.c
*** mi-main.c 2001/07/09 16:53:03 1.21
--- mi-main.c 2001/07/12 05:50:06
*************** mi_execute_command (char *cmd, int from_
*** 1164,1171 ****
mi_parse_free (command);
}
- gdb_flush (raw_stdout);
fputs_unfiltered ("(gdb) \n", raw_stdout);
/* print any buffered hook code */
/* ..... */
}
--- 1164,1171 ----
mi_parse_free (command);
}
fputs_unfiltered ("(gdb) \n", raw_stdout);
+ gdb_flush (raw_stdout);
/* print any buffered hook code */
/* ..... */
}
*************** mi_execute_async_cli_command (char *mi,
*** 1296,1301 ****
--- 1296,1302 ----
fputs_unfiltered (last_async_command, raw_stdout);
fputs_unfiltered ("^running\n", raw_stdout);
fputs_unfiltered ("(gdb) \n", raw_stdout);
+ gdb_flush (raw_stdout);
}
else
{
*************** mi_exec_async_cli_cmd_continuation (stru
*** 1337,1342 ****
--- 1338,1344 ----
mi_out_put (uiout, raw_stdout);
fputs_unfiltered ("\n", raw_stdout);
fputs_unfiltered ("(gdb) \n", raw_stdout);
+ gdb_flush (raw_stdout);
do_exec_cleanups (ALL_CLEANUPS);
}
*************** mi_command_loop (int mi_version)
*** 1464,1469 ****
--- 1466,1472 ----
/* Tell the world that we're alive */
fputs_unfiltered ("(gdb) \n", raw_stdout);
+ gdb_flush (raw_stdout);
if (!event_loop_p)
simplified_command_loop (mi_input, mi_execute_command);