From patchwork Fri Nov 14 16:49:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 3741 Received: (qmail 15330 invoked by alias); 14 Nov 2014 16:49:26 -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 15319 invoked by uid 89); 14 Nov 2014 16:49:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 14 Nov 2014 16:49:24 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D66501168E9 for ; Fri, 14 Nov 2014 11:49:22 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Jp+8s9Mw6+B6 for ; Fri, 14 Nov 2014 11:49:22 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 6F2D31168C0 for ; Fri, 14 Nov 2014 11:49:22 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id DAB4340F79; Fri, 14 Nov 2014 20:49:20 +0400 (RET) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [commit/Ada] gdb.ada/complete.exp failure on x86_64-windows Date: Fri, 14 Nov 2014 20:49:19 +0400 Message-Id: <1415983759-26868-1-git-send-email-brobecker@adacore.com> Hello, Using the example in gdb.ada/complete.exp, the following command on x86_64-windows returns one unwanted completion choice : (gdb) complete p pck p > [all following completions entries snipped, all expected] I tracked down this suprising entry to a minimal symbol whose name is ".refptr.pck_E". The problem occurs while trying to see if this symbol matches "pck" when doing wild-matching as we are doing here: /* Second: Try wild matching... */ if (!match && wild_match_p) { /* Since we are doing wild matching, this means that TEXT may represent an unqualified symbol name. We therefore must also compare TEXT against the unqualified name of the symbol. */ sym_name = ada_unqualified_name (ada_decode (sym_name)); if (strncmp (sym_name, text, text_len) == 0) match = 1; } What happens is that ada_decode correctly identifies the fact that SYM_NAME (".refptr.pck_E") is not following any GNAT encoding, and therefore returns that same name, but bracketed: "<.refptr.pck_E>". This is the convention we use for telling GDB that the decoded name is not a real Ada name - and therefore should not be encoded for operations such as name matching, symbol lookups, etc. So far, so good. Next is the call to ada_unqualified_name, which unfortunately does not notice that the decoded name it is being given isn't a natural symbol, and just blindly strips everything up to the last do, returning "pck_E>". And of course, "pck_E>" matches "pck" now, and so we end up accepting this symbol as a match. This patch fixes the problem by making ada_unqualified_name a little smarter by making sure that the given decoded symbol name does not start with '<'. gdb/ChangeLog: * ada-lang.c (ada_unqualified_name): Return DECODED_NAME if it starts with '<'. Tested on x86_64-windows using AdaCore's testsuite as well as on x86_64-linux. I will push the patch sometime next week, unless there are any comments. Thanks, diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b576839..86195e8 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -523,8 +523,16 @@ ada_typedef_target_type (struct type *type) static const char * ada_unqualified_name (const char *decoded_name) { - const char *result = strrchr (decoded_name, '.'); + const char *result; + + /* If the decoded name starts with '<', it means that the encoded + name does not follow standard naming conventions, and thus that + it is not your typical Ada symbol name. Trying to unqualify it + is therefore pointless and possibly erroneous. */ + if (decoded_name[0] == '<') + return decoded_name; + result = strrchr (decoded_name, '.'); if (result != NULL) result++; /* Skip the dot... */ else