This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH v4 7/9] make dprintf.exp pass in always-async mode
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 11 Nov 2013 16:29:52 +0000
- Subject: Re: [PATCH v4 7/9] make dprintf.exp pass in always-async mode
- Authentication-results: sourceware.org; auth=none
- References: <1382464769-2465-1-git-send-email-tromey at redhat dot com> <1382464769-2465-8-git-send-email-tromey at redhat dot com>
On 10/22/2013 06:59 PM, Tom Tromey wrote:
> When target-async is enabled, dprintf.exp fails.
> This happens because run_inferior_call causes gdb to forget that it is
> running in sync_execution mode, so something like a breakpoint
> condition that makes an inferior call causes gdb to enter fully async
It'd be great if we had a test that exercised this without
relying on how dprintf is implemented behind the scenes.
> This patch fixes the problem by noticing when gdb was in
> sync_execution mode in run_inferior_call, and taking care to restore
> this state afterward.
> Built and regtested on x86-64 Fedora 18.
> PR cli/15718:
> * infcall.c: Include event-top.h.
> (run_inferior_call): Call async_disable_stdin if needed.
> gdb/infcall.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
> diff --git a/gdb/infcall.c b/gdb/infcall.c
> index 19af044..7398913 100644
> --- a/gdb/infcall.c
> +++ b/gdb/infcall.c
> @@ -36,6 +36,7 @@
> #include "ada-lang.h"
> #include "gdbthread.h"
> #include "exceptions.h"
> +#include "event-top.h"
> /* If we can't find a function's name from its address,
> we print this instead. */
> @@ -398,6 +399,8 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc)
> TRY_CATCH (e, RETURN_MASK_ALL)
> + int was_sync = sync_execution;
> proceed (real_pc, GDB_SIGNAL_0, 0);
> /* Inferior function calls are always synchronous, even if the
> @@ -407,6 +410,11 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc)
> wait_for_inferior ();
> normal_stop ();
> + /* If gdb was previously in sync execution mode, then ensure
> + that it remains so. normal_stop calls
> + async_enable_stdin, so reset it again here. */
> + if (was_sync)
> + async_disable_stdin ();
Hmm, I was a worried about what would happen if the inferior
exits, or some other thread hits a breakpoint, or something
else like that. Like, what enables back stdin in that case?
So an error is always thrown, and we'll hit the INF_REG_EVENT error
handling inf-loop.c:inferior_event_handler, which re-enables back
stdin and the prompt. So the change is OK with me, but I'd
like to have this mentioned in the comment.