[PATCH v2 7/9] make dprintf.exp pass in always-async mode

Tom Tromey
2013-07-31T18:28:19Z

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
mode.

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 ();
}
}

--
1.8.1.4