summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-05-21 15:48:42 +0000
committerPedro Alves <palves@redhat.com>2009-05-21 15:48:42 +0000
commit47608cb1acc3880b330b8d3a8ad6aa29218046d9 (patch)
treeaa86b1ddd38ba6878b760346377a4dfebe955e1f /gdb
parent9944e9c2ac5e0e5d18eaf5100f6c57bf31cbe6e7 (diff)
downloadbinutils-gdb-47608cb1acc3880b330b8d3a8ad6aa29218046d9.tar.gz
* 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog51
-rw-r--r--gdb/bsd-uthread.c4
-rw-r--r--gdb/darwin-nat.c2
-rw-r--r--gdb/defs.h3
-rw-r--r--gdb/fork-child.c2
-rw-r--r--gdb/gnu-nat.c2
-rw-r--r--gdb/go32-nat.c2
-rw-r--r--gdb/hpux-thread.c4
-rw-r--r--gdb/inf-ptrace.c2
-rw-r--r--gdb/inf-ttrace.c2
-rw-r--r--gdb/infrun.c8
-rw-r--r--gdb/linux-nat.c24
-rw-r--r--gdb/linux-thread-db.c5
-rw-r--r--gdb/monitor.c2
-rw-r--r--gdb/nto-procfs.c2
-rw-r--r--gdb/record.c10
-rw-r--r--gdb/remote-mips.c2
-rw-r--r--gdb/remote-sim.c2
-rw-r--r--gdb/remote.c39
-rw-r--r--gdb/rs6000-nat.c2
-rw-r--r--gdb/sol-thread.c4
-rw-r--r--gdb/spu-linux-nat.c2
-rw-r--r--gdb/target.c4
-rw-r--r--gdb/target.h15
-rw-r--r--gdb/top.c3
-rw-r--r--gdb/tui/tui-hooks.c4
-rw-r--r--gdb/windows-nat.c2
27 files changed, 130 insertions, 74 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 70e30dd6db4..c45f8aaebbc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,56 @@
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>
+
* mi/mi-interp.c (mi_on_resume): Account for whole process
resumes.
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 5b0aa51a637..18287af9e8c 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -345,13 +345,13 @@ bsd_uthread_xfer_partial (struct target_ops *ops, enum target_object object,
static ptid_t
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;
struct target_ops *beneath = find_target_beneath (ops);
/* 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
out the thread ID. It will fail anyway. */
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index dc51ec635c1..8c20bd905a0 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -476,7 +476,7 @@ catch_exception_raise (mach_port_t port,
static ptid_t
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;
mach_msg_header_t *hdr = &msgin.hdr;
diff --git a/gdb/defs.h b/gdb/defs.h
index abf4b0285e2..0f91f3f1b9a 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -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_context_hook) (int);
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_detach_hook) (void);
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index 988154a11b3..9eadbc9969f 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -448,7 +448,7 @@ startup_inferior (int ntraps)
struct target_waitstatus 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)
/* The inferior didn't really stop, keep waiting. */
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index b3b89a40a63..daafb6250b4 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -1435,7 +1435,7 @@ struct inf *waiting_inf;
/* Wait for something to happen in the inferior, returning what in STATUS. */
static ptid_t
gnu_wait (struct target_ops *ops,
- ptid_t ptid, struct target_waitstatus *status)
+ ptid_t ptid, struct target_waitstatus *status, int options)
{
struct msg
{
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 5af281959b5..f0a3236c180 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -416,7 +416,7 @@ static char child_cwd[FILENAME_MAX];
static ptid_t
go32_wait (struct target_ops *ops,
- ptid_t ptid, struct target_waitstatus *status)
+ ptid_t ptid, struct target_waitstatus *status, int options)
{
int i;
unsigned char saved_opcode;
diff --git a/gdb/hpux-thread.c b/gdb/hpux-thread.c
index bdc547d97bb..ac96a7fe6c4 100644
--- a/gdb/hpux-thread.c
+++ b/gdb/hpux-thread.c
@@ -190,7 +190,7 @@ hpux_thread_resume (struct target_ops *ops,
static ptid_t
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;
struct cleanup *old_chain;
@@ -203,7 +203,7 @@ hpux_thread_wait (struct target_ops *ops,
ptid = main_ptid;
rtnval = deprecated_child_ops.to_wait (&deprecated_child_ops,
- ptid, ourstatus);
+ ptid, ourstatus, options);
rtnval = find_active_thread ();
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index d9f73386165..7076da7073b 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -396,7 +396,7 @@ inf_ptrace_resume (struct target_ops *ops,
static ptid_t
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;
int status, save_errno;
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index e78ad8ecf2b..a4c4b99aa65 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -924,7 +924,7 @@ inf_ttrace_resume (struct target_ops *ops,
static ptid_t
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);
lwpid_t lwpid = ptid_get_lwp (ptid);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 99873b180aa..489f9d160e8 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1842,9 +1842,9 @@ wait_for_inferior (int treat_exec_as_sigtrap)
struct cleanup *old_chain;
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
- ecs->ptid = target_wait (waiton_ptid, &ecs->ws);
+ ecs->ptid = target_wait (waiton_ptid, &ecs->ws, 0);
if (debug_infrun)
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)
ecs->ptid =
- deprecated_target_wait_hook (waiton_ptid, &ecs->ws);
+ deprecated_target_wait_hook (waiton_ptid, &ecs->ws, TARGET_WNOHANG);
else
- ecs->ptid = target_wait (waiton_ptid, &ecs->ws);
+ ecs->ptid = target_wait (waiton_ptid, &ecs->ws, TARGET_WNOHANG);
if (debug_infrun)
print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index d5799200002..8f125879500 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1341,7 +1341,6 @@ linux_nat_create_inferior (struct target_ops *ops,
char *exec_file, char *allargs, char **env,
int from_tty)
{
- int saved_async = 0;
#ifdef HAVE_PERSONALITY
int personality_orig = 0, personality_set = 0;
#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
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
if (disable_randomization)
{
@@ -1383,9 +1377,6 @@ linux_nat_create_inferior (struct target_ops *ops,
safe_strerror (errno));
}
#endif /* HAVE_PERSONALITY */
-
- if (saved_async)
- linux_nat_async_mask (saved_async);
}
static void
@@ -2687,7 +2678,8 @@ linux_nat_filter_event (int lwpid, int status, int options)
static ptid_t
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;
struct lwp_info *lp = NULL;
@@ -2822,8 +2814,9 @@ retry:
set_sigint_trap ();
}
- if (target_can_async_p ())
- options |= WNOHANG; /* In async mode, don't block. */
+ /* Translate generic target_wait options into waitpid options. */
+ if (target_options & TARGET_WNOHANG)
+ options |= WNOHANG;
while (lp == NULL)
{
@@ -2928,7 +2921,7 @@ retry:
In sync mode, suspend waiting for a SIGCHLD signal. */
if (options & __WCLONE)
{
- if (target_can_async_p ())
+ if (target_options & TARGET_WNOHANG)
{
/* No interesting event. */
ourstatus->kind = TARGET_WAITKIND_IGNORE;
@@ -3072,7 +3065,8 @@ retry:
static ptid_t
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;
@@ -3083,7 +3077,7 @@ linux_nat_wait (struct target_ops *ops,
if (target_can_async_p ())
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
may be more. If we requested a specific lwp or process, also
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 3efcae82327..3d49484a2b9 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1178,12 +1178,13 @@ check_event (ptid_t ptid)
static ptid_t
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 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)
return ptid;
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 1b41a165ef6..f77f46f320b 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -1065,7 +1065,7 @@ monitor_wait_filter (char *buf,
static ptid_t
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;
char buf[TARGET_BUF_SIZE];
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index b46c64d8db7..3ff99aab757 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -623,7 +623,7 @@ nto_interrupt (int signo)
static ptid_t
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;
siginfo_t info;
diff --git a/gdb/record.c b/gdb/record.c
index df59550b86f..dfd7487106f 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -98,7 +98,8 @@ static void (*record_beneath_to_resume) (struct target_ops *, ptid_t, int,
enum target_signal);
static struct target_ops *record_beneath_to_wait_ops;
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 void (*record_beneath_to_store_registers) (struct target_ops *,
struct regcache *,
@@ -566,7 +567,8 @@ record_wait_cleanups (void *ignore)
static ptid_t
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 ();
@@ -590,7 +592,7 @@ record_wait (struct target_ops *ops,
{
/* This is a single step. */
return record_beneath_to_wait (record_beneath_to_wait_ops,
- ptid, status);
+ ptid, status, 0);
}
else
{
@@ -601,7 +603,7 @@ record_wait (struct target_ops *ops,
while (1)
{
ret = record_beneath_to_wait (record_beneath_to_wait_ops,
- ptid, status);
+ ptid, status, 0);
if (status->kind == TARGET_WAITKIND_STOPPED
&& status->value.sig == TARGET_SIGNAL_TRAP)
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 23e845fd704..926e1d2ab9d 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -1695,7 +1695,7 @@ mips_signal_from_protocol (int sig)
static ptid_t
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 err;
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 4eae65aeca3..9b8d0fd7d69 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -676,7 +676,7 @@ gdbsim_cntrl_c (int signo)
static ptid_t
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) ();
int sigrc = 0;
diff --git a/gdb/remote.c b/gdb/remote.c
index 60d32048667..199120d553d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4646,7 +4646,7 @@ process_stop_reply (struct stop_reply *stop_reply,
/* The non-stop mode version of target_wait. */
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_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)
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. */
- if (remote_is_async_p ())
+ if (options & TARGET_WNOHANG)
{
status->kind = TARGET_WAITKIND_IGNORE;
return minus_one_ptid;
}
- /* Otherwise, asynchronous mode is masked, so do a blocking
- wait. */
+ /* Otherwise do a blocking wait. */
ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
1 /* forever */);
}
@@ -4707,7 +4706,7 @@ remote_wait_ns (ptid_t ptid, struct target_waitstatus *status)
STATUS just as `wait' would. */
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_arch_state *rsa = get_remote_arch_state ();
@@ -4717,6 +4716,8 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status)
char *buf, *p;
struct stop_reply *stop_reply;
+ again:
+
status->kind = TARGET_WAITKIND_IGNORE;
status->value.integer = 0;
@@ -4819,8 +4820,14 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status)
}
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
&& status->kind != TARGET_WAITKIND_SIGNALLED)
{
@@ -4841,24 +4848,14 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status)
static ptid_t
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;
if (non_stop)
- event_ptid = remote_wait_ns (ptid, status);
+ event_ptid = remote_wait_ns (ptid, status, options);
else
- {
- /* 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 ());
- }
+ event_ptid = remote_wait_as (ptid, status, options);
if (target_can_async_p ())
{
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 8aeef25b5c6..92bbabd872d 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -521,7 +521,7 @@ rs6000_xfer_partial (struct target_ops *ops, enum target_object object,
static ptid_t
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;
int status, save_errno;
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index cf085f0c243..028e036eb63 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -381,7 +381,7 @@ sol_thread_resume (struct target_ops *ops,
static ptid_t
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 save_ptid;
@@ -407,7 +407,7 @@ sol_thread_wait (struct target_ops *ops,
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)
{
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index 3b1e3378501..b8897e188fd 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -422,7 +422,7 @@ spu_child_post_attach (int pid)
minus_one_ptid in case of error; store status into *OURSTATUS. */
static ptid_t
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 status;
diff --git a/gdb/target.c b/gdb/target.c
index 506fce710d7..8cbde1b91ec 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1836,7 +1836,7 @@ target_disconnect (char *args, int from_tty)
}
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;
@@ -1844,7 +1844,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status)
{
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)
{
diff --git a/gdb/target.h b/gdb/target.h
index b94149ab99f..5ec06a08e6f 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -153,6 +153,13 @@ struct target_waitstatus
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.
Space for the result is malloc'd, caller must free. */
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_resume) (struct target_ops *, ptid_t, int, enum target_signal);
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_store_registers) (struct target_ops *, struct regcache *, int);
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
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,
- 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. */
diff --git a/gdb/top.c b/gdb/top.c
index 5654535453a..ba635eaa649 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -266,7 +266,8 @@ void (*deprecated_memory_changed_hook) (CORE_ADDR addr, int len);
while waiting for target events. */
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
like enabling/disabling buttons, etc... */
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index aa4ecca2bde..7dee03e47ec 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -160,7 +160,7 @@ tui_event_modify_breakpoint (int number)
Leave curses mode and setup program mode. */
static ptid_t
tui_target_wait_hook (ptid_t pid,
- struct target_waitstatus *status)
+ struct target_waitstatus *status, int options)
{
ptid_t res;
@@ -174,7 +174,7 @@ tui_target_wait_hook (ptid_t pid,
}
#endif
tui_target_has_run = 1;
- res = target_wait (pid, status);
+ res = target_wait (pid, status, options);
if (tui_active)
{
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 5b9b6f9700a..32a412664e5 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1494,7 +1494,7 @@ out:
/* Wait for interesting events to occur in the target process. */
static ptid_t
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;