Factor out foreground/background execution command preparation.
authorPedro Alves <palves@redhat.com>
Wed, 12 Mar 2014 20:32:53 +0000 (20:32 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 12 Mar 2014 20:32:53 +0000 (20:32 +0000)
commit8bc2fe488957946d2cdccda3ce8d4f39e4003ea0
treedade1dd39bf7e27dd341f2f5e306e8aef69ab66e
parent638c5f496205e1209547f3f6303f773270882173
Factor out foreground/background execution command preparation.

All execution commands currently have this pattern:

  /* If we must run in the background, but the target can't do it,
     error out.  */
  if (async_exec && !target_can_async_p ())
    error (_("Asynchronous execution not supported on this target."));

  /* If we are not asked to run in the bg, then prepare to run in the
     foreground, synchronously.  */
  if (!async_exec && target_can_async_p ())
    {
      /* Simulate synchronous execution.  */
      async_disable_stdin ();
    }

This patch factors that into a shared function.

attach_command installs a cleanup to re-enable stdin, but that's not
necessary, as per the comment in prepare_execution_command.  In any
case, if someday it turns out necessary, we have a single place to
install it now.

Tested on x86_64 Fedora 17, sync and async modes.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

* infcmd.c (prepare_execution_command): New function, factored out
from several execution commands.
(run_command_1, continue_command, step_1, jump_command)
(signal_command, until_command, advance_command, finish_command)
(attach_command): Use prepare_execution_command.
gdb/ChangeLog
gdb/infcmd.c