From: Pedro Alves <palves@redhat.com>
To: Hui Zhu <hui_zhu@mentor.com>
Cc: Hui Zhu <teawater@gmail.com>, Tom Tromey <tromey@redhat.com>,
gdb-patches@sourceware.org,
Keith Seitz <keiths@redhat.com>,
Yao Qi <yao@codesourcery.com>
Subject: Re: [RFC] PR 15075 dprintf interferes with "next"
Date: Mon, 24 Jun 2013 22:06:00 -0000 [thread overview]
Message-ID: <51C8A9FA.1050001@redhat.com> (raw)
In-Reply-To: <51C7CA0C.5020809@mentor.com>
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
next prev parent reply other threads:[~2013-06-24 20:20 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-18 13:09 Yao Qi
2013-02-18 21:36 ` Joel Brobecker
2013-02-21 16:36 ` Tom Tromey
2013-04-24 1:24 ` Hui Zhu
2013-04-24 6:06 ` Keith Seitz
2013-04-24 13:30 ` Hui Zhu
2013-04-24 14:03 ` Yao Qi
2013-04-24 14:09 ` Hui Zhu
2013-05-16 7:29 ` Hui Zhu
2013-05-17 21:01 ` Pedro Alves
2013-05-22 10:22 ` Hui Zhu
2013-05-22 12:46 ` Pedro Alves
2013-05-28 0:02 ` Hui Zhu
2013-05-28 3:36 ` Yao Qi
2013-05-29 10:08 ` Hui Zhu
2013-06-03 4:07 ` Hui Zhu
2013-06-03 17:48 ` Pedro Alves
2013-06-07 3:16 ` Hui Zhu
2013-06-17 7:36 ` Hui Zhu
2013-06-18 18:16 ` Pedro Alves
2013-06-24 8:36 ` Hui Zhu
2013-06-24 22:06 ` Pedro Alves [this message]
2013-06-25 9:14 ` Hui Zhu
2013-06-25 11:47 ` Pedro Alves
2013-06-25 13:02 ` Hui Zhu
2013-06-25 14:06 ` Pedro Alves
2013-06-26 2:54 ` Hui Zhu
2013-05-22 14:04 ` Tom Tromey
2013-02-22 17:39 ` DPrintf feedback (was: [RFC] PR 15075 dprintf interferes with "next") Marc Khouzam
2013-02-22 19:32 ` DPrintf feedback Tom Tromey
2013-02-22 20:37 ` Marc Khouzam
2013-02-26 21:12 ` Marc Khouzam
2013-02-28 15:32 ` [PATCH 1/4] Fix dprintf bugs Yao Qi
2013-02-28 13:17 ` [PATCH 3/4] Test dprintf breakpoint works correctly with other breakpoints Yao Qi
2013-02-28 13:17 ` [PATCH 2/4] Test case of conditional dprintf Yao Qi
2013-02-28 14:48 ` [PATCH 4/4] Test case on setting dprintf commands Yao Qi
2013-02-28 16:30 ` [PATCH 1/4] Fix dprintf bugs Eli Zaretskii
2013-03-07 7:45 ` Yao Qi
2013-03-03 2:21 ` Marc Khouzam
2013-03-07 6:47 ` Yao Qi
2013-03-07 14:06 ` Marc Khouzam
2013-03-07 14:36 ` Yao Qi
2013-03-07 14:49 ` Marc Khouzam
2013-03-07 14:59 ` Yao Qi
2013-03-08 15:49 ` Marc Khouzam
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=51C8A9FA.1050001@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=hui_zhu@mentor.com \
--cc=keiths@redhat.com \
--cc=teawater@gmail.com \
--cc=tromey@redhat.com \
--cc=yao@codesourcery.com \
/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