From patchwork Mon Mar 7 19:02:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 11242 Received: (qmail 80169 invoked by alias); 7 Mar 2016 19:02:49 -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 80153 invoked by uid 89); 7 Mar 2016 19:02:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=som, quoting, registration 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 07 Mar 2016 19:02:46 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 565138C56B for ; Mon, 7 Mar 2016 19:02:45 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u27J2ixE000525 for ; Mon, 7 Mar 2016 14:02:44 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Avoid spaces in osabi names Date: Mon, 7 Mar 2016 19:02:44 +0000 Message-Id: <1457377364-990-1-git-send-email-palves@redhat.com> It's not possible today to select some of the osabis by name. Specifically, those that have spaces in their names and then the first word is ambiguous... For example: (gdb) set osabi AIX Cygwin DICOS DJGPP Darwin FreeBSD ELF FreeBSD a.out GNU/Hurd GNU/Linux LynxOS178 NetBSD ELF NetBSD a.out Newlib OpenBSD ELF OpenVMS QNX Neutrino SDE SVR4 Solaris Symbian Windows CE auto default none (gdb) set osabi FreeBSD ELF Ambiguous item "FreeBSD ELF". In reality, because "set osabi" is an enum command, that was equivalent to trying "set osabi FreeBSD", which is then obviously ambiguous, because of "FreeBSD ELF" and "FreeBSD a.out". Also, even if the first word is not ambiguous, we actually ignore whatever comes after the first word: (gdb) set osabi GNU/Linux (gdb) show osabi The current OS ABI is "GNU/Linux". The default OS ABI is "GNU/Linux". (gdb) set osabi Windows SomeNonsense ^^^^^^^^^^^^ (gdb) show osabi The current OS ABI is "Windows CE". The default OS ABI is "GNU/Linux". (gdb) Fix this by avoiding spaces in osabi names. We could instead make "set osabi" have a custom set hook, or alternatively make the enum set hook (in cli-setshow.c) handle values with spaces, but OTOH, I have a feeling that could cause trouble. E.g., in cases where we might want to write more than one enum value in the same line. We could support quoting as workaround, but, do we want that? "No spaces" seems simpler. I'm thinking that if we take this route, we should probably make the enum command registration functions assert that no possible enum value contains spaces. I tried that, and other than the "set architecture" command, I found no other case. I sent a patch to binutils@ to try to fix that one. gdb/ChangeLog: 2016-03-07 Pedro Alves * osabi.c (gdb_osabi_names): Avoid spaces in osabi names. --- gdb/osabi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/osabi.c b/gdb/osabi.c index e8a77ab..f7d4e74 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -64,17 +64,17 @@ static const struct osabi_names gdb_osabi_names[] = { "GNU/Hurd", NULL }, { "Solaris", NULL }, { "GNU/Linux", "linux(-gnu)?" }, - { "FreeBSD a.out", NULL }, - { "FreeBSD ELF", NULL }, - { "NetBSD a.out", NULL }, - { "NetBSD ELF", NULL }, - { "OpenBSD ELF", NULL }, - { "Windows CE", NULL }, + { "FreeBSD/a.out", NULL }, + { "FreeBSD/ELF", NULL }, + { "NetBSD/a.out", NULL }, + { "NetBSD/ELF", NULL }, + { "OpenBSD/ELF", NULL }, + { "WindowsCE", NULL }, { "DJGPP", NULL }, { "Irix", NULL }, - { "HP/UX ELF", NULL }, - { "HP/UX SOM", NULL }, - { "QNX Neutrino", NULL }, + { "HP-UX/ELF", NULL }, + { "HP-UX/SOM", NULL }, + { "QNX-Neutrino", NULL }, { "Cygwin", NULL }, { "AIX", NULL }, { "DICOS", NULL },