diff options
author | Tom Tromey <tom@tromey.com> | 2016-05-26 15:04:07 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-06-23 21:11:48 -0600 |
commit | 8b302db80cb07f5f3264b50e1b51fdb8ecb29183 (patch) | |
tree | 6ce81a7c2ddd979e3a6560a1fa588a572fe5f596 /gdb/ada-lang.c | |
parent | 56618e20bc50e55b49ed224df2a2a7e0840056fe (diff) | |
download | gdb-8b302db80cb07f5f3264b50e1b51fdb8ecb29183.zip gdb-8b302db80cb07f5f3264b50e1b51fdb8ecb29183.tar.gz gdb-8b302db80cb07f5f3264b50e1b51fdb8ecb29183.tar.bz2 |
Move logic out of symbol_find_demangled_name
This patch moves most of the demangling logic out of
symbol_find_demangled_name into the various language_defn objects.
The simplest way to do this seemed to be to add a new method to
language_defn. This is shame given the existing la_demangle, but
given Ada's unusual needs, and the differing demangling options
between languages, la_demangle didn't seem to fit.
In order to make this work, I made enum language order-sensitive.
This helps preserve the current ordering of demangling operations.
2016-06-23 Tom Tromey <tom@tromey.com>
* symtab.c (symbol_find_demangled_name): Loop over languages and
use language_sniff_from_mangled_name.
* rust-lang.c (rust_sniff_from_mangled_name): New function.
(rust_language_defn): Update.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_sniff_from_mangled_name): New function.
(objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_sniff_from_mangled_name>: New
field.
(language_sniff_from_mangled_name): Declare.
* language.c (language_sniff_from_mangled_name): New function.
(unknown_language_defn, auto_language_defn, local_language_defn):
Update.
* jv-lang.c (java_sniff_from_mangled_name): New function.
(java_language_defn): Use it.
* go-lang.c (go_sniff_from_mangled_name): New function.
(go_language_defn): Use it.
* f-lang.c (f_language_defn): Update.
* defs.h (enum language): Reorder.
* d-lang.c (d_sniff_from_mangled_name): New function.
(d_language_defn): Use it.
* cp-support.h (gdb_sniff_from_mangled_name): Declare.
* cp-support.c (gdb_sniff_from_mangled_name): New function.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_sniff_from_mangled_name): New function.
(ada_language_defn): Use it.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 796dc65..b22b7ac 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1452,6 +1452,45 @@ ada_la_decode (const char *encoded, int options) return xstrdup (ada_decode (encoded)); } +/* Implement la_sniff_from_mangled_name for Ada. */ + +static int +ada_sniff_from_mangled_name (const char *mangled, char **out) +{ + const char *demangled = ada_decode (mangled); + + *out = NULL; + + if (demangled != mangled && demangled != NULL && demangled[0] != '<') + { + /* Set the gsymbol language to Ada, but still return 0. + Two reasons for that: + + 1. For Ada, we prefer computing the symbol's decoded name + on the fly rather than pre-compute it, in order to save + memory (Ada projects are typically very large). + + 2. There are some areas in the definition of the GNAT + encoding where, with a bit of bad luck, we might be able + to decode a non-Ada symbol, generating an incorrect + demangled name (Eg: names ending with "TB" for instance + are identified as task bodies and so stripped from + the decoded name returned). + + Returning 1, here, but not setting *DEMANGLED, helps us get a + little bit of the best of both worlds. Because we're last, + we should not affect any of the other languages that were + able to demangle the symbol before us; we get to correctly + tag Ada symbols as such; and even if we incorrectly tagged a + non-Ada symbol, which should be rare, any routing through the + Ada language should be transparent (Ada tries to behave much + like C/C++ with non-Ada symbols). */ + return 1; + } + + return 0; +} + /* Returns non-zero iff SYM_NAME matches NAME, ignoring any trailing suffixes that encode debugging information or leading _ada_ on SYM_NAME (see is_name_suffix commentary for the debugging @@ -14086,6 +14125,7 @@ const struct language_defn ada_language_defn = { ada_lookup_symbol_nonlocal, /* Looking up non-local symbols. */ basic_lookup_transparent_type, /* lookup_transparent_type */ ada_la_decode, /* Language specific symbol demangler */ + ada_sniff_from_mangled_name, NULL, /* Language specific class_name_from_physname */ ada_op_print_tab, /* expression operators for printing */ |