From patchwork Thu May 30 19:53:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 32931 Received: (qmail 124715 invoked by alias); 30 May 2019 19:53:42 -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 124647 invoked by uid 89); 30 May 2019 19:53:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1117 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 May 2019 19:53:40 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4E33C0578FA for ; Thu, 30 May 2019 19:53:39 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 706105D9E1 for ; Thu, 30 May 2019 19:53:39 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 06/24] Fix "set enum-command value garbage" Date: Thu, 30 May 2019 20:53:15 +0100 Message-Id: <20190530195333.20448-7-palves@redhat.com> In-Reply-To: <20190530195333.20448-1-palves@redhat.com> References: <20190530195333.20448-1-palves@redhat.com> 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 "compact": "foo" gdb/ChangeLog: yyyy-mm-dd Pedro Alves * cli/cli-setshow.c (do_set_command) : Detect garbage after item. --- gdb/cli/cli-setshow.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 96d7bf5c3c0..47e50941e3b 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -413,6 +413,11 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) if (nmatches > 1) error (_("Ambiguous item \"%s\"."), arg); + const char *after = skip_spaces (arg + len); + if (*after != '\0') + error (_("Garbage after item \"%.*s\": \"%s\""), + len, arg, after); + if (*(const char **) c->var != match) { *(const char **) c->var = match;