This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: patch to top.c to prevent gdb from being thrown into the background
- From: "J. Johnston" <jjohnstn at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 21 Oct 2003 17:27:17 -0400
- Subject: RFA: patch to top.c to prevent gdb from being thrown into the background
- Organization: Red Hat Inc.
The attached patch fixes a current problem with gdb regarding attaching to a
background process in the same terminal window the background process was
started in.
In the particular example, the attach started issuing messages regarding the
symbols loaded from shared libraries. Because the number of shared libraries
was quite large in this case, a page break occurred which caused readline() to
be called. The first readline() made a call to tcsetattr() which pushed gdb
into the background under Linux.
There is a separate problem regarding whether the output of the shared library
loads should be unfiltered in which case the problem would not have occurred,
but I am creating a separate thread for that issue.
The fix is simply to call terminal_ours() before calling readline() in
gdb_readline_wrapper(). I have tested on i686 linux.
Ok to commit?
2003-10-21 Jeff Johnston <jjohnstn@redhat.com>
* top.c (gdb_readline_wrapper): Ensure terminal is gdb's before calling
readline.
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.73.4.2
diff -u -p -r1.73.4.2 top.c
--- top.c 22 Sep 2003 17:50:32 -0000 1.73.4.2
+++ top.c 21 Oct 2003 21:19:10 -0000
@@ -969,6 +969,13 @@ gdb_readline_wrapper (char *prompt)
after_char_processing_hook = NULL;
}
+ /* Before calling readline, ensure we have the terminal. If we don't
+ have the terminal and call readline, we risk the possibility of
+ gdb being thrown into the background. This problem occurs when
+ we attach to a background process on the same terminal the background
+ process was started from and then perform some action which requires
+ a page break prompt. */
+ terminal_ours ();
return readline (prompt);
}