aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-05-26 15:04:07 -0600
committerTom Tromey <tom@tromey.com>2016-06-23 21:11:48 -0600
commit8b302db80cb07f5f3264b50e1b51fdb8ecb29183 (patch)
tree6ce81a7c2ddd979e3a6560a1fa588a572fe5f596 /gdb/language.c
parent56618e20bc50e55b49ed224df2a2a7e0840056fe (diff)
downloadgdb-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/language.c')
-rw-r--r--gdb/language.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/language.c b/gdb/language.c
index 02e21ca..f761002 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -663,6 +663,23 @@ language_demangle (const struct language_defn *current_language,
return NULL;
}
+/* See langauge.h. */
+
+int
+language_sniff_from_mangled_name (const struct language_defn *lang,
+ const char *mangled, char **demangled)
+{
+ gdb_assert (lang != NULL);
+
+ if (lang->la_sniff_from_mangled_name == NULL)
+ {
+ *demangled = NULL;
+ return 0;
+ }
+
+ return lang->la_sniff_from_mangled_name (mangled, demangled);
+}
+
/* Return class name from physname or NULL. */
char *
language_class_name_from_physname (const struct language_defn *lang,
@@ -843,6 +860,7 @@ const struct language_defn unknown_language_defn =
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
+ NULL,
unk_lang_class_name, /* Language specific
class_name_from_physname */
unk_op_print_tab, /* expression operators for printing */
@@ -891,6 +909,7 @@ const struct language_defn auto_language_defn =
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
+ NULL,
unk_lang_class_name, /* Language specific
class_name_from_physname */
unk_op_print_tab, /* expression operators for printing */
@@ -937,6 +956,7 @@ const struct language_defn local_language_defn =
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
+ NULL,
unk_lang_class_name, /* Language specific
class_name_from_physname */
unk_op_print_tab, /* expression operators for printing */