* [patch] Fix recent gdb.mi testsuite "unknown output after running"
@ 2009-05-20 18:32 Jan Kratochvil
2009-05-21 2:16 ` Pedro Alves
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2009-05-20 18:32 UTC (permalink / raw)
To: gdb-patches
Hi,
recently getting on Fedora 11 (=Rawhide) x86_64:
FAIL: gdb.mi/mi-nsintrall.exp: mi runto main (unknown output after running)
ERROR: mi-nsintrall.exp tests suppressed
FAIL: gdb.mi/mi-async.exp: start: stop (unknown output after running)
FAIL: gdb.mi/mi-async.exp: restart: stop (unknown output after running)
FAIL: gdb.mi/mi-nsmoribund.exp: mi runto main (unknown output after running)
ERROR: mi-nsmoribund.exp tests suppressed
FAIL: gdb.mi/mi-nonstop.exp: mi runto main (unknown output after running)
ERROR: mi-nonstop.exp tests suppressed
FAIL: gdb.mi/mi-nonstop-exit.exp: mi runto main (unknown output after running)
ERROR: mi-nonstop-exit.exp tests suppressed
but it is more a bug in the testsuite as GDB output looks valid (below).
Attaching a quick fix, just I understand an MI grammar compliant parser would
be better for the testsuite.
Regards,
Jan
^running^M
*running,thread-id="all"^M
(gdb) ^M
mi_expect_stop: expecting: \*stopped,reason="breakpoint-hit",disp="del",bkptno="[0-9]+",frame={addr="0x[0-9A-Fa-f]+",func="main",args=\[\],file="[^
]*.*basics.c",fullname="(/[^\n]*/|\\\\[^\\]+\\[^\n]+\\|\\[^\\][^\n]*\\|[a-zA-Z]:[^\n]*\\).*basics.c",line="66"},thread-id="[0-9]+",stopped-threads=[^
]*^M
(=thread-selected,id="[0-9+]"^M
)?
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0"^M
(gdb) ^M
got =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0"^M
(gdb) ^M
FAIL: gdb.mi/mi-async.exp: start: stop (unknown output after running)
next^M
=library-loaded,id="/lib64/libm.so.6",target-name="/lib64/libm.so.6",host-name="/lib64/libm.so.6",symbols-loaded="0"^M
=library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0"^M
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x00000000004005a4",func="main",args=[],file="../.././gdb/testsuite/gdb.mi/basics.c",fullname="/home/jkratoch/redhat/gdb-cvs-clean/gdb/testsuite/gdb.mi/basics.c",line="66"},thread-id="1",stopped-threads="all"^M
&"next\n"^M
^running^M
gdb/testsuite/
2009-05-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* lib/mi-support.exp (mi_expect_stop): Fix parsing unexpected prompt in
async mode.
--- gdb/testsuite/lib/mi-support.exp 2 Apr 2009 15:43:10 -0000 1.83
+++ gdb/testsuite/lib/mi-support.exp 20 May 2009 18:26:44 -0000
@@ -1044,6 +1044,11 @@ proc mi_expect_stop { reason func args f
return -1
}
-re ".*\r\n$mi_gdb_prompt$" {
+ if {$async} {
+ # There can appear arbitrary prompts in the async mode, the
+ # expected response will come later.
+ exp_continue
+ }
verbose -log "got $expect_out(buffer)"
fail "$test (unknown output after running)"
return -1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] Fix recent gdb.mi testsuite "unknown output after running" 2009-05-20 18:32 [patch] Fix recent gdb.mi testsuite "unknown output after running" Jan Kratochvil @ 2009-05-21 2:16 ` Pedro Alves 2009-05-21 13:46 ` Pedro Alves 0 siblings, 1 reply; 4+ messages in thread From: Pedro Alves @ 2009-05-21 2:16 UTC (permalink / raw) To: gdb-patches; +Cc: Jan Kratochvil On Wednesday 20 May 2009 19:32:10, Jan Kratochvil wrote: > recently getting on Fedora 11 (=Rawhide) x86_64: > > FAIL: gdb.mi/mi-nsintrall.exp: mi runto main (unknown output after running) > ERROR: mi-nsintrall.exp tests suppressed > FAIL: gdb.mi/mi-async.exp: start: stop (unknown output after running) > FAIL: gdb.mi/mi-async.exp: restart: stop (unknown output after running) > FAIL: gdb.mi/mi-nsmoribund.exp: mi runto main (unknown output after running) > ERROR: mi-nsmoribund.exp tests suppressed > FAIL: gdb.mi/mi-nonstop.exp: mi runto main (unknown output after running) > ERROR: mi-nonstop.exp tests suppressed > FAIL: gdb.mi/mi-nonstop-exit.exp: mi runto main (unknown output after running) > ERROR: mi-nonstop-exit.exp tests suppressed > > but it is more a bug in the testsuite as GDB output looks valid (below). > > Attaching a quick fix, just I understand an MI grammar compliant parser would > be better for the testsuite. I'd like to understand what caused this. This is probably related to my recent changes to linux-nat.c to rework async mode, and add multiprocess, although I wasn't seeing this when I commited them. -- Pedro Alves ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix recent gdb.mi testsuite "unknown output after running" 2009-05-21 2:16 ` Pedro Alves @ 2009-05-21 13:46 ` Pedro Alves 2009-05-21 15:54 ` [commit] New target_wait `options' argument, and new TARGET_WNOHANG option. (was: Re: [patch] Fix recent gdb.mi testsuite "unknown output after running") Pedro Alves 0 siblings, 1 reply; 4+ messages in thread From: Pedro Alves @ 2009-05-21 13:46 UTC (permalink / raw) To: gdb-patches; +Cc: Jan Kratochvil On Thursday 21 May 2009 03:16:29, Pedro Alves wrote: > On Wednesday 20 May 2009 19:32:10, Jan Kratochvil wrote: > > > recently getting on Fedora 11 (=Rawhide) x86_64: > > > > FAIL: gdb.mi/mi-nsintrall.exp: mi runto main (unknown output after running) > > ERROR: mi-nsintrall.exp tests suppressed > > FAIL: gdb.mi/mi-async.exp: start: stop (unknown output after running) > > FAIL: gdb.mi/mi-async.exp: restart: stop (unknown output after running) > > FAIL: gdb.mi/mi-nsmoribund.exp: mi runto main (unknown output after running) > > ERROR: mi-nsmoribund.exp tests suppressed > > FAIL: gdb.mi/mi-nonstop.exp: mi runto main (unknown output after running) > > ERROR: mi-nonstop.exp tests suppressed > > FAIL: gdb.mi/mi-nonstop-exit.exp: mi runto main (unknown output after running) > > ERROR: mi-nonstop-exit.exp tests suppressed > > > > but it is more a bug in the testsuite as GDB output looks valid (below). > > > > Attaching a quick fix, just I understand an MI grammar compliant parser would > > be better for the testsuite. > > I'd like to understand what caused this. This is probably related > to my recent changes to linux-nat.c to rework async mode, and add > multiprocess, although I wasn't seeing this when I commited them. It was, pie on my face. I changed linux_nat_is_async_p recently to do: - return 1; + /* See target.h/target_async_mask. */ + return linux_nat_async_mask_value; ... and, linux_nat_create_inferior does: static void linux_nat_create_inferior (struct target_ops *ops, char *exec_file, char *allargs, char **env, int from_tty) { int saved_async = 0; /* 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); linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty); if (saved_async) linux_nat_async_mask (saved_async); } The bowls of linux_ops->to_create_inferior do: fork_inferior -> startup_inferior -> target_wait -> target_resume and mi/mi-interp.c:mi_on_resume has this: if (!running_result_record_printed && mi_proceeded) { running_result_record_printed = 1; /* This is what gdb used to do historically -- printing prompt even if it cannot actually accept any input. This will be surely removed for MI3, and may be removed even earler. */ /* FIXME: review the use of target_is_async_p here -- is that what we want? */ if (!target_is_async_p ()) ^^^^^^^^^^^^^^^^^^^^^^^^^^ fputs_unfiltered ("(gdb) \n", raw_stdout); } The target_is_async_p call here is now returning false due to the async masking in create_inferior, and hence we're outputting that extra prompt. Sigh. I believe that the check on target_is_async_p is correct, but, something else is broken, namely the whole async-masking workaround mechanism. Here's what I think is a better solution (something that I mentioned before in other similar contexts, and what I've actually done on gdbserver too): - target_wait is modeled on wait(2), and has in the mean time gained a `pid' argument; so it is something between a `wait' and a `waitpid' --- it doesn't have an `options' flag. If we add it a new `options' parameter, we can have the caller selectivelly pass down to the target that a blocking or non-blocking target_wait is requested, and we can make the targets stop checking on the target_is_async_p/target_can_async_p "globals". startup_inferior wants a blocking wait, so does wait_for_inferior. fetch_inferior_event never wants to block. We drop the async masking on linux_nat_create_inferior. We could also drop the masking on infcall.c, but I left it out for the moment, for no other reason than wanting splitting this bug fix from further cleanup. The patch below implements it. The only interesting changes are to infrun.c, fork-child.c, linux-nat.c, and remote.c. All the rest is trivial adjustment to all other target_wait implementations, and none of them care about the new argument, because no other target implements async mode. I've tested this on native linux async, and local gdbserver in async mode too. I'll check it in if there are no knee-jerk reactions. ( warning, description + ChangeLog entry are bigger than the patch itself :-) ) -- Pedro Alves 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. --- gdb/bsd-uthread.c | 2 +- gdb/darwin-nat.c | 2 +- gdb/defs.h | 3 ++- gdb/fork-child.c | 2 +- gdb/gnu-nat.c | 2 +- gdb/go32-nat.c | 2 +- gdb/hpux-thread.c | 4 ++-- gdb/inf-ptrace.c | 2 +- gdb/inf-ttrace.c | 2 +- gdb/infrun.c | 8 ++++---- gdb/linux-nat.c | 24 +++++++++--------------- gdb/linux-thread-db.c | 5 +++-- gdb/monitor.c | 2 +- gdb/nto-procfs.c | 2 +- gdb/record.c | 10 ++++++---- gdb/remote-mips.c | 2 +- gdb/remote-sim.c | 2 +- gdb/remote.c | 39 ++++++++++++++++++--------------------- gdb/rs6000-nat.c | 2 +- gdb/sol-thread.c | 4 ++-- gdb/spu-linux-nat.c | 2 +- gdb/target.c | 4 ++-- gdb/target.h | 9 +++++++-- gdb/top.c | 3 ++- gdb/tui/tui-hooks.c | 4 ++-- gdb/windows-nat.c | 2 +- 26 files changed, 73 insertions(+), 72 deletions(-) Index: src/gdb/target.h =================================================================== --- src.orig/gdb/target.h 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/target.h 2009-05-21 14:19:26.000000000 +0100 @@ -153,6 +153,10 @@ struct target_waitstatus value; }; +/* Options that can be passed to target_wait. */ + +#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 +331,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 *); @@ -623,7 +627,8 @@ extern void target_resume (ptid_t ptid, to the prompt with a debugging target but without the frame cache, stop_pc, etc., set up. */ -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. */ Index: src/gdb/target.c =================================================================== --- src.orig/gdb/target.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/target.c 2009-05-21 14:19:26.000000000 +0100 @@ -1836,7 +1836,7 @@ target_disconnect (char *args, int from_ } 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_ { 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) { Index: src/gdb/infrun.c =================================================================== --- src.orig/gdb/infrun.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/infrun.c 2009-05-21 14:19:26.000000000 +0100 @@ -1842,9 +1842,9 @@ wait_for_inferior (int treat_exec_as_sig 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); Index: src/gdb/fork-child.c =================================================================== --- src.orig/gdb/fork-child.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/fork-child.c 2009-05-21 14:19:26.000000000 +0100 @@ -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. */ Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/linux-nat.c 2009-05-21 14:19:26.000000000 +0100 @@ -1341,7 +1341,6 @@ linux_nat_create_inferior (struct target 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 /* 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 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 s 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 options into linux 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 Index: src/gdb/remote.c =================================================================== --- src.orig/gdb/remote.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/remote.c 2009-05-21 14:19:26.000000000 +0100 @@ -4646,7 +4646,7 @@ process_stop_reply (struct stop_reply *s /* 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 targ 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 targ 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 targ 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 targ } 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 targ 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 ()) { Index: src/gdb/bsd-uthread.c =================================================================== --- src.orig/gdb/bsd-uthread.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/bsd-uthread.c 2009-05-21 14:19:26.000000000 +0100 @@ -345,7 +345,7 @@ bsd_uthread_xfer_partial (struct target_ 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); Index: src/gdb/darwin-nat.c =================================================================== --- src.orig/gdb/darwin-nat.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/darwin-nat.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; Index: src/gdb/defs.h =================================================================== --- src.orig/gdb/defs.h 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/defs.h 2009-05-21 14:19:26.000000000 +0100 @@ -1111,7 +1111,8 @@ extern void (*deprecated_register_change 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); Index: src/gdb/gnu-nat.c =================================================================== --- src.orig/gdb/gnu-nat.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/gnu-nat.c 2009-05-21 14:19:26.000000000 +0100 @@ -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 { Index: src/gdb/go32-nat.c =================================================================== --- src.orig/gdb/go32-nat.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/go32-nat.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; Index: src/gdb/hpux-thread.c =================================================================== --- src.orig/gdb/hpux-thread.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/hpux-thread.c 2009-05-21 14:19:26.000000000 +0100 @@ -190,7 +190,7 @@ hpux_thread_resume (struct target_ops *o 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 (); Index: src/gdb/inf-ptrace.c =================================================================== --- src.orig/gdb/inf-ptrace.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/inf-ptrace.c 2009-05-21 14:19:26.000000000 +0100 @@ -396,7 +396,7 @@ inf_ptrace_resume (struct target_ops *op 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; Index: src/gdb/inf-ttrace.c =================================================================== --- src.orig/gdb/inf-ttrace.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/inf-ttrace.c 2009-05-21 14:19:26.000000000 +0100 @@ -924,7 +924,7 @@ inf_ttrace_resume (struct target_ops *op 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); Index: src/gdb/linux-thread-db.c =================================================================== --- src.orig/gdb/linux-thread-db.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/linux-thread-db.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; Index: src/gdb/monitor.c =================================================================== --- src.orig/gdb/monitor.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/monitor.c 2009-05-21 14:19:26.000000000 +0100 @@ -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]; Index: src/gdb/nto-procfs.c =================================================================== --- src.orig/gdb/nto-procfs.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/nto-procfs.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; Index: src/gdb/record.c =================================================================== --- src.orig/gdb/record.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/record.c 2009-05-21 14:19:26.000000000 +0100 @@ -98,7 +98,8 @@ static void (*record_beneath_to_resume) 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) Index: src/gdb/remote-mips.c =================================================================== --- src.orig/gdb/remote-mips.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/remote-mips.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; Index: src/gdb/remote-sim.c =================================================================== --- src.orig/gdb/remote-sim.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/remote-sim.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; Index: src/gdb/rs6000-nat.c =================================================================== --- src.orig/gdb/rs6000-nat.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/rs6000-nat.c 2009-05-21 14:19:26.000000000 +0100 @@ -521,7 +521,7 @@ rs6000_xfer_partial (struct target_ops * 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; Index: src/gdb/sol-thread.c =================================================================== --- src.orig/gdb/sol-thread.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/sol-thread.c 2009-05-21 14:19:26.000000000 +0100 @@ -381,7 +381,7 @@ sol_thread_resume (struct target_ops *op 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) { Index: src/gdb/spu-linux-nat.c =================================================================== --- src.orig/gdb/spu-linux-nat.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/spu-linux-nat.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; Index: src/gdb/top.c =================================================================== --- src.orig/gdb/top.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/top.c 2009-05-21 14:19:26.000000000 +0100 @@ -266,7 +266,8 @@ void (*deprecated_memory_changed_hook) ( 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... */ Index: src/gdb/tui/tui-hooks.c =================================================================== --- src.orig/gdb/tui/tui-hooks.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/tui/tui-hooks.c 2009-05-21 14:19:26.000000000 +0100 @@ -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) { Index: src/gdb/windows-nat.c =================================================================== --- src.orig/gdb/windows-nat.c 2009-05-21 14:19:25.000000000 +0100 +++ src/gdb/windows-nat.c 2009-05-21 14:19:26.000000000 +0100 @@ -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; ^ permalink raw reply [flat|nested] 4+ messages in thread
* [commit] New target_wait `options' argument, and new TARGET_WNOHANG option. (was: Re: [patch] Fix recent gdb.mi testsuite "unknown output after running") 2009-05-21 13:46 ` Pedro Alves @ 2009-05-21 15:54 ` Pedro Alves 0 siblings, 0 replies; 4+ messages in thread From: Pedro Alves @ 2009-05-21 15:54 UTC (permalink / raw) To: gdb-patches; +Cc: Jan Kratochvil [changing title, almost-full quoting for context. skip to see patch] On Thursday 21 May 2009 14:46:13, Pedro Alves wrote: > On Thursday 21 May 2009 03:16:29, Pedro Alves wrote: > > On Wednesday 20 May 2009 19:32:10, Jan Kratochvil wrote: > > > > > recently getting on Fedora 11 (=Rawhide) x86_64: > > > > > > FAIL: gdb.mi/mi-nsintrall.exp: mi runto main (unknown output after running) > > > ERROR: mi-nsintrall.exp tests suppressed > > > FAIL: gdb.mi/mi-async.exp: start: stop (unknown output after running) > > > FAIL: gdb.mi/mi-async.exp: restart: stop (unknown output after running) > > > FAIL: gdb.mi/mi-nsmoribund.exp: mi runto main (unknown output after running) > > > ERROR: mi-nsmoribund.exp tests suppressed > > > FAIL: gdb.mi/mi-nonstop.exp: mi runto main (unknown output after running) > > > ERROR: mi-nonstop.exp tests suppressed > > > FAIL: gdb.mi/mi-nonstop-exit.exp: mi runto main (unknown output after running) > > > ERROR: mi-nonstop-exit.exp tests suppressed > > > > > > but it is more a bug in the testsuite as GDB output looks valid (below). > > > > > > Attaching a quick fix, just I understand an MI grammar compliant parser would > > > be better for the testsuite. > > > > I'd like to understand what caused this. This is probably related > > to my recent changes to linux-nat.c to rework async mode, and add > > multiprocess, although I wasn't seeing this when I commited them. > > It was, pie on my face. > > I changed linux_nat_is_async_p recently to do: > > - return 1; > + /* See target.h/target_async_mask. */ > + return linux_nat_async_mask_value; > > ... and, linux_nat_create_inferior does: > > static void > linux_nat_create_inferior (struct target_ops *ops, > char *exec_file, char *allargs, char **env, > int from_tty) > { > int saved_async = 0; > > /* 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); > > linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty); > > if (saved_async) > linux_nat_async_mask (saved_async); > } > > The bowls of linux_ops->to_create_inferior do: > > fork_inferior > -> startup_inferior > -> target_wait > -> target_resume > > > and mi/mi-interp.c:mi_on_resume has this: > > if (!running_result_record_printed && mi_proceeded) > { > running_result_record_printed = 1; > /* This is what gdb used to do historically -- printing prompt even if > it cannot actually accept any input. This will be surely removed > for MI3, and may be removed even earler. */ > /* FIXME: review the use of target_is_async_p here -- is that > what we want? */ > if (!target_is_async_p ()) > ^^^^^^^^^^^^^^^^^^^^^^^^^^ > fputs_unfiltered ("(gdb) \n", raw_stdout); > } > > The target_is_async_p call here is now returning false due to the async > masking in create_inferior, and hence we're outputting that extra > prompt. Sigh. I believe that the check on target_is_async_p is > correct, but, something else is broken, namely the whole async-masking > workaround mechanism. > > Here's what I think is a better solution (something that I > mentioned before in other similar contexts, and what I've actually > done on gdbserver too): > > - target_wait is modeled on wait(2), and has in the mean time > gained a `pid' argument; so it is something between a `wait' and > a `waitpid' --- it doesn't have an `options' flag. If we add it > a new `options' parameter, we can have the caller selectivelly pass > down to the target that a blocking or non-blocking target_wait is > requested, and we can make the targets stop checking on the > target_is_async_p/target_can_async_p "globals". startup_inferior > wants a blocking wait, so does wait_for_inferior. fetch_inferior_event > never wants to block. We drop the async masking on > linux_nat_create_inferior. We could also drop the masking on > infcall.c, but I left it out for the moment, for no other reason than > wanting splitting this bug fix from further cleanup. > > The patch below implements it. The only interesting changes are > to infrun.c, fork-child.c, linux-nat.c, and remote.c. All the > rest is trivial adjustment to all other target_wait implementations, > and none of them care about the new argument, because no other > target implements async mode. > > I've tested this on native linux async, and local gdbserver in > async mode too. I'll check it in if there are no knee-jerk > reactions. > > ( warning, description + ChangeLog entry are bigger than > the patch itself :-) ) > The version below is now checked in. I've added describing comments to TARGET_WNOHANG, and fixed bsd-uthread.c's target_wait to pass the new option to the target beneath, which I missed in the previous patch. -- Pedro Alves 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. --- gdb/bsd-uthread.c | 4 ++-- gdb/darwin-nat.c | 2 +- gdb/defs.h | 3 ++- gdb/fork-child.c | 2 +- gdb/gnu-nat.c | 2 +- gdb/go32-nat.c | 2 +- gdb/hpux-thread.c | 4 ++-- gdb/inf-ptrace.c | 2 +- gdb/inf-ttrace.c | 2 +- gdb/infrun.c | 8 ++++---- gdb/linux-nat.c | 24 +++++++++--------------- gdb/linux-thread-db.c | 5 +++-- gdb/monitor.c | 2 +- gdb/nto-procfs.c | 2 +- gdb/record.c | 10 ++++++---- gdb/remote-mips.c | 2 +- gdb/remote-sim.c | 2 +- gdb/remote.c | 39 ++++++++++++++++++--------------------- gdb/rs6000-nat.c | 2 +- gdb/sol-thread.c | 4 ++-- gdb/spu-linux-nat.c | 2 +- gdb/target.c | 4 ++-- gdb/target.h | 15 ++++++++++++--- gdb/top.c | 3 ++- gdb/tui/tui-hooks.c | 4 ++-- gdb/windows-nat.c | 2 +- 26 files changed, 79 insertions(+), 74 deletions(-) Index: src/gdb/target.h =================================================================== --- src.orig/gdb/target.h 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/target.h 2009-05-21 16:26:04.000000000 +0100 @@ -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, _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. */ Index: src/gdb/target.c =================================================================== --- src.orig/gdb/target.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/target.c 2009-05-21 16:22:13.000000000 +0100 @@ -1836,7 +1836,7 @@ target_disconnect (char *args, int from_ } 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_ { 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) { Index: src/gdb/infrun.c =================================================================== --- src.orig/gdb/infrun.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/infrun.c 2009-05-21 16:22:13.000000000 +0100 @@ -1842,9 +1842,9 @@ wait_for_inferior (int treat_exec_as_sig 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); Index: src/gdb/fork-child.c =================================================================== --- src.orig/gdb/fork-child.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/fork-child.c 2009-05-21 16:22:13.000000000 +0100 @@ -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. */ Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/linux-nat.c 2009-05-21 16:27:18.000000000 +0100 @@ -1341,7 +1341,6 @@ linux_nat_create_inferior (struct target 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 /* 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 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 s 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 Index: src/gdb/remote.c =================================================================== --- src.orig/gdb/remote.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/remote.c 2009-05-21 16:22:13.000000000 +0100 @@ -4646,7 +4646,7 @@ process_stop_reply (struct stop_reply *s /* 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 targ 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 targ 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 targ 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 targ } 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 targ 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 ()) { Index: src/gdb/bsd-uthread.c =================================================================== --- src.orig/gdb/bsd-uthread.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/bsd-uthread.c 2009-05-21 16:22:13.000000000 +0100 @@ -345,13 +345,13 @@ bsd_uthread_xfer_partial (struct target_ 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. */ Index: src/gdb/darwin-nat.c =================================================================== --- src.orig/gdb/darwin-nat.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/darwin-nat.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; Index: src/gdb/defs.h =================================================================== --- src.orig/gdb/defs.h 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/defs.h 2009-05-21 16:22:13.000000000 +0100 @@ -1111,7 +1111,8 @@ extern void (*deprecated_register_change 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); Index: src/gdb/gnu-nat.c =================================================================== --- src.orig/gdb/gnu-nat.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/gnu-nat.c 2009-05-21 16:22:13.000000000 +0100 @@ -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 { Index: src/gdb/go32-nat.c =================================================================== --- src.orig/gdb/go32-nat.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/go32-nat.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; Index: src/gdb/hpux-thread.c =================================================================== --- src.orig/gdb/hpux-thread.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/hpux-thread.c 2009-05-21 16:22:13.000000000 +0100 @@ -190,7 +190,7 @@ hpux_thread_resume (struct target_ops *o 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 (); Index: src/gdb/inf-ptrace.c =================================================================== --- src.orig/gdb/inf-ptrace.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/inf-ptrace.c 2009-05-21 16:22:13.000000000 +0100 @@ -396,7 +396,7 @@ inf_ptrace_resume (struct target_ops *op 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; Index: src/gdb/inf-ttrace.c =================================================================== --- src.orig/gdb/inf-ttrace.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/inf-ttrace.c 2009-05-21 16:22:13.000000000 +0100 @@ -924,7 +924,7 @@ inf_ttrace_resume (struct target_ops *op 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); Index: src/gdb/linux-thread-db.c =================================================================== --- src.orig/gdb/linux-thread-db.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/linux-thread-db.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; Index: src/gdb/monitor.c =================================================================== --- src.orig/gdb/monitor.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/monitor.c 2009-05-21 16:22:13.000000000 +0100 @@ -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]; Index: src/gdb/nto-procfs.c =================================================================== --- src.orig/gdb/nto-procfs.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/nto-procfs.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; Index: src/gdb/record.c =================================================================== --- src.orig/gdb/record.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/record.c 2009-05-21 16:22:13.000000000 +0100 @@ -98,7 +98,8 @@ static void (*record_beneath_to_resume) 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) Index: src/gdb/remote-mips.c =================================================================== --- src.orig/gdb/remote-mips.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/remote-mips.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; Index: src/gdb/remote-sim.c =================================================================== --- src.orig/gdb/remote-sim.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/remote-sim.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; Index: src/gdb/rs6000-nat.c =================================================================== --- src.orig/gdb/rs6000-nat.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/rs6000-nat.c 2009-05-21 16:22:13.000000000 +0100 @@ -521,7 +521,7 @@ rs6000_xfer_partial (struct target_ops * 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; Index: src/gdb/sol-thread.c =================================================================== --- src.orig/gdb/sol-thread.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/sol-thread.c 2009-05-21 16:22:13.000000000 +0100 @@ -381,7 +381,7 @@ sol_thread_resume (struct target_ops *op 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) { Index: src/gdb/spu-linux-nat.c =================================================================== --- src.orig/gdb/spu-linux-nat.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/spu-linux-nat.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; Index: src/gdb/top.c =================================================================== --- src.orig/gdb/top.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/top.c 2009-05-21 16:22:13.000000000 +0100 @@ -266,7 +266,8 @@ void (*deprecated_memory_changed_hook) ( 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... */ Index: src/gdb/tui/tui-hooks.c =================================================================== --- src.orig/gdb/tui/tui-hooks.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/tui/tui-hooks.c 2009-05-21 16:22:13.000000000 +0100 @@ -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) { Index: src/gdb/windows-nat.c =================================================================== --- src.orig/gdb/windows-nat.c 2009-05-21 15:58:13.000000000 +0100 +++ src/gdb/windows-nat.c 2009-05-21 16:22:13.000000000 +0100 @@ -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; ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-05-21 15:54 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-05-20 18:32 [patch] Fix recent gdb.mi testsuite "unknown output after running" Jan Kratochvil 2009-05-21 2:16 ` Pedro Alves 2009-05-21 13:46 ` Pedro Alves 2009-05-21 15:54 ` [commit] New target_wait `options' argument, and new TARGET_WNOHANG option. (was: Re: [patch] Fix recent gdb.mi testsuite "unknown output after running") Pedro Alves
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox