public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 1/2] Add non-wrapping mode to ada_decode
Date: Thu, 17 Jun 2021 13:12:29 -0600	[thread overview]
Message-ID: <20210617191230.71887-2-tromey@adacore.com> (raw)
In-Reply-To: <20210617191230.71887-1-tromey@adacore.com>

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  <tromey@adacore.com>

	* 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<struct block_symbol> ada_lookup_symbol_list
      (const char *, const struct block *, domain_enum);
-- 
2.26.3


  reply	other threads:[~2021-06-17 19:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 19:12 [PATCH 0/2] Change Ada type names reported by Python Tom Tromey
2021-06-17 19:12 ` Tom Tromey [this message]
2021-06-17 19:12 ` [PATCH 2/2] Decode Ada types in Python layer Tom Tromey
2021-06-17 21:10   ` Christian Biesinger
2021-06-18 15:09     ` Tom Tromey
2021-06-18 16:25       ` Christian Biesinger
2021-06-22 16:56         ` Tom Tromey
2021-06-25 14:02 ` [PATCH 0/2] Change Ada type names reported by Python Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210617191230.71887-2-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).