Fix regression in Ada do_full_match
authorTom Tromey <tromey@adacore.com>
Thu, 7 Jan 2021 14:02:46 +0000 (07:02 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 7 Jan 2021 14:06:26 +0000 (07:06 -0700)
An earlier patch to ada-lang.c:do_full_match introduced a subtle
change to the semantics.  The previous code did:

    -  if (strncmp (sym_name, search_name, search_name_len) == 0
    -      && is_name_suffix (sym_name + search_name_len))
    -    return true;
    -
    -  if (startswith (sym_name, "_ada_")

whereas the new code unconditionally skips a leading "_ada_".

The difference occurs if the lookup name itself starts with "_ada_".
In this case, the symbol won't match.

Normally this doesn't seem to be a problem.  However, it caused a
regression on one particular (internal) test case on one particular
platform.

This patch changes the code to handle this case.  I don't know how to
write a reliable test case for this, so no test is included.

2021-01-07  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (do_full_match): Conditionally skip "_ada_" prefix.

gdb/ChangeLog
gdb/ada-lang.c

index dd8c01b710acf13f56beff75d77b993e207c61f8..f3357d5e659a3674ebafb691fb0bd6da76c7e402 100644 (file)
@@ -1,3 +1,7 @@
+2021-01-07  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (do_full_match): Conditionally skip "_ada_" prefix.
+
 2021-01-07  Tom Tromey  <tromey@adacore.com>
 
        * ada-lang.c (add_component_interval): Start loop using vector's
index 4751b6eeda3ac9cca58c24239ca2ef42d315abe8..c898ccb683cfceb85dab0dc09e09b3fa53eddfe1 100644 (file)
@@ -13572,10 +13572,16 @@ do_full_match (const char *symbol_search_name,
               const lookup_name_info &lookup_name,
               completion_match_result *comp_match_res)
 {
-  if (startswith (symbol_search_name, "_ada_"))
+  const char *lname = lookup_name.ada ().lookup_name ().c_str ();
+
+  /* If both symbols start with "_ada_", just let the loop below
+     handle the comparison.  However, if only the symbol name starts
+     with "_ada_", skip the prefix and let the match proceed as
+     usual.  */
+  if (startswith (symbol_search_name, "_ada_")
+      && !startswith (lname, "_ada"))
     symbol_search_name += 5;
 
-  const char *lname = lookup_name.ada ().lookup_name ().c_str ();
   int uscore_count = 0;
   while (*lname != '\0')
     {
This page took 0.03275 seconds and 4 git commands to generate.