Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [RFC v5 5/8] make dprintf.exp pass in always-async mode
Date: Tue, 04 Mar 2014 18:33:00 -0000	[thread overview]
Message-ID: <1393957974-4521-6-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1393957974-4521-1-git-send-email-tromey@redhat.com>

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


  parent reply	other threads:[~2014-03-04 18:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04 18:33 [RFC v5 0/8] enable target-async by default Tom Tromey
2014-03-04 18:33 ` [RFC v5 7/8] separate MI and target notions of async Tom Tromey
2014-03-04 18:40   ` Eli Zaretskii
2014-03-04 19:11     ` Tom Tromey
2014-05-23 20:45   ` Pedro Alves
2014-03-04 18:33 ` Tom Tromey [this message]
2014-03-20 18:04   ` [RFC v5 5/8] make dprintf.exp pass in always-async mode Pedro Alves
2014-03-04 18:33 ` [RFC v5 1/8] fix latent bugs in ui-out.c Tom Tromey
2014-03-17 19:16   ` Pedro Alves
2014-03-04 18:33 ` [RFC v5 2/8] PR gdb/13860: make -interpreter-exec console "list" behave more like "list" Tom Tromey
2014-03-18 16:04   ` [RFC v6] " Pedro Alves
2014-05-21 22:16     ` Pedro Alves
2014-03-04 18:33 ` [RFC v5 3/8] PR gdb/13860: make "-exec-foo"'s MI output equal to "foo"'s MI output Tom Tromey
2014-03-04 18:33 ` [RFC v5 8/8] enable target-async by default Tom Tromey
2014-03-04 18:33 ` [RFC v5 4/8] PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode Tom Tromey
2014-03-18 19:01   ` [RFC v6 " Pedro Alves
2014-05-21 22:37     ` Pedro Alves
2014-03-04 18:40 ` [RFC v5 6/8] fix py-finish-breakpoint.exp with always-async Tom Tromey
2014-03-20 18:28   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393957974-4521-6-git-send-email-tromey@redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox