From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14008 invoked by alias); 24 Jun 2013 20:20:27 -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 13985 invoked by uid 89); 24 Jun 2013 20:20:23 -0000 X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 24 Jun 2013 20:20:22 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5OKKJjm001435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Jun 2013 16:20:19 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5OKKAeh032276; Mon, 24 Jun 2013 16:20:11 -0400 Message-ID: <51C8A9FA.1050001@redhat.com> Date: Mon, 24 Jun 2013 22:06:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: Hui Zhu CC: Hui Zhu , Tom Tromey , gdb-patches@sourceware.org, Keith Seitz , Yao Qi Subject: Re: [RFC] PR 15075 dprintf interferes with "next" References: <1361192891-29341-1-git-send-email-yao@codesourcery.com> <8738wpd3qe.fsf@fleche.redhat.com> <5176C14B.6010603@redhat.com> <51774714.9060306@codesourcery.com> <51969A92.80003@redhat.com> <519CBE2B.7060007@redhat.com> <51ACD6ED.7040604@redhat.com> <51C0A274.9010808@redhat.com> <51C7CA0C.5020809@mentor.com> In-Reply-To: <51C7CA0C.5020809@mentor.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-06/txt/msg00677.txt.bz2 On 06/24/2013 05:24 AM, Hui Zhu wrote: >> Hmm, this still looks racy to me, even on native targets. >> "continue &" produces a gdb prompt. gdb_test_multiple >> inside has a match for the prompt: >> >> -re "\r\n$gdb_prompt $" { >> if ![string match "" $message] then { >> fail "$message" >> } >> set result 1 >> } >> >> So if the expect happens to read >> >> continue & >> (gdb) >> >> from the buffer, we'll hit the fail. Doesn't the read1 hack catch this? > > EXPECT=../contrib/expect-read1.sh make check RUNTESTFLAGS="dprintf-non-stop.exp" is OK in my part. I suspect the "exec sleep 1" is masking it. If you remove the sleep, then the test fails. > >> >> We need to consume the prompt after that "continue&". >> >>> + } >>> +} >>> + >>> +set test "inferior stopped" >>> +gdb_test_multiple "" $test { >>> + -re "\r\n\\\[.* \[0-9\]+\\\] #1 stopped\\\.\r\n" { >>> + pass $test >>> + } >>> +} >> >> Likewise? >> > > I just copy this part of code from "gdb.base/async-shell.exp". > Could you give me some help about how to consume the prompt after that "continue&"? Just doing: -send_gdb "continue &\n" +gdb_test "continue &" "Continuing\\." will consume the prompt. Otherwise, we'd do like e.g., completion.exp does: # Eat the prompt gdb_expect { -re "$gdb_prompt " { pass "$test (eat prompt)" } timeout { fail "(timeout) $test (eat prompt)" } } We still need the sleep, but for different a reason -- be sure to wait for the dprintf to trigger -- we need GDB to print the prompt before the program reaches the dprintf. I think it's slightly better to do the sleep on the inferior program side. We can expect the "At foo entry" output from the dprintf, as the default "set dprintf-style" is "gdb". I see now that the set test "inferior stopped" gdb_test_multiple "" $test { -re "\r\n\\\[.* \[0-9\]+\\\] #1 stopped\\\.\r\n" { pass $test } } case doesn't need to eat the prompt, as that output appears after the prompt: (gdb) PASS: gdb.base/dprintf-non-stop.exp: continue & At foo entry PASS: gdb.base/dprintf-non-stop.exp: dprintf triggered interrupt (gdb) [process 6106] #1 stopped. PASS: gdb.base/dprintf-non-stop.exp: interrupt PASS: gdb.base/dprintf-non-stop.exp: inferior stopped and the "interrupt" test already eats it. See patchlet on top of yours below. Please merge it with yours, and push the result in (and post it, for the archives). Thanks, Pedro Alves --- gdb/testsuite/gdb.base/dprintf-non-stop.c | 1 + gdb/testsuite/gdb.base/dprintf-non-stop.exp | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/dprintf-non-stop.c b/gdb/testsuite/gdb.base/dprintf-non-stop.c index 2198848..2d25d9e 100644 --- a/gdb/testsuite/gdb.base/dprintf-non-stop.c +++ b/gdb/testsuite/gdb.base/dprintf-non-stop.c @@ -23,6 +23,7 @@ foo () int main () { + sleep (1); foo (); sleep (3); return 0; diff --git a/gdb/testsuite/gdb.base/dprintf-non-stop.exp b/gdb/testsuite/gdb.base/dprintf-non-stop.exp index c3fb85e..707f913 100644 --- a/gdb/testsuite/gdb.base/dprintf-non-stop.exp +++ b/gdb/testsuite/gdb.base/dprintf-non-stop.exp @@ -36,9 +36,22 @@ if ![runto main] { gdb_test "dprintf foo,\"At foo entry\\n\"" "Dprintf .*" -send_gdb "continue &\n" -exec sleep 1 +gdb_test "continue &" "Continuing\\." +# Wait for the dprintf to trigger. +set test "dprintf triggered" +gdb_expect { + -re "At foo entry" { + pass "$test" + } + timeout { + fail "$test (timeout)" + } +} + +# Now test that we're still able to issue commands. GDB used to +# implement re-resuming from dprintfs with a synchronous "continue" in +# the dprintf's command list, which stole the prompt from the user. set test "interrupt" gdb_test_multiple $test $test { -re "interrupt\r\n$gdb_prompt " { -- 1.7.11.7