From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22422 invoked by alias); 10 Sep 2004 00:40:21 -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 22367 invoked from network); 10 Sep 2004 00:40:20 -0000 Received: from unknown (HELO mail-out4.apple.com) (17.254.13.23) by sourceware.org with SMTP; 10 Sep 2004 00:40:20 -0000 Received: from mailgate1.apple.com (a17-128-100-225.apple.com [17.128.100.225]) by mail-out4.apple.com (8.12.11/8.12.11) with ESMTP id i8A0ggYG025643 for ; Thu, 9 Sep 2004 17:42:42 -0700 (PDT) Received: from relay4.apple.com (relay4.apple.com) by mailgate1.apple.com (Content Technologies SMTPRS 4.3.14) with ESMTP id ; Thu, 9 Sep 2004 17:40:19 -0700 Received: from [17.201.22.21] (moleja.apple.com [17.201.22.21]) by relay4.apple.com (8.12.11/8.12.11) with ESMTP id i8A0eHTQ025272; Thu, 9 Sep 2004 17:40:18 -0700 (PDT) In-Reply-To: <414069F8.nailE691CTVHR@mindspring.com> References: <76449857-01CD-11D9-9838-000A9569836A@apple.com> <414069F8.nailE691CTVHR@mindspring.com> Mime-Version: 1.0 (Apple Message framework v672) Content-Type: multipart/mixed; boundary=Apple-Mail-1-505492830 Message-Id: Cc: gdb-patches@sources.redhat.com, cagney@gnu.org From: Jason Molenda Subject: Re: RFA: if/while commands in user-defined command behave differently Date: Fri, 10 Sep 2004 00:40:00 -0000 To: Michael Chastain X-SW-Source: 2004-09/txt/msg00156.txt.bz2 --Apple-Mail-1-505492830 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 1109 On Sep 9, 2004, at 7:34 AM, Michael Chastain wrote: > send_gdb / gdb_expect are old; can you can upgrade this to the modern > interface, gdb_test_multiple? With gdb_test_multiple you don't need > the default "$gdb_prompt $" and timeout clauses. > > The idea is good; it just needs gdb_test_multiple. Just do that and > re-test and re-submit. OK, I switched to gdb_test_multiple, thanks for the feedback. I haven't used gdb_test_multiple before, but I think this patch is correct. I haven't heard anything back on the CLI change. If the testsuite change is approved, should I commit that and file a PR to track the bug? :-) Jason [gdb/ChangeLog] 2004-09-08 Jason Molenda (jmolenda@apple.com) * cli/cli-script.c (read_next_line): Accept zero or more whitespace chars after 'if' or 'while' commands in user-defined commands. [gdb/testsuite/ChangeLog] 2004-09-09 Jason Molenda (jmolenda@apple.com) * gdb.base/define.exp: Two new tests to verify zero space chars after 'if' and 'while' commands in a user-defined command is correctly parsed. --Apple-Mail-1-505492830 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="pa2.txt" Content-Disposition: attachment; filename=pa2.txt Content-length: 3584 Index: cli/cli-script.c =================================================================== RCS file: /cvs/src/src/gdb/cli/cli-script.c,v retrieving revision 1.23 diff -u -p -r1.23 cli-script.c --- cli/cli-script.c 21 Apr 2004 23:52:21 -0000 1.23 +++ cli/cli-script.c 8 Sep 2004 19:19:53 -0000 @@ -1,7 +1,7 @@ /* GDB CLI command scripting. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, - 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -727,9 +727,21 @@ read_next_line (struct command_line **co /* Check for while, if, break, continue, etc and build a new command line structure for them. */ if (p1 - p > 5 && !strncmp (p, "while", 5)) - *command = build_command_line (while_control, p + 6); + { + char *first_arg; + first_arg = p + 5; + while (first_arg < p1 && isspace (*first_arg)) + first_arg++; + *command = build_command_line (while_control, first_arg); + } else if (p1 - p > 2 && !strncmp (p, "if", 2)) - *command = build_command_line (if_control, p + 3); + { + char *first_arg; + first_arg = p + 2; + while (first_arg < p1 && isspace (*first_arg)) + first_arg++; + *command = build_command_line (if_control, first_arg); + } else if (p1 - p == 10 && !strncmp (p, "loop_break", 10)) { *command = (struct command_line *) Index: define.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/define.exp,v retrieving revision 1.4 diff -u -p -r1.4 define.exp --- define.exp 9 Dec 2003 18:19:20 -0000 1.4 +++ define.exp 10 Sep 2004 00:36:36 -0000 @@ -1,4 +1,4 @@ -# Copyright 1998, 1999, 2001, 2003 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2001, 2003, 2004 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -200,6 +200,40 @@ gdb_expect { timeout {fail "(timeout) help user command: nextwhere"} } +# Verify that the command parser doesn't require a space after an 'if' +# command in a user defined function. +# +gdb_test_multiple "define ifnospace" "define user command: ifnospace" \ +{ + -re "Type commands for definition of \"ifnospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \ + { + gdb_test_multiple "if(3<4)\nprint \"hi there\\n\"\nend\nend" "send body of ifnospace" \ + { + -re "$gdb_prompt $"\ + {pass "define user command: ifspace"} + } + } +} + +gdb_test "ifnospace" ".*hi there.*" "test ifnospace is parsed correctly" + +# Verify that the command parser doesn't require a space after an 'while' +# command in a user defined function. +# +gdb_test_multiple "define whilenospace" "define user command: whilenospace" \ +{ + -re "Type commands for definition of \"whilenospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \ + { + gdb_test_multiple "set \$i=1\nwhile(\$i<2)\nset \$i=2\nprint \"hi there\\n\"\nend\nend" "send body of whilenospace" \ + { + -re "$gdb_prompt $" \ + {pass "define user command: whilenospace"} + } + } +} + +gdb_test "whilenospace" ".*hi there.*" "test whilenospace is parsed correctly" + # Verify that the user can "hook" a builtin command. We choose to # hook the "stop" pseudo command, and we'll define it to use a user- # define command. --Apple-Mail-1-505492830--