* linux-nat.c (linux_nat_terminal_inferior)

(linux_nat_terminal_ours): Don't check sync_execution.
	* remote.c (remote_terminal_inferior, remote_terminal_ours):
	Don't check sync_execution.  Update comments.
	* target.c (target_terminal_inferior): New.
	* target.h (target_terminal_inferior): Delete macro, and declare
	as function.
	* event-top.c (async_disable_stdin): Make idempotent.  Don't give
	the target the terminal here.
	* inflow.c (terminal_ours_1): Don't return early without setting
	`terminal_is_ours'.
This commit is contained in:
Pedro Alves 2009-05-21 16:00:14 +00:00
parent 47608cb1ac
commit d9d2d8b6c0
7 changed files with 41 additions and 38 deletions

View File

@ -1,3 +1,17 @@
2009-05-21 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_nat_terminal_inferior)
(linux_nat_terminal_ours): Don't check sync_execution.
* remote.c (remote_terminal_inferior, remote_terminal_ours):
Don't check sync_execution. Update comments.
* target.c (target_terminal_inferior): New.
* target.h (target_terminal_inferior): Delete macro, and declare
as function.
* event-top.c (async_disable_stdin): Make idempotent. Don't give
the target the terminal here.
* inflow.c (terminal_ours_1): Don't return early without setting
`terminal_is_ours'.
2009-05-21 Pedro Alves <pedro@codesourcery.com> 2009-05-21 Pedro Alves <pedro@codesourcery.com>
* target.h (TARGET_WNOHANG): New. * target.h (TARGET_WNOHANG): New.

View File

@ -457,15 +457,12 @@ async_enable_stdin (void)
void void
async_disable_stdin (void) async_disable_stdin (void)
{
if (!sync_execution)
{ {
sync_execution = 1; sync_execution = 1;
push_prompt ("", "", ""); push_prompt ("", "", "");
/* FIXME: cagney/1999-09-27: At present this call is technically }
redundant since infcmd.c and infrun.c both already call
target_terminal_inferior(). As the terminal handling (in
sync/async mode) is refined, the duplicate calls can be
eliminated (Here or in infcmd.c/infrun.c). */
target_terminal_inferior ();
} }

View File

@ -361,6 +361,8 @@ terminal_ours_1 (int output_only)
if (terminal_is_ours) if (terminal_is_ours)
return; return;
terminal_is_ours = 1;
/* Checking inferior->run_terminal is necessary so that /* Checking inferior->run_terminal is necessary so that
if GDB is running in the background, it won't block trying if GDB is running in the background, it won't block trying
to do the ioctl()'s below. Checking gdb_has_a_terminal to do the ioctl()'s below. Checking gdb_has_a_terminal
@ -371,7 +373,6 @@ terminal_ours_1 (int output_only)
if (inf->terminal_info->run_terminal != NULL || gdb_has_a_terminal () == 0) if (inf->terminal_info->run_terminal != NULL || gdb_has_a_terminal () == 0)
return; return;
if (!terminal_is_ours)
{ {
#ifdef SIGTTOU #ifdef SIGTTOU
/* Ignore this signal since it will happen when we try to set the /* Ignore this signal since it will happen when we try to set the
@ -380,8 +381,6 @@ terminal_ours_1 (int output_only)
#endif #endif
int result; int result;
terminal_is_ours = 1;
#ifdef SIGTTOU #ifdef SIGTTOU
if (job_control) if (job_control)
osigttou = (void (*)()) signal (SIGTTOU, SIG_IGN); osigttou = (void (*)()) signal (SIGTTOU, SIG_IGN);

View File

@ -4360,14 +4360,9 @@ linux_nat_terminal_inferior (void)
return; return;
} }
/* GDB should never give the terminal to the inferior, if the
inferior is running in the background (run&, continue&, etc.).
This check can be removed when the common code is fixed. */
if (!sync_execution)
return;
terminal_inferior (); terminal_inferior ();
/* Calls to target_terminal_*() are meant to be idempotent. */
if (!async_terminal_is_ours) if (!async_terminal_is_ours)
return; return;
@ -4393,9 +4388,6 @@ linux_nat_terminal_ours (void)
but claiming it sure should. */ but claiming it sure should. */
terminal_ours (); terminal_ours ();
if (!sync_execution)
return;
if (async_terminal_is_ours) if (async_terminal_is_ours)
return; return;

View File

@ -4078,19 +4078,12 @@ remote_terminal_inferior (void)
/* Nothing to do. */ /* Nothing to do. */
return; return;
/* FIXME: cagney/1999-09-27: Shouldn't need to test for /* FIXME: cagney/1999-09-27: Make calls to target_terminal_*()
sync_execution here. This function should only be called when idempotent. The event-loop GDB talking to an asynchronous target
GDB is resuming the inferior in the forground. A background with a synchronous command calls this function from both
resume (``run&'') should leave GDB in control of the terminal and event-top.c and infrun.c/infcmd.c. Once GDB stops trying to
consequently should not call this code. */ transfer the terminal to the target when it shouldn't this guard
if (!sync_execution) can go away. */
return;
/* FIXME: cagney/1999-09-27: Closely related to the above. Make
calls target_terminal_*() idenpotent. The event-loop GDB talking
to an asynchronous target with a synchronous command calls this
function from both event-top.c and infrun.c/infcmd.c. Once GDB
stops trying to transfer the terminal to the target when it
shouldn't this guard can go away. */
if (!remote_async_terminal_ours_p) if (!remote_async_terminal_ours_p)
return; return;
delete_file_handler (input_fd); delete_file_handler (input_fd);
@ -4109,9 +4102,6 @@ remote_terminal_ours (void)
return; return;
/* See FIXME in remote_terminal_inferior. */ /* See FIXME in remote_terminal_inferior. */
if (!sync_execution)
return;
/* See FIXME in remote_terminal_inferior. */
if (remote_async_terminal_ours_p) if (remote_async_terminal_ours_p)
return; return;
cleanup_sigint_signal_handler (NULL); cleanup_sigint_signal_handler (NULL);

View File

@ -301,6 +301,18 @@ target_create_inferior (char *exec_file, char *args,
"could not find a target to create inferior"); "could not find a target to create inferior");
} }
void
target_terminal_inferior (void)
{
/* A background resume (``run&'') should leave GDB in control of the
terminal. */
if (target_is_async_p () && !sync_execution)
return;
/* If GDB is resuming the inferior in the foreground, install
inferior's terminal modes. */
(*current_target.to_terminal_inferior) ();
}
static int static int
nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write, nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write,

View File

@ -763,8 +763,7 @@ extern void print_section_info (struct target_ops *, bfd *);
/* Put the inferior's terminal settings into effect. /* Put the inferior's terminal settings into effect.
This is preparation for starting or resuming the inferior. */ This is preparation for starting or resuming the inferior. */
#define target_terminal_inferior() \ extern void target_terminal_inferior (void);
(*current_target.to_terminal_inferior) ()
/* Put some of our terminal settings into effect, /* Put some of our terminal settings into effect,
enough to get proper results from our output, enough to get proper results from our output,