]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add non-wrapping mode to ada_decode
authorTom Tromey <tromey@adacore.com>
Fri, 25 Jun 2021 14:01:15 +0000 (08:01 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 25 Jun 2021 14:07:21 +0000 (08:07 -0600)
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.

2021-06-25  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (ada_decode): Add wrap parameter.
* ada-lang.h (ada_decode): Add wrap parameter.

gdb/ChangeLog
gdb/ada-lang.c
gdb/ada-lang.h

index 820a9d36b4523fc2cd9cf90a583489ebb21745fd..9d56f1c7bc32febaaa6751df492b743f5dfa5c69 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-25  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (ada_decode): Add wrap parameter.
+       * ada-lang.h (ada_decode): Add wrap parameter.
+
 2021-06-25  Luis Machado  <luis.machado@linaro.org>
 
        * corelow.c (core_target::core_target) Update to read target
index 6ed6b65e705b4bb42b5c1662bb01955d9a7204d6..49a7d5b36b6ca18a69aae2333b8b651b1854c4aa 100644 (file)
@@ -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
index 156c9b0cec781518c59aa67fc853e63a16f25526..a89ed29119a24b9c18df066f1f4e3b1bf7b5abb1 100644 (file)
@@ -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);