From 7532cf103ab3dfcee75eed7425575c2fbe025e96 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Fri, 1 Jan 1993 20:29:41 +0000 Subject: [PATCH] * tm-sun4sol2.h (CPLUS_MARKER): Remove, now set in tm-sysv4.h. * tm-sysv4.h (CPLUS_MARKER): By default, g++ uses '.' as the CPLUS_MARKER for all SVR4 systems, so follow suit. * defs.h (strdup_demangled): Remove prototype. * dwarfread.c (enum_type, synthesize_typedef): Use new macro SYMBOL_INIT_LANGUAGE_SPECIFIC. * dwarfread.c (new_symbol): Use SYMBOL_INIT_DEMANGLED_NAME. * minsyms.c (install_minimal_symbols, prim_record_minimal_symbol, prim_record_minimal_symbol_and_info): Use new macro SYMBOL_INIT_LANGUAGE_SPECIFIC. * minsyms.c (install_minimal_symbols): Use new macro SYMBOL_INIT_DEMANGLED_NAME. * stabsread.c (define_symbol): Use new macro SYMBOL_INIT_DEMANGLED_NAME. * symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list): Use new macro SYMBOL_INIT_DEMANGLED_NAME. * symfile.h (ADD_PSYMBOL_VT_TO_LIST): Use new macro SYMBOL_INIT_DEMANGLED_NAME. * symmisc.c (dump_msymbols, dump_symtab, print_partial_symbol): SYMBOL_DEMANGLED_NAME now tests language itself. * symtab.c (COMPLETION_LIST_ADD_SYMBOL): SYMBOL_DEMANGLED_NAME now tests language itself. * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): New macro that does what SYMBOL_DEMANGLED_NAME used to do, directly access the C++ mangled name member in the language dependent portion of a symbol. * symtab.h (SYMBOL_DEMANGLED_NAME): New macro that returns the mangled name member appropriate for a symbol's language. * symtab.h (SYMBOL_SOURCE_NAME, SYMBOL_LINKAGE_NAME, SYMBOL_MATCHES_NAME, SYMBOL_MATCHES_REGEXP): SYMBOL_DEMANGLED_NAME now tests language itself. * symtab.h (SYMBOL_INIT_LANGUAGE_SPECIFIC): New macro that initializes language dependent portion of symbol. * symtab.h (SYMBOL_INIT_DEMANGLED_NAME): New macro that demangles and caches the demangled form of symbol names. * utils.c (fputs_demangled, fprint_symbol): Use current language to select an appropriate demangling algorithm. * utils.c (strdup_demangled): Remove, no longer used. **** start-sanitize-chill **** * symtab.h (SYMBOL_CHILL_DEMANGLED_NAME): New macro that directly access the Chill mangled name member in the language dependent portion of a symbol. * ch-lang.c (chill_demangle): New function, simple demangler. * defs.h (chill_demangle): Add prototype. * symtab.h (language_dependent_info): Add struct for Chill. **** end-sanitize-chill **** --- gdb/ChangeLog | 48 +++++++++++++++++++++++++++++++++++++++++++++++ gdb/ch-lang.c | 24 ++++++++++++++++++++++++ gdb/defs.h | 10 +++++++--- gdb/dwarfread.c | 20 +++----------------- gdb/minsyms.c | 36 ++++------------------------------- gdb/stabsread.c | 13 +------------ gdb/symfile.c | 34 ++------------------------------- gdb/symmisc.c | 9 +++------ gdb/tm-sun4sol2.h | 5 ----- gdb/tm-sysv4.h | 10 ++++++++++ 10 files changed, 102 insertions(+), 107 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 573130b1f37..e01cb11ac2a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,51 @@ +Fri Jan 1 11:56:23 1993 Fred Fish (fnf@cygnus.com) + + * tm-sun4sol2.h (CPLUS_MARKER): Remove, now set in tm-sysv4.h. + * tm-sysv4.h (CPLUS_MARKER): By default, g++ uses '.' as the + CPLUS_MARKER for all SVR4 systems, so follow suit. + * defs.h (strdup_demangled): Remove prototype. + * dwarfread.c (enum_type, synthesize_typedef): Use new macro + SYMBOL_INIT_LANGUAGE_SPECIFIC. + * dwarfread.c (new_symbol): Use SYMBOL_INIT_DEMANGLED_NAME. + * minsyms.c (install_minimal_symbols, prim_record_minimal_symbol, + prim_record_minimal_symbol_and_info): Use new macro + SYMBOL_INIT_LANGUAGE_SPECIFIC. + * minsyms.c (install_minimal_symbols): Use new macro + SYMBOL_INIT_DEMANGLED_NAME. + * stabsread.c (define_symbol): Use new macro + SYMBOL_INIT_DEMANGLED_NAME. + * symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list): + Use new macro SYMBOL_INIT_DEMANGLED_NAME. + * symfile.h (ADD_PSYMBOL_VT_TO_LIST): Use new macro + SYMBOL_INIT_DEMANGLED_NAME. + * symmisc.c (dump_msymbols, dump_symtab, print_partial_symbol): + SYMBOL_DEMANGLED_NAME now tests language itself. + * symtab.c (COMPLETION_LIST_ADD_SYMBOL): SYMBOL_DEMANGLED_NAME + now tests language itself. + * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): New macro that does + what SYMBOL_DEMANGLED_NAME used to do, directly access the C++ + mangled name member in the language dependent portion of a symbol. + * symtab.h (SYMBOL_DEMANGLED_NAME): New macro that returns the + mangled name member appropriate for a symbol's language. + * symtab.h (SYMBOL_SOURCE_NAME, SYMBOL_LINKAGE_NAME, + SYMBOL_MATCHES_NAME, SYMBOL_MATCHES_REGEXP): + SYMBOL_DEMANGLED_NAME now tests language itself. + * symtab.h (SYMBOL_INIT_LANGUAGE_SPECIFIC): New macro that + initializes language dependent portion of symbol. + * symtab.h (SYMBOL_INIT_DEMANGLED_NAME): New macro that + demangles and caches the demangled form of symbol names. + * utils.c (fputs_demangled, fprint_symbol): Use current language + to select an appropriate demangling algorithm. + * utils.c (strdup_demangled): Remove, no longer used. + **** start-sanitize-chill **** + * symtab.h (SYMBOL_CHILL_DEMANGLED_NAME): New macro that directly + access the Chill mangled name member in the language dependent + portion of a symbol. + * ch-lang.c (chill_demangle): New function, simple demangler. + * defs.h (chill_demangle): Add prototype. + * symtab.h (language_dependent_info): Add struct for Chill. + **** end-sanitize-chill **** + Thu Dec 31 11:06:38 1992 Fred Fish (fnf@cygnus.com) * Makefile.in (BISON): Add comment that when bison is used, it diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c index f512b4f7824..e42dc1b4493 100644 --- a/gdb/ch-lang.c +++ b/gdb/ch-lang.c @@ -25,6 +25,30 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "language.h" #include "ch-lang.h" + +/* For now, Chill uses a simple mangling algorithm whereby you simply + discard everything after the occurance of two successive CPLUS_MARKER + characters to derive the demangled form. */ + +char * +chill_demangle (mangled) + const char *mangled; +{ + char *joiner; + char *demangled; + + joiner = strchr (mangled, CPLUS_MARKER); + if (joiner != NULL && *(joiner + 1) == CPLUS_MARKER) + { + demangled = savestring (mangled, joiner - mangled); + } + else + { + demangled = NULL; + } + return (demangled); +} + static void chill_printchar (c, stream) register int c; diff --git a/gdb/defs.h b/gdb/defs.h index 53d1784d2c1..283b589519e 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -100,6 +100,13 @@ inside_entry_file PARAMS ((CORE_ADDR addr)); extern int inside_main_func PARAMS ((CORE_ADDR pc)); +/* start-sanitize-chill */ +/* From ch-lang.c, for the moment. (FIXME) */ + +extern char * +chill_demangle PARAMS ((const char *)); +/* end-sanitize-chill */ + /* From libiberty.a */ extern char * @@ -236,9 +243,6 @@ n_spaces PARAMS ((int)); extern void gdb_printchar PARAMS ((int, FILE *, int)); -extern char * -strdup_demangled PARAMS ((const char *)); - extern void fprint_symbol PARAMS ((FILE *, char *)); diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index dd1f0130838..3da9e7673b6 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -1737,8 +1737,7 @@ enum_type (dip, objfile) memset (sym, 0, sizeof (struct symbol)); SYMBOL_NAME (sym) = create_name (list -> field.name, &objfile->symbol_obstack); - SYMBOL_LANGUAGE (sym) = cu_language; - SYMBOL_DEMANGLED_NAME (sym) = NULL; + SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language); SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_TYPE (sym) = type; @@ -2939,19 +2938,7 @@ new_symbol (dip, objfile) C++ symbol lookups by a factor of about 20. */ SYMBOL_LANGUAGE (sym) = cu_language; - if (SYMBOL_LANGUAGE (sym) == language_cplus) - { - char *demangled = - cplus_demangle (SYMBOL_NAME (sym), DMGL_PARAMS | DMGL_ANSI); - if (demangled != NULL) - { - SYMBOL_DEMANGLED_NAME (sym) = - obsavestring (demangled, strlen (demangled), - &objfile -> symbol_obstack); - free (demangled); - } - } - + SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile -> symbol_obstack); switch (dip -> die_tag) { case TAG_label: @@ -3080,8 +3067,7 @@ synthesize_typedef (dip, objfile, type) memset (sym, 0, sizeof (struct symbol)); SYMBOL_NAME (sym) = create_name (dip -> at_name, &objfile->symbol_obstack); - SYMBOL_LANGUAGE (sym) = cu_language; - SYMBOL_DEMANGLED_NAME (sym) = NULL; + SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language); SYMBOL_TYPE (sym) = type; SYMBOL_CLASS (sym) = LOC_TYPEDEF; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 66ac9228542..b4ee1413742 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -264,12 +264,7 @@ prim_record_minimal_symbol (name, address, ms_type) } msymbol = &msym_bunch -> contents[msym_bunch_index]; SYMBOL_NAME (msymbol) = (char *) name; - /* Note that SYMBOL_LANGUAGE and SYMBOL_DEMANGLED_NAME are not initialized - to their final values until the minimal symbols are actually added to - the minimal symbol table. We just set them to a known state here so - random values won't confuse anyone debugging the debugger. */ - SYMBOL_LANGUAGE (msymbol) = language_unknown; - SYMBOL_DEMANGLED_NAME (msymbol) = NULL; + SYMBOL_INIT_LANGUAGE_SPECIFIC (msymbol, language_unknown); SYMBOL_VALUE_ADDRESS (msymbol) = address; MSYMBOL_TYPE (msymbol) = ms_type; /* FIXME: This info, if it remains, needs its own field. */ @@ -300,12 +295,7 @@ prim_record_minimal_symbol_and_info (name, address, ms_type, info) } msymbol = &msym_bunch -> contents[msym_bunch_index]; SYMBOL_NAME (msymbol) = (char *) name; - /* Note that SYMBOL_LANGUAGE and SYMBOL_DEMANGLED_NAME are not initialized - to their final values until the minimal symbols are actually added to - the minimal symbol table. We just set them to a known state here so - random values won't confuse anyone debugging the debugger. */ - SYMBOL_LANGUAGE (msymbol) = language_unknown; - SYMBOL_DEMANGLED_NAME (msymbol) = NULL; + SYMBOL_INIT_LANGUAGE_SPECIFIC (msymbol, language_unknown); SYMBOL_VALUE_ADDRESS (msymbol) = address; MSYMBOL_TYPE (msymbol) = ms_type; /* FIXME: This info, if it remains, needs its own field. */ @@ -539,8 +529,7 @@ install_minimal_symbols (objfile) SYMBOL_VALUE_ADDRESS (&msymbols[mcount]) = 0; MSYMBOL_INFO (&msymbols[mcount]) = NULL; MSYMBOL_TYPE (&msymbols[mcount]) = mst_unknown; - SYMBOL_LANGUAGE (&msymbols[mcount]) = language_unknown; - SYMBOL_DEMANGLED_NAME (&msymbols[mcount]) = NULL; + SYMBOL_INIT_LANGUAGE_SPECIFIC (&msymbols[mcount], language_unknown); /* Attach the minimal symbol table to the specified objfile. The strings themselves are also located in the symbol_obstack @@ -554,24 +543,7 @@ install_minimal_symbols (objfile) for ( ; mcount-- > 0 ; msymbols++) { - if (SYMBOL_LANGUAGE (msymbols) == language_auto) - { - demangled_name = cplus_demangle (SYMBOL_NAME (msymbols), - DMGL_PARAMS | DMGL_ANSI); - if (demangled_name == NULL) - { - SYMBOL_LANGUAGE (msymbols) = language_unknown; - } - else - { - SYMBOL_LANGUAGE (msymbols) = language_cplus; - SYMBOL_DEMANGLED_NAME (msymbols) = - obsavestring (demangled_name, strlen (demangled_name), - &objfile->symbol_obstack); - - free (demangled_name); - } - } + SYMBOL_INIT_DEMANGLED_NAME (msymbols, &objfile->symbol_obstack); } } } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7259df4d74f..c14835ecf0b 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -513,18 +513,7 @@ define_symbol (valu, string, desc, type, objfile) space tradeoff, that was decided in favor of time because it sped up C++ symbol lookups by a factor of about 20. */ - if (SYMBOL_LANGUAGE (sym) == language_cplus) - { - char *demangled = - cplus_demangle (SYMBOL_NAME (sym), DMGL_PARAMS | DMGL_ANSI); - if (demangled != NULL) - { - SYMBOL_DEMANGLED_NAME (sym) = - obsavestring (demangled, strlen (demangled), - &objfile -> symbol_obstack); - free (demangled); - } - } + SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); } p++; diff --git a/gdb/symfile.c b/gdb/symfile.c index 2265693bc39..06bce27a034 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1345,22 +1345,7 @@ add_psymbol_to_list (name, namelength, namespace, class, list, val, language, SYMBOL_LANGUAGE (psym) = language; PSYMBOL_NAMESPACE (psym) = namespace; PSYMBOL_CLASS (psym) = class; - if (language == language_cplus) - { - demangled_name = - cplus_demangle (SYMBOL_NAME (psym), DMGL_PARAMS | DMGL_ANSI); - if (demangled_name == NULL) - { - SYMBOL_DEMANGLED_NAME (psym) = NULL; - } - else - { - SYMBOL_DEMANGLED_NAME (psym) = - obsavestring (demangled_name, strlen (demangled_name), - &objfile->psymbol_obstack); - free (demangled_name); - } - } + SYMBOL_INIT_DEMANGLED_NAME (psym, &objfile->psymbol_obstack); } /* Add a symbol with a CORE_ADDR value to a psymtab. */ @@ -1394,22 +1379,7 @@ add_psymbol_addr_to_list (name, namelength, namespace, class, list, val, SYMBOL_LANGUAGE (psym) = language; PSYMBOL_NAMESPACE (psym) = namespace; PSYMBOL_CLASS (psym) = class; - if (language == language_cplus) - { - demangled_name = - cplus_demangle (SYMBOL_NAME (psym), DMGL_PARAMS | DMGL_ANSI); - if (demangled_name == NULL) - { - SYMBOL_DEMANGLED_NAME (psym) = NULL; - } - else - { - SYMBOL_DEMANGLED_NAME (psym) = - obsavestring (demangled_name, strlen (demangled_name), - &objfile->psymbol_obstack); - free (demangled_name); - } - } + SYMBOL_INIT_DEMANGLED_NAME (psym, &objfile->psymbol_obstack); } #endif /* !INLINE_ADD_PSYMBOL */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 670f527e781..40809e757eb 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -227,8 +227,7 @@ dump_msymbols (objfile, outfile) } fprintf_filtered (outfile, "[%2d] %c %#10x %s", index, ms_type, SYMBOL_VALUE_ADDRESS (msymbol), SYMBOL_NAME (msymbol)); - if (SYMBOL_LANGUAGE (msymbol) == language_cplus && - SYMBOL_DEMANGLED_NAME (msymbol) != NULL) + if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL) { fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol)); } @@ -333,8 +332,7 @@ dump_symtab (objfile, symtab, outfile) if (BLOCK_FUNCTION (b)) { fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b))); - if (SYMBOL_LANGUAGE (BLOCK_FUNCTION (b)) == language_cplus && - SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL) + if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL) { fprintf (outfile, " %s", SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b))); @@ -604,8 +602,7 @@ print_partial_symbol (p, count, what, outfile) while (count-- > 0) { fprintf_filtered (outfile, " `%s'", SYMBOL_NAME(p)); - if (SYMBOL_LANGUAGE (p) == language_cplus && - SYMBOL_DEMANGLED_NAME (p) != NULL) + if (SYMBOL_DEMANGLED_NAME (p) != NULL) { fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (p)); } diff --git a/gdb/tm-sun4sol2.h b/gdb/tm-sun4sol2.h index f785dd18ec2..dbf9ffbb383 100644 --- a/gdb/tm-sun4sol2.h +++ b/gdb/tm-sun4sol2.h @@ -37,11 +37,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define SUN_FIXED_LBRAC_BUG -/* Assembler doesn't grok dollar signs in identifiers, so we use dots instead. - This item must be coordinated with G++. */ -#undef CPLUS_MARKER -#define CPLUS_MARKER '.' - #if 0 /* Setjmp/longjmp are not as well doc'd in SunOS 5.x yet */ /* Offsets into jmp_buf. Not defined by Sun, but at least documented in a diff --git a/gdb/tm-sysv4.h b/gdb/tm-sysv4.h index cdf747b3250..a058e8f3bf7 100644 --- a/gdb/tm-sysv4.h +++ b/gdb/tm-sysv4.h @@ -39,3 +39,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ tables." So... */ #undef NAMES_HAVE_UNDERSCORE + +/* It is unknown which, if any, SVR4 assemblers do not accept dollar signs + in identifiers. The default in G++ is to use dots instead, for all SVR4 + systems, so we make that our default also. FIXME: There should be some + way to get G++ to tell us what CPLUS_MARKER it is using, perhaps by + stashing it in the debugging information as part of the name of an + invented symbol ("gcc_cplus_marker$" for example). */ + +#undef CPLUS_MARKER +#define CPLUS_MARKER '.' -- 2.30.2