From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 310753987C38 for ; Thu, 17 Jun 2021 19:12:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 310753987C38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DDE1A1168A8; Thu, 17 Jun 2021 15:12:31 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com 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 k0a8A9rLvdCl; Thu, 17 Jun 2021 15:12:31 -0400 (EDT) Received: from murgatroyd.Home (97-122-70-83.hlrn.qwest.net [97.122.70.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 9CA10116894; Thu, 17 Jun 2021 15:12:31 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/2] Add non-wrapping mode to ada_decode Date: Thu, 17 Jun 2021 13:12:29 -0600 Message-Id: <20210617191230.71887-2-tromey@adacore.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210617191230.71887-1-tromey@adacore.com> References: <20210617191230.71887-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2021 19:12:34 -0000 When ada_decode encounters a name that it cannot decode, it simply wraps it in <...>, which is used elsewhere in the Ada code to indicate that a verbatim match should be done. A subequent patch needed the ability to suppress this wrapping, so this patch adds a new mode to ada_decode. gdb/ChangeLog 2021-06-17 Tom Tromey * ada-lang.c (ada_decode): Add wrap parameter. * ada-lang.h (ada_decode): Add wrap parameter. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 10 +++++----- gdb/ada-lang.h | 7 ++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 6ed6b65e705..49a7d5b36b6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -976,12 +976,10 @@ ada_remove_po_subprogram_suffix (const char *encoded, int *len) *len = *len - 1; } -/* If ENCODED follows the GNAT entity encoding conventions, then return - the decoded form of ENCODED. Otherwise, return "<%s>" where "%s" is - replaced by ENCODED. */ +/* See ada-lang.h. */ std::string -ada_decode (const char *encoded) +ada_decode (const char *encoded, bool wrap) { int i, j; int len0; @@ -1216,12 +1214,14 @@ ada_decode (const char *encoded) return decoded; Suppress: + if (!wrap) + return {}; + if (encoded[0] == '<') decoded = encoded; else decoded = '<' + std::string(encoded) + '>'; return decoded; - } /* Table for keeping permanent unique copies of decoded names. Once diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 156c9b0cec7..a89ed29119a 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -216,7 +216,12 @@ extern struct type *ada_get_decoded_type (struct type *type); extern const char *ada_decode_symbol (const struct general_symbol_info *); -extern std::string ada_decode (const char*); +/* Decode the GNAT-encoded name NAME, returning the decoded name. If + the name does not appear to be GNAT-encoded, then the result + depends on WRAP. If WRAP is true (the default), then the result is + simply wrapped in <...>. If WRAP is false, then the empty string + will be returned. */ +extern std::string ada_decode (const char *name, bool wrap = true); extern std::vector ada_lookup_symbol_list (const char *, const struct block *, domain_enum); -- 2.26.3