* target.h (TARGET_WNOHANG): New.

* target.c (target_wait): Add `options' argument.  Adjust.
	(struct target_ops) <to_wait>: Add `options' argument.
	(target_wait): Add `options' argument.
	* infrun.c (wait_for_inferior): Pass 0 as options to
	target_wait (blocking wait).
	(fetch_inferior_event): Pass TARGET_WNOHANG as options to
	target_wait.
	* fork-child.c (startup_inferior): Pass 0 as options to
	target_wait (blocking wait).
	* linux-nat.c (linux_nat_create_inferior): Remove async masking.
	(linux_nat_wait_1): Add `target_options' argument.  Use it instead
	of checking on target_can_async_p.
	(linux_nat_wait): Add `target_options' argument.  Adjust.
	* remote.c (remote_wait_ns): Add `options' argument.  Adjust to
	check on TARGET_WNOWAIT instead of checking on remote_is_async_p.
	(remote_wait_as): Add `options' argument.  Adjust to check on
	TARGET_WNOWAIT instead of checking on remote_is_async_p.  If doing
	a blocking wait, keep waiting until an interesting event comes
	out.
	(remote_wait): Add `options' argument.  Don't loop here if the
	target is in async mode, and a blocking wait has been requested.

	* top.c (deprecated_target_wait_hook): Add `options' argument.
	* linux-thread-db.c (thread_db_wait): Add `options' argument, and
	pass it down to the layer beneath.
	* inf-ptrace.c (inf_ptrace_wait): Add `options' argument.
	* record.c (record_beneath_to_wait): Add `options' argument.
	(record_wait): Add `options' argument, and pass it down to the
	layer beneath.
	* bsd-uthread.c (bsd_uthread_wait): Add `options' argument.
	* darwin-nat.c (darwin_wait): Likewise.
	* defs.h (deprecated_target_wait_hook): Likewise.
	* gnu-nat.c (gnu_wait): Add `options' argument.
	* go32-nat.c (go32_wait): Likewise.
	* hpux-thread.c (hpux_thread_wait): Add `options' argument, and
	pass it down to the layer beneath.
	* inf-ttrace.c (inf_ttrace_wait): Add `options' argument.
	* monitor.c (monitor_wait): Likewise.
	* nto-procfs.c (procfs_wait): Likewise.
	* remote-mips.c (mips_wait): Add `options' argument.
	* remote-sim.c (gdbsim_wait): Likewise.
	* rs6000-nat.c (rs6000_wait): Add `options' argument.
	* sol-thread.c (sol_thread_wait): Add `options' argument, and pass
	it down to the layer beneath.
	* spu-linux-nat.c (spu_child_wait): Add `options' argument.
	* windows-nat.c (windows_wait): Likewise.
	* tui/tui-hooks.c (tui_target_wait_hook): Likewise.  Adjust.
This commit is contained in:
Pedro Alves 2009-05-21 15:48:42 +00:00
parent 9944e9c2ac
commit 47608cb1ac
27 changed files with 130 additions and 74 deletions

View File

@ -1,3 +1,54 @@
2009-05-21 Pedro Alves <pedro@codesourcery.com>
* target.h (TARGET_WNOHANG): New.
* target.c (target_wait): Add `options' argument. Adjust.
(struct target_ops) <to_wait>: Add `options' argument.
(target_wait): Add `options' argument.
* infrun.c (wait_for_inferior): Pass 0 as options to
target_wait (blocking wait).
(fetch_inferior_event): Pass TARGET_WNOHANG as options to
target_wait.
* fork-child.c (startup_inferior): Pass 0 as options to
target_wait (blocking wait).
* linux-nat.c (linux_nat_create_inferior): Remove async masking.
(linux_nat_wait_1): Add `target_options' argument. Use it instead
of checking on target_can_async_p.
(linux_nat_wait): Add `target_options' argument. Adjust.
* remote.c (remote_wait_ns): Add `options' argument. Adjust to
check on TARGET_WNOWAIT instead of checking on remote_is_async_p.
(remote_wait_as): Add `options' argument. Adjust to check on
TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing
a blocking wait, keep waiting until an interesting event comes
out.
(remote_wait): Add `options' argument. Don't loop here if the
target is in async mode, and a blocking wait has been requested.
* top.c (deprecated_target_wait_hook): Add `options' argument.
* linux-thread-db.c (thread_db_wait): Add `options' argument, and
pass it down to the layer beneath.
* inf-ptrace.c (inf_ptrace_wait): Add `options' argument.
* record.c (record_beneath_to_wait): Add `options' argument.
(record_wait): Add `options' argument, and pass it down to the
layer beneath.
* bsd-uthread.c (bsd_uthread_wait): Add `options' argument.
* darwin-nat.c (darwin_wait): Likewise.
* defs.h (deprecated_target_wait_hook): Likewise.
* gnu-nat.c (gnu_wait): Add `options' argument.
* go32-nat.c (go32_wait): Likewise.
* hpux-thread.c (hpux_thread_wait): Add `options' argument, and
pass it down to the layer beneath.
* inf-ttrace.c (inf_ttrace_wait): Add `options' argument.
* monitor.c (monitor_wait): Likewise.
* nto-procfs.c (procfs_wait): Likewise.
* remote-mips.c (mips_wait): Add `options' argument.
* remote-sim.c (gdbsim_wait): Likewise.
* rs6000-nat.c (rs6000_wait): Add `options' argument.
* sol-thread.c (sol_thread_wait): Add `options' argument, and pass
it down to the layer beneath.
* spu-linux-nat.c (spu_child_wait): Add `options' argument.
* windows-nat.c (windows_wait): Likewise.
* tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 Pedro Alves <pedro@codesourcery.com> 2009-05-21 Pedro Alves <pedro@codesourcery.com>
* mi/mi-interp.c (mi_on_resume): Account for whole process * mi/mi-interp.c (mi_on_resume): Account for whole process

View File

@ -345,13 +345,13 @@ bsd_uthread_xfer_partial (struct target_ops *ops, enum target_object object,
static ptid_t static ptid_t
bsd_uthread_wait (struct target_ops *ops, bsd_uthread_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
CORE_ADDR addr; CORE_ADDR addr;
struct target_ops *beneath = find_target_beneath (ops); struct target_ops *beneath = find_target_beneath (ops);
/* Pass the request to the layer beneath. */ /* Pass the request to the layer beneath. */
ptid = beneath->to_wait (beneath, ptid, status); ptid = beneath->to_wait (beneath, ptid, status, options);
/* If the process is no longer alive, there's no point in figuring /* If the process is no longer alive, there's no point in figuring
out the thread ID. It will fail anyway. */ out the thread ID. It will fail anyway. */

View File

@ -476,7 +476,7 @@ catch_exception_raise (mach_port_t port,
static ptid_t static ptid_t
darwin_wait (struct target_ops *ops, darwin_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
kern_return_t kret; kern_return_t kret;
mach_msg_header_t *hdr = &msgin.hdr; mach_msg_header_t *hdr = &msgin.hdr;

View File

@ -1111,7 +1111,8 @@ extern void (*deprecated_register_changed_hook) (int regno);
extern void (*deprecated_memory_changed_hook) (CORE_ADDR addr, int len); extern void (*deprecated_memory_changed_hook) (CORE_ADDR addr, int len);
extern void (*deprecated_context_hook) (int); extern void (*deprecated_context_hook) (int);
extern ptid_t (*deprecated_target_wait_hook) (ptid_t ptid, extern ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
struct target_waitstatus * status); struct target_waitstatus *status,
int options);
extern void (*deprecated_attach_hook) (void); extern void (*deprecated_attach_hook) (void);
extern void (*deprecated_detach_hook) (void); extern void (*deprecated_detach_hook) (void);

View File

@ -448,7 +448,7 @@ startup_inferior (int ntraps)
struct target_waitstatus ws; struct target_waitstatus ws;
memset (&ws, 0, sizeof (ws)); memset (&ws, 0, sizeof (ws));
event_ptid = target_wait (resume_ptid, &ws); event_ptid = target_wait (resume_ptid, &ws, 0);
if (ws.kind == TARGET_WAITKIND_IGNORE) if (ws.kind == TARGET_WAITKIND_IGNORE)
/* The inferior didn't really stop, keep waiting. */ /* The inferior didn't really stop, keep waiting. */

View File

@ -1435,7 +1435,7 @@ struct inf *waiting_inf;
/* Wait for something to happen in the inferior, returning what in STATUS. */ /* Wait for something to happen in the inferior, returning what in STATUS. */
static ptid_t static ptid_t
gnu_wait (struct target_ops *ops, gnu_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
struct msg struct msg
{ {

View File

@ -416,7 +416,7 @@ static char child_cwd[FILENAME_MAX];
static ptid_t static ptid_t
go32_wait (struct target_ops *ops, go32_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
int i; int i;
unsigned char saved_opcode; unsigned char saved_opcode;

View File

@ -190,7 +190,7 @@ hpux_thread_resume (struct target_ops *ops,
static ptid_t static ptid_t
hpux_thread_wait (struct target_ops *ops, hpux_thread_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
ptid_t rtnval; ptid_t rtnval;
struct cleanup *old_chain; struct cleanup *old_chain;
@ -203,7 +203,7 @@ hpux_thread_wait (struct target_ops *ops,
ptid = main_ptid; ptid = main_ptid;
rtnval = deprecated_child_ops.to_wait (&deprecated_child_ops, rtnval = deprecated_child_ops.to_wait (&deprecated_child_ops,
ptid, ourstatus); ptid, ourstatus, options);
rtnval = find_active_thread (); rtnval = find_active_thread ();

View File

@ -396,7 +396,7 @@ inf_ptrace_resume (struct target_ops *ops,
static ptid_t static ptid_t
inf_ptrace_wait (struct target_ops *ops, inf_ptrace_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
pid_t pid; pid_t pid;
int status, save_errno; int status, save_errno;

View File

@ -924,7 +924,7 @@ inf_ttrace_resume (struct target_ops *ops,
static ptid_t static ptid_t
inf_ttrace_wait (struct target_ops *ops, inf_ttrace_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
pid_t pid = ptid_get_pid (ptid); pid_t pid = ptid_get_pid (ptid);
lwpid_t lwpid = ptid_get_lwp (ptid); lwpid_t lwpid = ptid_get_lwp (ptid);

View File

@ -1842,9 +1842,9 @@ wait_for_inferior (int treat_exec_as_sigtrap)
struct cleanup *old_chain; struct cleanup *old_chain;
if (deprecated_target_wait_hook) if (deprecated_target_wait_hook)
ecs->ptid = deprecated_target_wait_hook (waiton_ptid, &ecs->ws); ecs->ptid = deprecated_target_wait_hook (waiton_ptid, &ecs->ws, 0);
else else
ecs->ptid = target_wait (waiton_ptid, &ecs->ws); ecs->ptid = target_wait (waiton_ptid, &ecs->ws, 0);
if (debug_infrun) if (debug_infrun)
print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws); print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws);
@ -1920,9 +1920,9 @@ fetch_inferior_event (void *client_data)
if (deprecated_target_wait_hook) if (deprecated_target_wait_hook)
ecs->ptid = ecs->ptid =
deprecated_target_wait_hook (waiton_ptid, &ecs->ws); deprecated_target_wait_hook (waiton_ptid, &ecs->ws, TARGET_WNOHANG);
else else
ecs->ptid = target_wait (waiton_ptid, &ecs->ws); ecs->ptid = target_wait (waiton_ptid, &ecs->ws, TARGET_WNOHANG);
if (debug_infrun) if (debug_infrun)
print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws); print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws);

View File

@ -1341,7 +1341,6 @@ linux_nat_create_inferior (struct target_ops *ops,
char *exec_file, char *allargs, char **env, char *exec_file, char *allargs, char **env,
int from_tty) int from_tty)
{ {
int saved_async = 0;
#ifdef HAVE_PERSONALITY #ifdef HAVE_PERSONALITY
int personality_orig = 0, personality_set = 0; int personality_orig = 0, personality_set = 0;
#endif /* HAVE_PERSONALITY */ #endif /* HAVE_PERSONALITY */
@ -1349,11 +1348,6 @@ linux_nat_create_inferior (struct target_ops *ops,
/* The fork_child mechanism is synchronous and calls target_wait, so /* The fork_child mechanism is synchronous and calls target_wait, so
we have to mask the async mode. */ we have to mask the async mode. */
if (target_can_async_p ())
/* Mask async mode. Creating a child requires a loop calling
wait_for_inferior currently. */
saved_async = linux_nat_async_mask (0);
#ifdef HAVE_PERSONALITY #ifdef HAVE_PERSONALITY
if (disable_randomization) if (disable_randomization)
{ {
@ -1383,9 +1377,6 @@ linux_nat_create_inferior (struct target_ops *ops,
safe_strerror (errno)); safe_strerror (errno));
} }
#endif /* HAVE_PERSONALITY */ #endif /* HAVE_PERSONALITY */
if (saved_async)
linux_nat_async_mask (saved_async);
} }
static void static void
@ -2687,7 +2678,8 @@ linux_nat_filter_event (int lwpid, int status, int options)
static ptid_t static ptid_t
linux_nat_wait_1 (struct target_ops *ops, linux_nat_wait_1 (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus,
int target_options)
{ {
static sigset_t prev_mask; static sigset_t prev_mask;
struct lwp_info *lp = NULL; struct lwp_info *lp = NULL;
@ -2822,8 +2814,9 @@ retry:
set_sigint_trap (); set_sigint_trap ();
} }
if (target_can_async_p ()) /* Translate generic target_wait options into waitpid options. */
options |= WNOHANG; /* In async mode, don't block. */ if (target_options & TARGET_WNOHANG)
options |= WNOHANG;
while (lp == NULL) while (lp == NULL)
{ {
@ -2928,7 +2921,7 @@ retry:
In sync mode, suspend waiting for a SIGCHLD signal. */ In sync mode, suspend waiting for a SIGCHLD signal. */
if (options & __WCLONE) if (options & __WCLONE)
{ {
if (target_can_async_p ()) if (target_options & TARGET_WNOHANG)
{ {
/* No interesting event. */ /* No interesting event. */
ourstatus->kind = TARGET_WAITKIND_IGNORE; ourstatus->kind = TARGET_WAITKIND_IGNORE;
@ -3072,7 +3065,8 @@ retry:
static ptid_t static ptid_t
linux_nat_wait (struct target_ops *ops, linux_nat_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus,
int target_options)
{ {
ptid_t event_ptid; ptid_t event_ptid;
@ -3083,7 +3077,7 @@ linux_nat_wait (struct target_ops *ops,
if (target_can_async_p ()) if (target_can_async_p ())
async_file_flush (); async_file_flush ();
event_ptid = linux_nat_wait_1 (ops, ptid, ourstatus); event_ptid = linux_nat_wait_1 (ops, ptid, ourstatus, target_options);
/* If we requested any event, and something came out, assume there /* If we requested any event, and something came out, assume there
may be more. If we requested a specific lwp or process, also may be more. If we requested a specific lwp or process, also

View File

@ -1178,12 +1178,13 @@ check_event (ptid_t ptid)
static ptid_t static ptid_t
thread_db_wait (struct target_ops *ops, thread_db_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus,
int options)
{ {
struct thread_db_info *info; struct thread_db_info *info;
struct target_ops *beneath = find_target_beneath (ops); struct target_ops *beneath = find_target_beneath (ops);
ptid = beneath->to_wait (beneath, ptid, ourstatus); ptid = beneath->to_wait (beneath, ptid, ourstatus, options);
if (ourstatus->kind == TARGET_WAITKIND_IGNORE) if (ourstatus->kind == TARGET_WAITKIND_IGNORE)
return ptid; return ptid;

View File

@ -1065,7 +1065,7 @@ monitor_wait_filter (char *buf,
static ptid_t static ptid_t
monitor_wait (struct target_ops *ops, monitor_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
int old_timeout = timeout; int old_timeout = timeout;
char buf[TARGET_BUF_SIZE]; char buf[TARGET_BUF_SIZE];

View File

@ -623,7 +623,7 @@ nto_interrupt (int signo)
static ptid_t static ptid_t
procfs_wait (struct target_ops *ops, procfs_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
sigset_t set; sigset_t set;
siginfo_t info; siginfo_t info;

View File

@ -98,7 +98,8 @@ static void (*record_beneath_to_resume) (struct target_ops *, ptid_t, int,
enum target_signal); enum target_signal);
static struct target_ops *record_beneath_to_wait_ops; static struct target_ops *record_beneath_to_wait_ops;
static ptid_t (*record_beneath_to_wait) (struct target_ops *, ptid_t, static ptid_t (*record_beneath_to_wait) (struct target_ops *, ptid_t,
struct target_waitstatus *); struct target_waitstatus *,
int);
static struct target_ops *record_beneath_to_store_registers_ops; static struct target_ops *record_beneath_to_store_registers_ops;
static void (*record_beneath_to_store_registers) (struct target_ops *, static void (*record_beneath_to_store_registers) (struct target_ops *,
struct regcache *, struct regcache *,
@ -566,7 +567,8 @@ record_wait_cleanups (void *ignore)
static ptid_t static ptid_t
record_wait (struct target_ops *ops, record_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status,
int options)
{ {
struct cleanup *set_cleanups = record_gdb_operation_disable_set (); struct cleanup *set_cleanups = record_gdb_operation_disable_set ();
@ -590,7 +592,7 @@ record_wait (struct target_ops *ops,
{ {
/* This is a single step. */ /* This is a single step. */
return record_beneath_to_wait (record_beneath_to_wait_ops, return record_beneath_to_wait (record_beneath_to_wait_ops,
ptid, status); ptid, status, 0);
} }
else else
{ {
@ -601,7 +603,7 @@ record_wait (struct target_ops *ops,
while (1) while (1)
{ {
ret = record_beneath_to_wait (record_beneath_to_wait_ops, ret = record_beneath_to_wait (record_beneath_to_wait_ops,
ptid, status); ptid, status, 0);
if (status->kind == TARGET_WAITKIND_STOPPED if (status->kind == TARGET_WAITKIND_STOPPED
&& status->value.sig == TARGET_SIGNAL_TRAP) && status->value.sig == TARGET_SIGNAL_TRAP)

View File

@ -1695,7 +1695,7 @@ mips_signal_from_protocol (int sig)
static ptid_t static ptid_t
mips_wait (struct target_ops *ops, mips_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
int rstatus; int rstatus;
int err; int err;

View File

@ -676,7 +676,7 @@ gdbsim_cntrl_c (int signo)
static ptid_t static ptid_t
gdbsim_wait (struct target_ops *ops, gdbsim_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
static RETSIGTYPE (*prev_sigint) (); static RETSIGTYPE (*prev_sigint) ();
int sigrc = 0; int sigrc = 0;

View File

@ -4646,7 +4646,7 @@ process_stop_reply (struct stop_reply *stop_reply,
/* The non-stop mode version of target_wait. */ /* The non-stop mode version of target_wait. */
static ptid_t static ptid_t
remote_wait_ns (ptid_t ptid, struct target_waitstatus *status) remote_wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
{ {
struct remote_state *rs = get_remote_state (); struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state (); struct remote_arch_state *rsa = get_remote_arch_state ();
@ -4688,16 +4688,15 @@ remote_wait_ns (ptid_t ptid, struct target_waitstatus *status)
if (stop_reply != NULL) if (stop_reply != NULL)
return process_stop_reply (stop_reply, status); return process_stop_reply (stop_reply, status);
/* Still no event. If we're in asynchronous mode, then just /* Still no event. If we're just polling for an event, then
return to the event loop. */ return to the event loop. */
if (remote_is_async_p ()) if (options & TARGET_WNOHANG)
{ {
status->kind = TARGET_WAITKIND_IGNORE; status->kind = TARGET_WAITKIND_IGNORE;
return minus_one_ptid; return minus_one_ptid;
} }
/* Otherwise, asynchronous mode is masked, so do a blocking /* Otherwise do a blocking wait. */
wait. */
ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size, ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
1 /* forever */); 1 /* forever */);
} }
@ -4707,7 +4706,7 @@ remote_wait_ns (ptid_t ptid, struct target_waitstatus *status)
STATUS just as `wait' would. */ STATUS just as `wait' would. */
static ptid_t static ptid_t
remote_wait_as (ptid_t ptid, struct target_waitstatus *status) remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
{ {
struct remote_state *rs = get_remote_state (); struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state (); struct remote_arch_state *rsa = get_remote_arch_state ();
@ -4717,6 +4716,8 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status)
char *buf, *p; char *buf, *p;
struct stop_reply *stop_reply; struct stop_reply *stop_reply;
again:
status->kind = TARGET_WAITKIND_IGNORE; status->kind = TARGET_WAITKIND_IGNORE;
status->value.integer = 0; status->value.integer = 0;
@ -4819,8 +4820,14 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status)
} }
if (status->kind == TARGET_WAITKIND_IGNORE) if (status->kind == TARGET_WAITKIND_IGNORE)
/* Nothing interesting happened. */ {
return minus_one_ptid; /* Nothing interesting happened. If we're doing a non-blocking
poll, we're done. Otherwise, go back to waiting. */
if (options & TARGET_WNOHANG)
return minus_one_ptid;
else
goto again;
}
else if (status->kind != TARGET_WAITKIND_EXITED else if (status->kind != TARGET_WAITKIND_EXITED
&& status->kind != TARGET_WAITKIND_SIGNALLED) && status->kind != TARGET_WAITKIND_SIGNALLED)
{ {
@ -4841,24 +4848,14 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status)
static ptid_t static ptid_t
remote_wait (struct target_ops *ops, remote_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status) ptid_t ptid, struct target_waitstatus *status, int options)
{ {
ptid_t event_ptid; ptid_t event_ptid;
if (non_stop) if (non_stop)
event_ptid = remote_wait_ns (ptid, status); event_ptid = remote_wait_ns (ptid, status, options);
else else
{ event_ptid = remote_wait_as (ptid, status, options);
/* In synchronous mode, keep waiting until the target stops. In
asynchronous mode, always return to the event loop. */
do
{
event_ptid = remote_wait_as (ptid, status);
}
while (status->kind == TARGET_WAITKIND_IGNORE
&& !target_can_async_p ());
}
if (target_can_async_p ()) if (target_can_async_p ())
{ {

View File

@ -521,7 +521,7 @@ rs6000_xfer_partial (struct target_ops *ops, enum target_object object,
static ptid_t static ptid_t
rs6000_wait (struct target_ops *ops, rs6000_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
pid_t pid; pid_t pid;
int status, save_errno; int status, save_errno;

View File

@ -381,7 +381,7 @@ sol_thread_resume (struct target_ops *ops,
static ptid_t static ptid_t
sol_thread_wait (struct target_ops *ops, sol_thread_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
ptid_t rtnval; ptid_t rtnval;
ptid_t save_ptid; ptid_t save_ptid;
@ -407,7 +407,7 @@ sol_thread_wait (struct target_ops *ops,
GET_THREAD (save_ptid)); GET_THREAD (save_ptid));
} }
rtnval = beneath->to_wait (beneath, ptid, ourstatus); rtnval = beneath->to_wait (beneath, ptid, ourstatus, options);
if (ourstatus->kind != TARGET_WAITKIND_EXITED) if (ourstatus->kind != TARGET_WAITKIND_EXITED)
{ {

View File

@ -422,7 +422,7 @@ spu_child_post_attach (int pid)
minus_one_ptid in case of error; store status into *OURSTATUS. */ minus_one_ptid in case of error; store status into *OURSTATUS. */
static ptid_t static ptid_t
spu_child_wait (struct target_ops *ops, spu_child_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
int save_errno; int save_errno;
int status; int status;

View File

@ -1836,7 +1836,7 @@ target_disconnect (char *args, int from_tty)
} }
ptid_t ptid_t
target_wait (ptid_t ptid, struct target_waitstatus *status) target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
{ {
struct target_ops *t; struct target_ops *t;
@ -1844,7 +1844,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status)
{ {
if (t->to_wait != NULL) if (t->to_wait != NULL)
{ {
ptid_t retval = (*t->to_wait) (t, ptid, status); ptid_t retval = (*t->to_wait) (t, ptid, status, options);
if (targetdebug) if (targetdebug)
{ {

View File

@ -153,6 +153,13 @@ struct target_waitstatus
value; value;
}; };
/* Options that can be passed to target_wait. */
/* Return immediately if there's no event already queued. If this
options is not requested, target_wait blocks waiting for an
event. */
#define TARGET_WNOHANG 1
/* Return a pretty printed form of target_waitstatus. /* Return a pretty printed form of target_waitstatus.
Space for the result is malloc'd, caller must free. */ Space for the result is malloc'd, caller must free. */
extern char *target_waitstatus_to_string (const struct target_waitstatus *); extern char *target_waitstatus_to_string (const struct target_waitstatus *);
@ -327,7 +334,7 @@ struct target_ops
void (*to_disconnect) (struct target_ops *, char *, int); void (*to_disconnect) (struct target_ops *, char *, int);
void (*to_resume) (struct target_ops *, ptid_t, int, enum target_signal); void (*to_resume) (struct target_ops *, ptid_t, int, enum target_signal);
ptid_t (*to_wait) (struct target_ops *, ptid_t (*to_wait) (struct target_ops *,
ptid_t, struct target_waitstatus *); ptid_t, struct target_waitstatus *, int);
void (*to_fetch_registers) (struct target_ops *, struct regcache *, int); void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
void (*to_store_registers) (struct target_ops *, struct regcache *, int); void (*to_store_registers) (struct target_ops *, struct regcache *, int);
void (*to_prepare_to_store) (struct regcache *); void (*to_prepare_to_store) (struct regcache *);
@ -621,9 +628,11 @@ extern void target_resume (ptid_t ptid, int step, enum target_signal signal);
_NOT_ OK to throw_exception() out of target_wait() without popping _NOT_ OK to throw_exception() out of target_wait() without popping
the debugging target from the stack; GDB isn't prepared to get back the debugging target from the stack; GDB isn't prepared to get back
to the prompt with a debugging target but without the frame cache, to the prompt with a debugging target but without the frame cache,
stop_pc, etc., set up. */ stop_pc, etc., set up. OPTIONS is a bitwise OR of TARGET_W*
options. */
extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status); extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
int options);
/* Fetch at least register REGNO, or all regs if regno == -1. No result. */ /* Fetch at least register REGNO, or all regs if regno == -1. No result. */

View File

@ -266,7 +266,8 @@ void (*deprecated_memory_changed_hook) (CORE_ADDR addr, int len);
while waiting for target events. */ while waiting for target events. */
ptid_t (*deprecated_target_wait_hook) (ptid_t ptid, ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
struct target_waitstatus * status); struct target_waitstatus *status,
int options);
/* Used by UI as a wrapper around command execution. May do various things /* Used by UI as a wrapper around command execution. May do various things
like enabling/disabling buttons, etc... */ like enabling/disabling buttons, etc... */

View File

@ -160,7 +160,7 @@ tui_event_modify_breakpoint (int number)
Leave curses mode and setup program mode. */ Leave curses mode and setup program mode. */
static ptid_t static ptid_t
tui_target_wait_hook (ptid_t pid, tui_target_wait_hook (ptid_t pid,
struct target_waitstatus *status) struct target_waitstatus *status, int options)
{ {
ptid_t res; ptid_t res;
@ -174,7 +174,7 @@ tui_target_wait_hook (ptid_t pid,
} }
#endif #endif
tui_target_has_run = 1; tui_target_has_run = 1;
res = target_wait (pid, status); res = target_wait (pid, status, options);
if (tui_active) if (tui_active)
{ {

View File

@ -1494,7 +1494,7 @@ out:
/* Wait for interesting events to occur in the target process. */ /* Wait for interesting events to occur in the target process. */
static ptid_t static ptid_t
windows_wait (struct target_ops *ops, windows_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus) ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{ {
int pid = -1; int pid = -1;