From patchwork Tue Mar 25 12:30:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 270 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (caibbdcaaahc.dreamhost.com [208.113.200.72]) by wilcox.dreamhost.com (Postfix) with ESMTP id 443CA36014C for ; Tue, 25 Mar 2014 06:09:31 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id DD315419131C5; Tue, 25 Mar 2014 06:09:30 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id B8375419131C8 for ; Tue, 25 Mar 2014 06:09:30 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=L/vZnoxr4XopbTEBu7Xo2cQP6hRndueMZxRFve/dIuUkNJiiPXmnP TxfcxMAcWviFDN2lij4Yl8B42VJ7FAb0rc19RzaRns9ZGm7NPkwy2ZSd/I/WEP7J 2ucWP/i8bD5TVZ0hsLSo829DrDrb/58D/fDwF7qgW+Cywn2Jye/x1Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=ZZQGoRpknY3y8EgQDSC4iw4BG5M=; b=CCTdRAI2pvlonM+DFfkH3SlBUSZ0 wsKH2IDITEo+bh2LWrLQc4lsHH2D9SW/FXU34EOnaav795hhrrid477TXb0kmHqq nnNszEYtgX+W3yMtfGUtIX4+C2bYk+cqVXiAxrrxEAvbqk3KrPNSjG1PzC7AkWcF 2tJCxzdwzVwuH78= Received: (qmail 13679 invoked by alias); 25 Mar 2014 13:09:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 13653 invoked by uid 89); 25 Mar 2014 13:09:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 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, 25 Mar 2014 13:09:23 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2PD6us9028888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Mar 2014 09:09:20 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2PCUNqN002640 for ; Tue, 25 Mar 2014 08:30:24 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PUSHED] "source", foreground execution commands, and target-async Date: Tue, 25 Mar 2014 12:30:23 +0000 Message-Id: <1395750623-8054-1-git-send-email-palves@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in Sourcing a GDB script that runs foreground execution commands in succession fails if the target can async: Breakpoint 1, main () at ../../../src/gdb/testsuite/gdb.base/source-execution.c:36 36 func1 (); (gdb) source ../../../src/gdb/testsuite/gdb.base/source-execution.gdb ../../../src/gdb/testsuite/gdb.base/source-execution.gdb:21: Error in sourced command file: Cannot execute this command while the selected thread is running. (gdb) FAIL: gdb.base/source-execution.exp: source source-execution.gdb That is, after a foreground execution command, GDB moves on to the following command immediately before waiting for the previous command to complete. https://sourceware.org/ml/gdb-patches/2011-09/msg00037.html (b4a14fd0) addressed this for command lists, Python's gdb.execute, etc., but missed "source". Fixed now in the same way. gdb/ 2014-03-25 Pedro Alves * cli/cli-script.c (script_from_file): Force the interpreter to sync mode. gdb/testsuite/ 2014-03-25 Pedro Alves Doug Evans * gdb.base/source-execution.c: New file. * gdb.base/source-execution.exp: New file. * gdb.base/source-execution.gdb: New file. --- gdb/ChangeLog | 5 ++++ gdb/cli/cli-script.c | 3 +++ gdb/testsuite/ChangeLog | 7 +++++ gdb/testsuite/gdb.base/source-execution.c | 41 +++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/source-execution.exp | 33 +++++++++++++++++++++++ gdb/testsuite/gdb.base/source-execution.gdb | 21 +++++++++++++++ 6 files changed, 110 insertions(+) create mode 100644 gdb/testsuite/gdb.base/source-execution.c create mode 100644 gdb/testsuite/gdb.base/source-execution.exp create mode 100644 gdb/testsuite/gdb.base/source-execution.gdb diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c1231ca..74e20a4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-03-25 Pedro Alves + + * cli/cli-script.c (script_from_file): Force the interpreter to + sync mode. + 2014-03-24 Pierre Langlois * avr-tdep.c (avr_scan_prologue): Accept push r1 instruction for diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 246fcc9..7dc1ba4 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1667,6 +1667,9 @@ script_from_file (FILE *stream, const char *file) source_line_number = 0; source_file_name = file; + make_cleanup_restore_integer (&interpreter_async); + interpreter_async = 0; + { volatile struct gdb_exception e; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ba0471a..b7bc990 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-03-25 Pedro Alves + Doug Evans + + * gdb.base/source-execution.c: New file. + * gdb.base/source-execution.exp: New file. + * gdb.base/source-execution.gdb: New file. + 2014-03-24 Doug Evans * gdb.linespec/macro-relative.exp: Mark the test as unsupported if diff --git a/gdb/testsuite/gdb.base/source-execution.c b/gdb/testsuite/gdb.base/source-execution.c new file mode 100644 index 0000000..e7de119 --- /dev/null +++ b/gdb/testsuite/gdb.base/source-execution.c @@ -0,0 +1,41 @@ +/* This testcase is part of GDB, the GNU debugger. + + 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 . */ + +static void +func1 (void) +{ +} + +static void +func2 (void) +{ +} + +static void +func3 (void) +{ +} + +int +main (void) +{ + func1 (); + func2 (); + func3 (); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/source-execution.exp b/gdb/testsuite/gdb.base/source-execution.exp new file mode 100644 index 0000000..0b0e8ef --- /dev/null +++ b/gdb/testsuite/gdb.base/source-execution.exp @@ -0,0 +1,33 @@ +# This testcase is part of GDB, the GNU debugger. + +# 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 . + +# Test sourcing a script that runs execution commands. + +standard_testfile + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { + return -1 +} + +if ![runto_main] then { + fail "Can't run to main" + return 0 +} + +gdb_test "source ${srcdir}/${subdir}/source-execution.gdb" \ + "func2.*func3.*" \ + "source source-execution.gdb" diff --git a/gdb/testsuite/gdb.base/source-execution.gdb b/gdb/testsuite/gdb.base/source-execution.gdb new file mode 100644 index 0000000..6a08f56 --- /dev/null +++ b/gdb/testsuite/gdb.base/source-execution.gdb @@ -0,0 +1,21 @@ +# This testcase is part of GDB, the GNU debugger. +# +# 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 . + +# A couple synchronous execution commands in succession, to make sure +# GDB waits for the first to complete before moving to the second. +next +next