From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18248 invoked by alias); 8 Jun 2008 18:41:55 -0000 Received: (qmail 18240 invoked by uid 22791); 8 Jun 2008 18:41:54 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 08 Jun 2008 18:41:37 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m58IfZsD010764 for ; Sun, 8 Jun 2008 14:41:35 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m58IfZMq008960; Sun, 8 Jun 2008 14:41:35 -0400 Received: from opsy.redhat.com (vpn-10-25.bos.redhat.com [10.16.10.25]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m58IfTVj030330; Sun, 8 Jun 2008 14:41:34 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id D925E37814F; Sun, 8 Jun 2008 12:41:28 -0600 (MDT) To: gdb-patches@sources.redhat.com Subject: RFA: fix two field name completion bugs From: Tom Tromey Reply-To: Tom Tromey X-Attribution: Tom Date: Sun, 08 Jun 2008 18:41:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2008-06/txt/msg00143.txt.bz2 After committing the field name completion patch I found a couple bugs. One is a huge goof -- I must not have checked the '->' case, since it didn't work. How embarrassing. The other is that spaces in the expression could throw off the completer. The fix is to make sure that the entire expression is passed to expression_completer, then duplicate some logic there in the case where location_completer is called. I added test cases for both of these. Ok? Tom ChangeLog: 2008-06-08 Tom Tromey * completer.c (complete_line): Don't special-case expression_completer. (expression_completer): Only pass last word to location_completer. * c-exp.y (yylex): Check 'token', not 'operator'. testsuite/ChangeLog: 2008-06-08 Tom Tromey * gdb.base/completion.exp: New tests for field name completion with spaces, and field name completion with '->'. Index: c-exp.y =================================================================== RCS file: /cvs/src/src/gdb/c-exp.y,v retrieving revision 1.44 diff -u -r1.44 c-exp.y --- c-exp.y 6 Jun 2008 20:58:08 -0000 1.44 +++ c-exp.y 8 Jun 2008 18:38:48 -0000 @@ -1433,7 +1433,7 @@ { lexptr += 2; yylval.opcode = tokentab2[i].opcode; - if (in_parse_field && tokentab2[i].opcode == ARROW) + if (in_parse_field && tokentab2[i].token == ARROW) last_was_structop = 1; return tokentab2[i].token; } Index: completer.c =================================================================== RCS file: /cvs/src/src/gdb/completer.c,v retrieving revision 1.25 diff -u -r1.25 completer.c --- completer.c 6 Jun 2008 20:58:08 -0000 1.25 +++ completer.c 8 Jun 2008 18:38:48 -0000 @@ -387,7 +387,7 @@ expression_completer (char *text, char *word) { struct type *type; - char *fieldname; + char *fieldname, *p; /* Perform a tentative parse of the expression, to see whether a field completion is required. */ @@ -418,8 +418,15 @@ } } + /* Commands which complete on locations want to see the entire + argument. */ + for (p = word; + p > text && p[-1] != ' ' && p[-1] != '\t'; + p--) + ; + /* Not ideal but it is what we used to do before... */ - return location_completer (text, word); + return location_completer (p, word); } /* Complete on command names. Used by "help". */ @@ -604,8 +611,7 @@ rl_completer_word_break_characters = gdb_completer_file_name_break_characters; } - else if (c->completer == location_completer - || c->completer == expression_completer) + else if (c->completer == location_completer) { /* Commands which complete on locations want to see the entire argument. */ @@ -673,8 +679,7 @@ rl_completer_word_break_characters = gdb_completer_file_name_break_characters; } - else if (c->completer == location_completer - || c->completer == expression_completer) + else if (c->completer == location_completer) { for (p = word; p > tmp_command Index: testsuite/gdb.base/completion.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/completion.exp,v retrieving revision 1.30 diff -u -r1.30 completion.exp --- testsuite/gdb.base/completion.exp 6 Jun 2008 20:58:08 -0000 1.30 +++ testsuite/gdb.base/completion.exp 8 Jun 2008 18:38:50 -0000 @@ -654,6 +654,40 @@ timeout { fail "(timeout) complete 'p values\[0\].a' 2" } } +send_gdb "p values\[0\] . a\t" +sleep 3 +gdb_expect { + -re "^p values.0. . a_field $"\ + { send_gdb "\n" + sleep 1 + gdb_expect { + -re "^.* = 0.*$gdb_prompt $"\ + { pass "complete 'p values\[0\] . a'"} + -re ".*$gdb_prompt $" { fail "complete 'p values\[0\] . a'"} + timeout {fail "(timeout) complete 'p values\[0\] . a'"} + } + } + -re ".*$gdb_prompt $" { fail "complete 'p values\[0\] . a'" } + timeout { fail "(timeout) complete 'p values\[0\] . a' 2" } + } + +send_gdb "p &values\[0\] -> a\t" +sleep 3 +gdb_expect { + -re "^p &values.0. -> a_field $"\ + { send_gdb "\n" + sleep 1 + gdb_expect { + -re "^.* = .*0x\[0-9a-fA-F\]*.*$gdb_prompt $"\ + { pass "complete 'p &values\[0\] -> a'"} + -re ".*$gdb_prompt $" { fail "complete 'p &values\[0\] -> a'"} + timeout {fail "(timeout) complete 'p &values\[0\] -> a'"} + } + } + -re ".*$gdb_prompt $" { fail "complete 'p &values\[0\] -> a'" } + timeout { fail "(timeout) complete 'p &values\[0\] -> a' 2" } + } + # The following tests used to simply try to complete `${objdir}/file', # and so on. The problem is that ${objdir} can be very long; the # completed filename may be more than eighty characters wide. When