This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC v5 5/8] make dprintf.exp pass in always-async mode


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.

This patch also adds a new test case, so that regression testing isn't
dependent on the implementation of dprintf.

2013-10-30  Tom Tromey  <tromey@redhat.com>

	PR cli/15718:
	* infcall.c: Include event-top.h.
	(run_inferior_call): Call async_disable_stdin if needed.

2014-03-04  Tom Tromey  <tromey@redhat.com>

	* gdb.base/async-cond.c: New file.
	* gdb.base/async-cond.exp: New file.
---
 gdb/ChangeLog                         |  6 ++++++
 gdb/infcall.c                         | 10 ++++++++++
 gdb/testsuite/ChangeLog               |  5 +++++
 gdb/testsuite/gdb.base/async-cond.c   | 32 ++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/async-cond.exp | 25 +++++++++++++++++++++++++
 5 files changed, 78 insertions(+)
 create mode 100644 gdb/testsuite/gdb.base/async-cond.c
 create mode 100644 gdb/testsuite/gdb.base/async-cond.exp

diff --git a/gdb/infcall.c b/gdb/infcall.c
index ad18ff1..c917f92 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,13 @@ 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.  In other
+	     cases, stdin will be re-enabled by
+	     inferior_event_handler, when an exception is thrown.  */
+	  if (was_sync)
+	    async_disable_stdin ();
 	}
     }
 
diff --git a/gdb/testsuite/gdb.base/async-cond.c b/gdb/testsuite/gdb.base/async-cond.c
new file mode 100644
index 0000000..469fcc2
--- /dev/null
+++ b/gdb/testsuite/gdb.base/async-cond.c
@@ -0,0 +1,32 @@
+/* Copyright 2014 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+zero (void)
+{
+  return 0;
+}
+
+int
+g (void)
+{
+  return 23;
+}
+
+int
+main (void)
+{
+  g();
+}
diff --git a/gdb/testsuite/gdb.base/async-cond.exp b/gdb/testsuite/gdb.base/async-cond.exp
new file mode 100644
index 0000000..8d857eb
--- /dev/null
+++ b/gdb/testsuite/gdb.base/async-cond.exp
@@ -0,0 +1,25 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    return -1
+}
+
+gdb_test_no_output "set target-async on"
+gdb_test "break g if zero()" "Breakpoint .*"
+gdb_test "run" "Inferior.*exited.*"
-- 
1.8.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]