Hi,
On 15 June 2010 18:19, Daniel Jacobowitz <dan@codesourcery.com> wrote:
This hunk unfortunately exhibits a common subtle pitfall :-(
You can use bare gdb_expect with a string that contains gdb_prompt not
at the end, or contains more than one gdb_prompt, although it's a bit
tricky. You can't do the same with gdb_test_multiple, because it has
patterns like ".*$gdb_prompt $" -> FAIL. If the output comes out
buffered in such a way that the prompt is written separately from the
post-prompt text, this will match before GDB is done printing output.
OK, I audited the testsuite for uses of gdb_prompt in the middle of
gdb_test_multiple patterns (well to be precise, I looked for such
usage in the first pattern of every gdb_test_multiple. I becomes
harder to grep for the following patterns). Here's the list of the
problematic places I've found, which include all the failures I've
seen:
testsuite/gdb.base/setshow.exp
58:gdb_test_multiple "set annotate 2" "set annotate 2" {
59- -re ".*\032\032pre-prompt.*$gdb_prompt .*\032\032prompt.*$" {
--
64:gdb_test_multiple "show annotate" "show annotate 2" {
65- -re ".*\032\032post-prompt.*Annotation_level is
2..*\032\032pre-prompt.*$gdb_prompt .*\032\032prompt.*$" {
--
71:gdb_test_multiple "info line 1" "annotation_level 2" {
72- -re ".*\032\032post-prompt.*Line 1 of .* is at address .* but
contains no code.*:1:0:beg:0x.*\032\032pre-prompt.*$gdb_prompt
.*\032\032prompt.*$" {
testsuite/gdb.mi/mi2-basics.exp
63: gdb_test_multiple "-gdb-version" "acceptance of MI operations" {
64- -re "GNU gdb .*\r\n$mi_gdb_prompt$" {
--
212: gdb_test_multiple "-environment-path" "-environment-path" {
213- -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" {
testsuite/gdb.mi/mi2-console.exp
51:gdb_test_multiple "220-exec-next" "Started step over hello" {
52- -re "220\\^running\r\n(\\*running,thread-id=\"all\"\r\n)?$mi_gdb_prompt"
{
testsuite/gdb.mi/mi2-return.exp
56: gdb_test_multiple "111-exec-return" "return from callee4 now" {
57- -re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\r\n$mi_gdb_prompt$"
{
testsuite/gdb.mi/mi2-var-display.exp
608:gdb_test_multiple "p/x \$fp" "print FP register" {
609- -re ".*($hex).*\\^done\r\n$mi_gdb_prompt$" {
testsuite/gdb.mi/mi-basics.exp
63: gdb_test_multiple "-gdb-version" "acceptance of MI operations" {
64- -re "GNU gdb .*\r\n$mi_gdb_prompt$" {
--
210: gdb_test_multiple "-environment-path" "-environment-path" {
211- -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" {
testsuite/gdb.mi/mi-nonstop-exit.exp
40:gdb_test_multiple "-gdb-show non-stop" "" {
41- -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$"
{
testsuite/gdb.mi/mi-nonstop.exp
50:gdb_test_multiple "-gdb-show non-stop" "" {
51- -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$"
{
--
96:gdb_test_multiple "-exec-interrupt --thread 1" "interrupted" {
97- -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
--
107:gdb_test_multiple "-exec-continue --all" "resume all" {
108- -re ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"\r\n$mi_gdb_prompt"
{
testsuite/gdb.mi/mi-nsintrall.exp
40:gdb_test_multiple "-gdb-show non-stop" "" {
41- -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$"
{
--
80:gdb_test_multiple "-exec-continue --all" "resume all, no breakpoint" {
81- -re ".*$running_re$mi_gdb_prompt" {
--
99:gdb_test_multiple "-exec-continue --all" "resume all after interrupting" {
100- -re ".*$running_re$mi_gdb_prompt" {
testsuite/gdb.mi/mi-nsmoribund.exp
40:gdb_test_multiple "-gdb-show non-stop" "" {
41- -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$"
{
--
101:gdb_test_multiple "-exec-continue --all" "resume all, thread
specific breakpoint" {
102- -re ".*$running_re$mi_gdb_prompt" {
testsuite/gdb.mi/mi-ns-stale-regcache.exp
54:gdb_test_multiple "-gdb-show non-stop" "" {
55- -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$"
{
testsuite/gdb.mi/mi-nsthrexec.exp
50:gdb_test_multiple "-gdb-show non-stop" "" {
51- -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$"
{
testsuite/gdb.mi/mi-return.exp
56: gdb_test_multiple "111-exec-return" "return from callee4 now" {
57- -re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\r\n$mi_gdb_prompt$"
{
testsuite/gdb.mi/mi-var-display.exp
609:gdb_test_multiple "p/x \$fp" "print FP register" {
610- -re ".*($hex).*\\^done\r\n$mi_gdb_prompt$" {
Note all the cases using mi_gdb_prompt. Even if the mi_gdb_prompt is
at the end of the pattern, as it expands to gdb_prompt followed by a
newline, it's as if we used gdb_prompt in the middle of the pattern.
I've definitely seen at least mi(2)-return.exp exhibit this random
failure.
Cheers,
Fred