From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10530 invoked by alias); 19 Aug 2005 22:27:31 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10507 invoked by uid 22791); 19 Aug 2005 22:27:23 -0000 Received: from centrmmtao01vip.cox.net (HELO centrmmtao01.cox.net) (68.1.16.139) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 19 Aug 2005 22:27:23 +0000 Received: from white ([68.9.64.121]) by centrmmtao01.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050819222721.IAOM23608.centrmmtao01.cox.net@white>; Fri, 19 Aug 2005 18:27:21 -0400 Received: from bob by white with local (Exim 3.36 #1 (Debian)) id 1E6FKb-0005DK-00; Fri, 19 Aug 2005 18:27:21 -0400 Date: Sat, 20 Aug 2005 09:07:00 -0000 From: Bob Rossi To: Mark Kettenis Cc: gdb-patches@sources.redhat.com Subject: Re: MI testsuite to use PTY for inferior Message-ID: <20050819222721.GA20029@white> Mail-Followup-To: Mark Kettenis , gdb-patches@sources.redhat.com References: <20050727031758.GA15798@white> <200508132151.j7DLpnoR015475@elgar.sibelius.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200508132151.j7DLpnoR015475@elgar.sibelius.xs4all.nl> User-Agent: Mutt/1.5.9i X-SW-Source: 2005-08/txt/msg00212.txt.bz2 > Funny thing is that if I run mi-console.exp alone, it usually > (although not always) succeeds. > > Attached are a gdb.log for a failing run and a passing run. OK, I've tracked down why mi-console.exp breaks. Also, I can reproduce it. The problem is slightly difficult to fix because of race conditions so I was hoping to get some advice from people who might have had similar experience with the testsuite. For MI, the mi_gdb_test function is used to test the output of a command. Only problem is, in mi_gdb_test there is this, gdb_expect $tmt { ... -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" { if ![string match "" $message] then { pass "$message" } set result 0 } ... -re ".*$mi_gdb_prompt\[ \]*$" { if ![string match "" $message] then { fail "$message" } set result 1 } ... } So, if the pattern the user passes in matches the regex, then a pass will get put out. However, if the pattern does not match, and a mi_gdb_prompt is reached, then a fail will be issued. Only difference is, the second case does not have to wait the full $tmt (which is 60 in this case) seconds to complete the match. So, the first problem is that $pattern can not consist of more than a single gdb prompt output. In MI this means, you send, 47-exec-next and get back 47^running^M (gdb) ^M 47*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x080483e8",func="main",args=[],file (gdb) ^M You can not expect to get back both of those in a single mi_gdb_test command list so, mi_gdb_test "47-exec-next" \ "47\\^running\[\r\n\]+${mi_gdb_prompt}47\\*stopped.*}" \ "Testing console output" \ "Hello \\\\\"!\[\r\n\]+" With that in mind, the next obvious solution, which is the one used, is to do what is currently in mi-console.exp, mi_gdb_test "47-exec-next" \ "47\\^running" \ "Testing console output" \ "Hello \\\\\"!\[\r\n\]+" gdb_expect { -re "47\\*stopped.*$mi_gdb_prompt$" { pass "Finished step over hello" } timeout { fail "Finished step over hello (timeout)" } } This splits up the regex matching into 2 commands, which makes sense. The problem is, in mi_gdb_test when it goes to match 47\\^running, it is possible that either just that has been outputted by GDB (Yay, match!), or that also the 47\\*stopped... output has also been output by GDB. In this case, the testcase fails because the regex in mi_gdb_test does not match the 'end anchor' of the output from GDB. Thus the race condition. I'm still thinking of ways to fix this without totally hacking the testsuite, any ideas? To reproduce this problem, put 'sleep 1' just before the gdb_expect line in mi-support.exp:mi_gdb_test. That gives GDB enough time to output both items that need to be matched. Thanks, Bob Rossi