From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24167 invoked by alias); 4 Mar 2014 18:33:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 24030 invoked by uid 89); 4 Mar 2014 18:33:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Mar 2014 18:33:03 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s24IX1ea011866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Mar 2014 13:33:01 -0500 Received: from barimba.redhat.com (ovpn-113-183.phx2.redhat.com [10.3.113.183]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s24IWtjY012049; Tue, 4 Mar 2014 13:33:00 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC v5 5/8] make dprintf.exp pass in always-async mode Date: Tue, 04 Mar 2014 18:33:00 -0000 Message-Id: <1393957974-4521-6-git-send-email-tromey@redhat.com> In-Reply-To: <1393957974-4521-1-git-send-email-tromey@redhat.com> References: <1393957974-4521-1-git-send-email-tromey@redhat.com> X-SW-Source: 2014-03/txt/msg00085.txt.bz2 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 PR cli/15718: * infcall.c: Include event-top.h. (run_inferior_call): Call async_disable_stdin if needed. 2014-03-04 Tom Tromey * 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 . */ + +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 . + + +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