From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23909 invoked by alias); 20 Jan 2007 20:34:01 -0000 Received: (qmail 23901 invoked by uid 22791); 20 Jan 2007 20:34:00 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sat, 20 Jan 2007 20:33:55 +0000 Received: from drow by nevyn.them.org with local (Exim 4.63) (envelope-from ) id 1H8MuP-0007E1-0s; Sat, 20 Jan 2007 15:33:53 -0500 Date: Sat, 20 Jan 2007 20:34:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Allow use of breakpoint commands inside `if' or `while' Message-ID: <20070120203352.GD25573@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , gdb-patches@sources.redhat.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes 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 X-SW-Source: 2007-01/txt/msg00426.txt.bz2 On Sat, Jan 13, 2007 at 07:21:19PM +0200, Eli Zaretskii wrote: > > Date: Sat, 13 Jan 2007 19:11:41 +0200 > > From: Eli Zaretskii > > > > (I will post an initial attempt to add a test for this in a moment.) > > Here it is. It is admittedly inelegant; in particular, the > diagnostics for a GDB that fails the test is not very smart, and one > of the two tests isn't counted in the sum of failed tests, although it > does fail. Hopefully, someone more fluent with Expect will be able to > improve on the test (I think Daniel offered help back when I first > reported this). I did indeed. How does this look? -- Daniel Jacobowitz CodeSourcery 2007-01-20 Daniel Jacobowitz * gdb.base/commands.exp: Call if_commands_test. (gdb_test_no_prompt, if_commands_test): New. Index: testsuite/gdb.base/commands.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/commands.exp,v retrieving revision 1.18 diff -u -p -r1.18 commands.exp --- testsuite/gdb.base/commands.exp 9 Jan 2007 17:59:09 -0000 1.18 +++ testsuite/gdb.base/commands.exp 20 Jan 2007 20:32:44 -0000 @@ -618,6 +618,79 @@ end} file delete file3 } +proc gdb_test_no_prompt { command result msg } { + global gdb_prompt + + set msg "$command - $msg" + set result "^[string_to_regexp $command]\r\n$result$" + gdb_test_multiple $command $msg { + -re "$result" { + pass $msg + return 1 + } + -re "\r\n *>$" { + fail $msg + return 0 + } + } + return 0 +} + +proc if_commands_test {} { + global gdb_prompt + + gdb_test "set \$tem = 1" "" "set \$tem in if_commands_test" + + set test "if_commands_test 1" + gdb_test_no_prompt "if \$tem == 2" { >} $test + gdb_test_no_prompt "break main" { >} $test + gdb_test_no_prompt "else" { >} $test + gdb_test_no_prompt "break factorial" { >} $test + gdb_test_no_prompt "commands" { >} $test + gdb_test_no_prompt "silent" { >} $test + gdb_test_no_prompt "set \$tem = 3" { >} $test + gdb_test_no_prompt "continue" { >} $test + gdb_test_multiple "end" "first end - $test" { + -re " >\$" { + pass "first end - $test" + } + -re "\r\n>\$" { + fail "first end - $test" + } + } + gdb_test_multiple "end" "second end - $test" { + -re "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\.\r\n$gdb_prompt $" { + pass "second end - $test" + } + -re "Undefined command: \"silent\".*$gdb_prompt $" { + fail "second end - $test" + } + } + + set test "if_commands_test 2" + gdb_test_no_prompt "if \$tem == 1" { >} $test + gdb_test_no_prompt "break main" { >} $test + gdb_test_no_prompt "else" { >} $test + gdb_test_no_prompt "break factorial" { >} $test + gdb_test_no_prompt "commands" { >} $test + gdb_test_no_prompt "silent" { >} $test + gdb_test_no_prompt "set \$tem = 3" { >} $test + gdb_test_no_prompt "continue" { >} $test + gdb_test_multiple "end" "first end - $test" { + -re " >\$" { + pass "first end - $test" + } + -re "\r\n>\$" { + fail "first end - $test" + } + } + gdb_test_multiple "end" "second end - $test" { + -re "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\.\r\n$gdb_prompt $" { + pass "second end - $test" + } + } +} + gdbvar_simple_if_test gdbvar_simple_while_test gdbvar_complex_if_while_test @@ -635,3 +708,4 @@ bp_deleted_in_command_test temporary_breakpoint_commands stray_arg0_test recursive_source_test +if_commands_test