diff options
author | Adam Fedor <fedor@gnu.org> | 2003-04-02 03:02:46 +0000 |
---|---|---|
committer | Adam Fedor <fedor@gnu.org> | 2003-04-02 03:02:46 +0000 |
commit | 9a3d7dfd2e56889dce422be422767465d3f0f06b (patch) | |
tree | f86ad9aba59abf9c3148e8b7596b96e36ba4c3bf /gdb | |
parent | 5eb7f2340accc91a9efeab18386f95f24dd9709e (diff) | |
download | gdb-9a3d7dfd2e56889dce422be422767465d3f0f06b.zip gdb-9a3d7dfd2e56889dce422be422767465d3f0f06b.tar.gz gdb-9a3d7dfd2e56889dce422be422767465d3f0f06b.tar.bz2 |
* Makefile.in (c_lang.o, jv_lang.o, language.o): Add $(demangle_h).
* language.h (struct language_defn): Add la_demangle.
(language_demangle): Declare.
* language.c (language_demangle): New function.
(unk_lang_demangle): Likewise.
(unknown_language_defn, auto_language_defn, local_language_defn):
Add ukn_lang_demangle.
* ada-lang.c (ada_language_defn): Add NULL for la_demangle element.
* f-lang.c, m2-lang.c, p-lang.c, scm-lang.c: Likewise.
* c-lang.c (c_language_defn, asm_language_defn): Likewise.
(cplus_language_defn): Add cplus_demangle for la_demangle element.
* jv-lang.c (java_demangle): New function
(java_language_defn): Use it for la_demangle element.
* objc-lang.c (objc_demangle): Add options argument
(objc_language_defn): Use objc_demangle for la_demangle element.
* maint.c (maintenance_demangle): Replace switch with
call to language_demangle.
* utils.c (fprintf_symbol_filtered): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 21 | ||||
-rw-r--r-- | gdb/Makefile.in | 7 | ||||
-rw-r--r-- | gdb/ada-lang.c | 1 | ||||
-rw-r--r-- | gdb/c-lang.c | 4 | ||||
-rw-r--r-- | gdb/f-lang.c | 1 | ||||
-rw-r--r-- | gdb/jv-lang.c | 8 | ||||
-rw-r--r-- | gdb/language.c | 26 | ||||
-rw-r--r-- | gdb/language.h | 7 | ||||
-rw-r--r-- | gdb/m2-lang.c | 1 | ||||
-rw-r--r-- | gdb/maint.c | 13 | ||||
-rw-r--r-- | gdb/objc-lang.c | 3 | ||||
-rw-r--r-- | gdb/objc-lang.h | 2 | ||||
-rw-r--r-- | gdb/p-lang.c | 1 | ||||
-rw-r--r-- | gdb/scm-lang.c | 1 | ||||
-rw-r--r-- | gdb/utils.c | 17 |
15 files changed, 81 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b6f02d8..c25970b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,24 @@ +2003-04-01 Adam Fedor <fedor@gnu.org> + + * Makefile.in (c_lang.o, jv_lang.o, language.o): Add $(demangle_h). + * language.h (struct language_defn): Add la_demangle. + (language_demangle): Declare. + * language.c (language_demangle): New function. + (unk_lang_demangle): Likewise. + (unknown_language_defn, auto_language_defn, local_language_defn): + Add ukn_lang_demangle. + * ada-lang.c (ada_language_defn): Add NULL for la_demangle element. + * f-lang.c, m2-lang.c, p-lang.c, scm-lang.c: Likewise. + * c-lang.c (c_language_defn, asm_language_defn): Likewise. + (cplus_language_defn): Add cplus_demangle for la_demangle element. + * jv-lang.c (java_demangle): New function + (java_language_defn): Use it for la_demangle element. + * objc-lang.c (objc_demangle): Add options argument + (objc_language_defn): Use objc_demangle for la_demangle element. + * maint.c (maintenance_demangle): Replace switch with + call to language_demangle. + * utils.c (fprintf_symbol_filtered): Likewise. + 2003-04-01 Andrew Cagney <cagney@redhat.com> * printcmd.c (print_frame_nameless_args): Delete #ifdef diff --git a/gdb/Makefile.in b/gdb/Makefile.in index afdb327..e09bd7b 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1571,7 +1571,8 @@ builtin-regs.o: builtin-regs.c $(defs_h) $(builtin_regs_h) $(gdbtypes_h) \ $(gdb_string_h) $(gdb_assert_h) c-lang.o: c-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \ $(parser_defs_h) $(language_h) $(c_lang_h) $(valprint_h) \ - $(macroscope_h) $(gdb_assert_h) $(charset_h) $(gdb_string_h) + $(macroscope_h) $(gdb_assert_h) $(charset_h) $(gdb_string_h) \ + $(demangle_h) c-typeprint.o: c-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \ $(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(target_h) \ $(language_h) $(demangle_h) $(c_lang_h) $(typeprint_h) $(cp_abi_h) \ @@ -1853,7 +1854,7 @@ irix5-nat.o: irix5-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) $(target_h) \ jv-lang.o: jv-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \ $(parser_defs_h) $(language_h) $(gdbtypes_h) $(symtab_h) \ $(symfile_h) $(objfiles_h) $(gdb_string_h) $(value_h) $(c_lang_h) \ - $(jv_lang_h) $(gdbcore_h) $(block_h) + $(jv_lang_h) $(gdbcore_h) $(block_h) $(demangle_h) jv-typeprint.o: jv-typeprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) \ $(value_h) $(demangle_h) $(jv_lang_h) $(gdb_string_h) $(typeprint_h) \ $(c_lang_h) $(cp_abi_h) @@ -1865,7 +1866,7 @@ kod.o: kod.c $(defs_h) $(command_h) $(gdbcmd_h) $(target_h) $(gdb_string_h) \ $(kod_h) language.o: language.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \ $(value_h) $(gdbcmd_h) $(expression_h) $(language_h) $(target_h) \ - $(parser_defs_h) $(jv_lang_h) + $(parser_defs_h) $(jv_lang_h) $(demangle_h) lin-lwp.o: lin-lwp.c $(defs_h) $(gdb_assert_h) $(gdb_string_h) $(gdb_wait_h) \ $(gdbthread_h) $(inferior_h) $(target_h) $(regcache_h) $(gdbcmd_h) linespec.o: linespec.c $(defs_h) $(symtab_h) $(frame_h) $(command_h) \ diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index bcb2805..bc0809d 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8081,6 +8081,7 @@ const struct language_defn ada_language_defn = { ada_val_print, /* Print a value using appropriate syntax */ ada_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + NULL, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ #if 0 {"8#%lo#", "8#", "o", "#"}, /* Octal format info */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 4890a2b..e492b9a 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -31,6 +31,7 @@ #include "gdb_assert.h" #include "charset.h" #include "gdb_string.h" +#include "demangle.h" extern void _initialize_c_language (void); static void c_emit_char (int c, struct ui_file * stream, int quoter); @@ -553,6 +554,7 @@ const struct language_defn c_language_defn = c_val_print, /* Print a value using appropriate syntax */ c_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + NULL, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ @@ -606,6 +608,7 @@ const struct language_defn cplus_language_defn = c_val_print, /* Print a value using appropriate syntax */ c_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + cplus_demangle, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ @@ -636,6 +639,7 @@ const struct language_defn asm_language_defn = c_val_print, /* Print a value using appropriate syntax */ c_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + NULL, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 6d4e7f9..2a4eac3 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -473,6 +473,7 @@ const struct language_defn f_language_defn = f_val_print, /* Print a value using appropriate syntax */ c_value_print, /* FIXME */ NULL, /* Language specific skip_trampoline */ + NULL, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%o", "0", "o", ""}, /* Octal format info */ {"%d", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index f6bc2de..9e73030 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -34,6 +34,7 @@ #include "jv-lang.h" #include "gdbcore.h" #include "block.h" +#include "demangle.h" #include <ctype.h> struct type *java_int_type; @@ -996,6 +997,12 @@ java_create_fundamental_type (struct objfile *objfile, int typeid) return c_create_fundamental_type (objfile, typeid); } +static char *java_demangle (const char *mangled, int options) +{ + return cplus_demangle (mangled, options | DMGL_JAVA); +} + + /* Table mapping opcodes into strings for printing operators and precedences of the operators. */ @@ -1055,6 +1062,7 @@ const struct language_defn java_language_defn = java_val_print, /* Print a value using appropriate syntax */ java_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + java_demangle, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/language.c b/gdb/language.c index 2b71d1f..0a65094 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -44,6 +44,7 @@ #include "target.h" #include "parser-defs.h" #include "jv-lang.h" +#include "demangle.h" extern void _initialize_language (void); @@ -1361,6 +1362,21 @@ skip_language_trampoline (CORE_ADDR pc) return 0; } +/* Return demangled language symbol, or NULL. + FIXME: Options are only useful for certain languages and ignored + by others, so it would be better to remove them here and have a + more flexible demangler for the languages that need it. + FIXME: Sometimes the demangler is invoked when we don't know the + language, so we can't use this everywhere. */ +char * +language_demangle (const struct language_defn *current_language, + const char *mangled, int options) +{ + if (current_language != NULL && current_language->la_demangle) + return current_language->la_demangle (mangled, options); + return NULL; +} + /* Define the language that is no language. */ @@ -1428,6 +1444,13 @@ static CORE_ADDR unk_lang_trampoline (CORE_ADDR pc) return 0; } +/* Unknown languages just use the cplus demangler. */ +static char *unk_lang_demangle (const char *mangled, int options) +{ + return cplus_demangle (mangled, options); +} + + static struct type **const (unknown_builtin_types[]) = { 0 @@ -1456,6 +1479,7 @@ const struct language_defn unknown_language_defn = unk_lang_val_print, /* Print a value using appropriate syntax */ unk_lang_value_print, /* Print a top-level value */ unk_lang_trampoline, /* Language specific skip_trampoline */ + unk_lang_demangle, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ @@ -1487,6 +1511,7 @@ const struct language_defn auto_language_defn = unk_lang_val_print, /* Print a value using appropriate syntax */ unk_lang_value_print, /* Print a top-level value */ unk_lang_trampoline, /* Language specific skip_trampoline */ + unk_lang_demangle, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ @@ -1517,6 +1542,7 @@ const struct language_defn local_language_defn = unk_lang_val_print, /* Print a value using appropriate syntax */ unk_lang_value_print, /* Print a top-level value */ unk_lang_trampoline, /* Language specific skip_trampoline */ + unk_lang_demangle, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/language.h b/gdb/language.h index 4b9f8ce..d926532 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -209,6 +209,9 @@ struct language_defn if it isn't a language tramp for this language. */ CORE_ADDR (*skip_trampoline) (CORE_ADDR pc); + /* Return demangled language symbol, or NULL. */ + char *(*la_demangle) (const char *mangled, int options); + /* Base 2 (binary) formats. */ struct language_format_info la_binary_format; @@ -475,4 +478,8 @@ extern enum language get_frame_language (void); /* In stack.c */ extern CORE_ADDR skip_language_trampoline (CORE_ADDR pc); +/* Return demangled language symbol, or NULL. */ +extern char *language_demangle (const struct language_defn *current_language, + const char *mangled, int options); + #endif /* defined (LANGUAGE_H) */ diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 48c6931..4932cdf 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -427,6 +427,7 @@ const struct language_defn m2_language_defn = m2_val_print, /* Print a value using appropriate syntax */ c_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + NULL, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"%loB", "", "o", "B"}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/maint.c b/gdb/maint.c index f2dfa68..166acdb 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -151,17 +151,8 @@ maintenance_demangle (char *args, int from_tty) } else { - switch (current_language->la_language) - { - case language_objc: - /* Commented out until ObjC handling is enabled. */ - /* demangled = objc_demangle (args); */ - /* break; */ - case language_cplus: - default: - demangled = cplus_demangle (args, DMGL_ANSI | DMGL_PARAMS); - break; - } + demangled = language_demangle (current_language, args, + DMGL_ANSI | DMGL_PARAMS); if (demangled != NULL) { printf_unfiltered ("%s\n", demangled); diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 911831e..6fbbaa7 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -237,7 +237,7 @@ value_nsstring (char *ptr, int len) /* Objective-C name demangling. */ char * -objc_demangle (const char *mangled) +objc_demangle (const char *mangled, int options) { char *demangled, *cp; @@ -700,6 +700,7 @@ const struct language_defn objc_language_defn = { c_val_print, /* Print a value using appropriate syntax */ c_value_print, /* Print a top-level value */ objc_skip_trampoline, /* Language specific skip_trampoline */ + objc_demangle, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h index 02688c7..0c49bac 100644 --- a/gdb/objc-lang.h +++ b/gdb/objc-lang.h @@ -41,7 +41,7 @@ extern int c_value_print (struct value *, struct ui_file *, extern CORE_ADDR lookup_objc_class (char *classname); extern int lookup_child_selector (char *methodname); -extern char *objc_demangle (const char *mangled); +extern char *objc_demangle (const char *mangled, int options); extern int find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc); diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 40019a4..827fa0e 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -462,6 +462,7 @@ const struct language_defn pascal_language_defn = pascal_val_print, /* Print a value using appropriate syntax */ pascal_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + NULL, /* Language specific symbol demangler */ {"", "%", "b", ""}, /* Binary format info */ {"0%lo", "0", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c index 746e599..99a1fd5 100644 --- a/gdb/scm-lang.c +++ b/gdb/scm-lang.c @@ -251,6 +251,7 @@ const struct language_defn scm_language_defn = scm_val_print, /* Print a value using appropriate syntax */ scm_value_print, /* Print a top-level value */ NULL, /* Language specific skip_trampoline */ + NULL, /* Language specific symbol demangler */ {"", "", "", ""}, /* Binary format info */ {"#o%lo", "#o", "o", ""}, /* Octal format info */ {"%ld", "", "d", ""}, /* Decimal format info */ diff --git a/gdb/utils.c b/gdb/utils.c index f7ece88..f8ac0fd 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2298,22 +2298,7 @@ fprintf_symbol_filtered (struct ui_file *stream, char *name, } else { - switch (lang) - { - case language_cplus: - demangled = cplus_demangle (name, arg_mode); - break; - case language_java: - demangled = cplus_demangle (name, arg_mode | DMGL_JAVA); - break; - case language_objc: - /* Commented out until ObjC handling is enabled. */ - /*demangled = objc_demangle (name); */ - /*break; */ - default: - demangled = NULL; - break; - } + demangled = language_demangle (language_def (lang), name, arg_mode); fputs_filtered (demangled ? demangled : name, stream); if (demangled != NULL) { |