From patchwork Tue Apr 21 18:08:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 6363 Received: (qmail 97128 invoked by alias); 21 Apr 2015 18:09:07 -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 96008 invoked by uid 89); 21 Apr 2015 18:08:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 21 Apr 2015 18:08:56 +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 t3LI8tnw017681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 21 Apr 2015 14:08:55 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3LI8WLA028722 for ; Tue, 21 Apr 2015 14:08:54 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 21/24] Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id Date: Tue, 21 Apr 2015 19:08:28 +0100 Message-Id: <1429639711-16459-22-git-send-email-palves@redhat.com> In-Reply-To: <1429639711-16459-1-git-send-email-palves@redhat.com> References: <1429639711-16459-1-git-send-email-palves@redhat.com> gdb/testsuite/ChangeLog: 2015-04-21 Pedro Alves * gdb.mi/mi-dprintf.exp (mi_expect_dprintf): New procedure, factore out from mi_continue_dprintf. For call-style dprintfs, expect dprintf output out of $inferior_spawn_id. (mi_continue_dprintf): Use mi_expect_dprintf. * gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. --- gdb/testsuite/gdb.mi/mi-dprintf.exp | 66 +++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp index ea198bd..c205724 100644 --- a/gdb/testsuite/gdb.mi/mi-dprintf.exp +++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp @@ -72,45 +72,47 @@ mi_gdb_test "[incr i]-break-info" \ mi_gdb_test "-break-insert $bp_location1" ".*" "mi insert breakpoint bp_location1" -proc mi_continue_dprintf {args} { - with_test_prefix $args { - global mi_gdb_prompt +# Helper for mi_continue_dprintf. + +proc mi_expect_dprintf {args where msg} { + global mi_gdb_prompt + global inferior_spawn_id gdb_spawn_id + + if { $args == "call" || $args == "fprintf" } { + set foobarbazqux "\"foobarbazqux\"" + set sid $inferior_spawn_id + } else { + set foobarbazqux "\\\\\"foobarbazqux\\\\\"" + set sid $gdb_spawn_id + } - if { $args == "call" || $args == "fprintf" } { - set foobarbazqux "\"foobarbazqux\"" - } else { - set foobarbazqux "\\\\\"foobarbazqux\\\\\"" + # Don't expect the prompt here to avoid a race with mi_expect_stop + # in case $inferior_spawn_id != $gdb_spawn_id. Otherwise, in that + # case, we could see the gdb prompt before the inferior output. + gdb_expect { + -i $sid + -re ".*$foobarbazqux $where" { + pass $msg } + eof { + fail "$msg (eof)" + } + timeout { + fail "$msg (timeout)" + } + } + mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "$msg stop" +} - mi_run_cmd +proc mi_continue_dprintf {args} { + with_test_prefix $args { set msg "mi 1st dprintf" - gdb_expect { - -re ".*$foobarbazqux At foo entry.*arg=1234, g=1234" { - pass $msg - } - -re ".*$mi_gdb_prompt$" { - fail $msg - } - timeout { - fail $msg - } - } - mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "$msg stop" + mi_run_cmd + mi_expect_dprintf $args "At foo entry.*arg=1234, g=1234" $msg set msg "mi 2nd dprintf" mi_send_resuming_command "exec-continue" "$msg continue" - gdb_expect { - -re ".*$foobarbazqux At foo entry.*arg=1235, g=2222" { - pass $msg - } - -re ".*$mi_gdb_prompt$" { - fail $msg - } - timeout { - fail $msg - } - } - mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "$msg 2nd stop" + mi_expect_dprintf $args "At foo entry.*arg=1235, g=2222" $msg } }