diff options
author | Tom Tromey <tromey@adacore.com> | 2020-12-14 08:14:06 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-12-14 08:14:06 -0700 |
commit | 86b442599bca468f997a3f1f58cba68b752ef6b2 (patch) | |
tree | bbdf6c450491a0746e511eeccf9982cef12c512a /gdb/ada-lang.c | |
parent | 25a1127be7d6923904b2346ff76e7e9658620bf5 (diff) | |
download | gdb-86b442599bca468f997a3f1f58cba68b752ef6b2.zip gdb-86b442599bca468f997a3f1f58cba68b752ef6b2.tar.gz gdb-86b442599bca468f997a3f1f58cba68b752ef6b2.tar.bz2 |
Handle block-local names for Ada
GNAT can generate a mangled name with "B_N" (where N is a number) in
the middle, like "hello__B_1__fourth.0". This is used for names local
to a block. Multiple levels of block-local name can also occur, a
possibility that was neglected by v1 of this patch. This patch
changes gdb to handle these names.
The wild name matcher is updated a straightforward way. The full
matcher is rewritten. The hash function is updated to ensure that
this works.
This version does not seem to have the performance problems that
affected v1. In particular, the previously-slow "bt" problem has been
fixed.
gdb/ChangeLog
2020-12-14 Tom Tromey <tromey@adacore.com>
* dictionary.c (language_defn::search_name_hash): Ignore "B".
* ada-lang.c (advance_wild_match): Ignore "B".
(full_match): Remove.
(do_full_match): Rewrite.
gdb/testsuite/ChangeLog
2020-12-14 Tom Tromey <tromey@adacore.com>
* gdb.ada/nested.exp: Add new tests.
* gdb.ada/nested/hello.adb (Fourth, Fifth): New procedures.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index ca66642..564cdbe 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6037,6 +6037,13 @@ advance_wild_match (const char **namep, const char *name0, char target0) name += 2; break; } + else if (t1 == '_' && name[2] == 'B' && name[3] == '_') + { + /* Names like "pkg__B_N__name", where N is a number, are + block-local. We can handle these by simply skipping + the "B_" here. */ + name += 4; + } else return 0; } @@ -6081,28 +6088,6 @@ wild_match (const char *name, const char *patn) } } -/* Returns true iff symbol name SYM_NAME matches SEARCH_NAME, ignoring - any trailing suffixes that encode debugging information or leading - _ada_ on SYM_NAME (see is_name_suffix commentary for the debugging - information that is ignored). */ - -static bool -full_match (const char *sym_name, const char *search_name) -{ - size_t search_name_len = strlen (search_name); - - 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_") - && strncmp (sym_name + 5, search_name, search_name_len) == 0 - && is_name_suffix (sym_name + search_name_len + 5)) - return true; - - return false; -} - /* Add symbols from BLOCK matching LOOKUP_NAME in DOMAIN to vector *defn_symbols, updating the list of symbols in OBSTACKP (if necessary). OBJFILE is the section containing BLOCK. */ @@ -13606,7 +13591,41 @@ do_full_match (const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res) { - return full_match (symbol_search_name, ada_lookup_name (lookup_name)); + if (startswith (symbol_search_name, "_ada_")) + symbol_search_name += 5; + + const char *lname = lookup_name.ada ().lookup_name ().c_str (); + int uscore_count = 0; + while (*lname != '\0') + { + if (*symbol_search_name != *lname) + { + if (*symbol_search_name == 'B' && uscore_count == 2 + && symbol_search_name[1] == '_') + { + symbol_search_name += 2; + while (isdigit (*symbol_search_name)) + ++symbol_search_name; + if (symbol_search_name[0] == '_' + && symbol_search_name[1] == '_') + { + symbol_search_name += 2; + continue; + } + } + return false; + } + + if (*symbol_search_name == '_') + ++uscore_count; + else + uscore_count = 0; + + ++symbol_search_name; + ++lname; + } + + return is_name_suffix (symbol_search_name); } /* symbol_name_matcher_ftype for exact (verbatim) matches. */ |