From patchwork Fri May 24 11:39:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 32846 Received: (qmail 52976 invoked by alias); 24 May 2019 11:39:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 52958 invoked by uid 89); 24 May 2019 11:39:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 May 2019 11:39:10 +0000 Received: by mail-wm1-f65.google.com with SMTP id f204so9049136wme.0 for ; Fri, 24 May 2019 04:39:09 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4eeb:42ff:feef:f164? ([2001:8a0:f913:f700:4eeb:42ff:feef:f164]) by smtp.gmail.com with ESMTPSA id b10sm3546692wrh.59.2019.05.24.04.39.07 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 04:39:07 -0700 (PDT) Subject: Re: [PATCH 06/24] Fix "set enum-command value garbage" To: Sergio Durigan Junior References: <20190522205327.2568-1-palves@redhat.com> <20190522205327.2568-7-palves@redhat.com> <8736l5ougm.fsf@redhat.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Fri, 24 May 2019 12:39:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <8736l5ougm.fsf@redhat.com> On 5/23/19 8:13 PM, Sergio Durigan Junior wrote: > On Wednesday, May 22 2019, Pedro Alves wrote: > >> With enum commands, we currently fail to notice garbage after the >> value. >> >> Currently: >> >> (gdb) set print entry-values compact foo >> (gdb) show print entry-values foo >> Printing of function arguments at function entry is "compact". >> >> After this fix: >> >> (gdb) set print entry-values compact foo >> Garbage after item: "foo" > > I think it would be clearer to specify which item here, otherwise the > user might think that the item is "foo". Maybe: > > Invalid data after item "compact": "foo" > > What do you think? Otherwise, LGTM. Thanks. Agreed. I'm changing the code like this: diff --git c/gdb/cli/cli-setshow.c w/gdb/cli/cli-setshow.c index 9d6479ffca2..47e50941e3b 100644 --- c/gdb/cli/cli-setshow.c +++ w/gdb/cli/cli-setshow.c @@ -413,9 +413,10 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) if (nmatches > 1) error (_("Ambiguous item \"%s\"."), arg); - arg = skip_spaces (arg + len); - if (*arg != '\0') - error (_("Garbage after item: \"%s\""), arg); + const char *after = skip_spaces (arg + len); + if (*after != '\0') + error (_("Garbage after item \"%.*s\": \"%s\""), + len, arg, after); Also changed the test like this, in patch #9: --- i/gdb/testsuite/gdb.base/settings.exp +++ w/gdb/testsuite/gdb.base/settings.exp @@ -378,7 +378,13 @@ proc_with_prefix test-enum {} { # Valid value followed by garbage. gdb_test "$set_cmd xxx 1" \ - "Garbage after item: \"1\"" + "Garbage after item \"xxx\": \"1\"" + # Valid value followed by garbage, with extra spaces. + gdb_test "$set_cmd xxx 1" \ + "Garbage after item \"xxx\": \"1\"" + # Abbreviated value followed by garbage. + gdb_test "$set_cmd xx 1" \ + "Garbage after item \"xx\": \"1\"" Thanks, Pedro Alves