diff options
author | Sami Wagiaalla <swagiaal@redhat.com> | 2010-07-16 19:23:56 +0000 |
---|---|---|
committer | Sami Wagiaalla <swagiaal@redhat.com> | 2010-07-16 19:23:56 +0000 |
commit | 29df156df4e7df351f9ba24641df74739d39c8e8 (patch) | |
tree | 871abb704d7e9222c4b40e32aff076ec9d141ec0 /gdb/symtab.c | |
parent | 502abbdf22c780cc0acdc17b90159a8e475db036 (diff) | |
download | gdb-29df156df4e7df351f9ba24641df74739d39c8e8.zip gdb-29df156df4e7df351f9ba24641df74739d39c8e8.tar.gz gdb-29df156df4e7df351f9ba24641df74739d39c8e8.tar.bz2 |
Use allocated cplus_specific for cplus symbols.
2010-07-16 Sami Wagiaalla <swagiaal@redhat.com>
* symtab.h (symbol_set_demangled_name): Now takes an optional objfile*
argument.
(cplus_specific): New struct.
* symtab.c (symbol_set_demangled_name): Updated.
Use cplus_specific for cplus symbols.
(symbol_get_demangled_name): Retrive the name from the cplus_specific
struct for cplus symbols.
(symbol_init_language_specific): Set cplus_specific for cplus symbols.
(symbol_set_names): Pass objfile to symbol_set_demangled_name.
* symtab.c (symbol_init_cplus_specific): New function.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 8701d1f..b0e7061 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -340,20 +340,53 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id) return (mangled_name); } +/* Initialize the cplus_specific structure. 'cplus_specific' should + only be allocated for use with cplus symbols. */ + +static void +symbol_init_cplus_specific (struct general_symbol_info *gsymbol, + struct objfile *objfile) +{ + /* A language_specific structure should not have been previously + initialized. */ + gdb_assert (gsymbol->language_specific.cplus_specific == NULL); + gdb_assert (objfile != NULL); + + gsymbol->language_specific.cplus_specific = + OBSTACK_ZALLOC (&objfile->objfile_obstack, struct cplus_specific); +} + /* Set the demangled name of GSYMBOL to NAME. NAME must be already - correctly allocated. */ + correctly allocated. For C++ symbols a cplus_specific struct is + allocated so OBJFILE must not be NULL. If this is a non C++ symbol + OBJFILE can be NULL. */ void symbol_set_demangled_name (struct general_symbol_info *gsymbol, - char *name) + char *name, + struct objfile *objfile) { - gsymbol->language_specific.mangled_lang.demangled_name = name; + if (gsymbol->language == language_cplus) + { + if (gsymbol->language_specific.cplus_specific == NULL) + symbol_init_cplus_specific (gsymbol, objfile); + + gsymbol->language_specific.cplus_specific->demangled_name = name; + } + else + gsymbol->language_specific.mangled_lang.demangled_name = name; } /* Return the demangled name of GSYMBOL. */ char * symbol_get_demangled_name (const struct general_symbol_info *gsymbol) { - return gsymbol->language_specific.mangled_lang.demangled_name; + if (gsymbol->language == language_cplus) + { + gdb_assert (gsymbol->language_specific.cplus_specific != NULL); + return gsymbol->language_specific.cplus_specific->demangled_name; + } + else + return gsymbol->language_specific.mangled_lang.demangled_name; } @@ -363,6 +396,7 @@ void symbol_init_language_specific (struct general_symbol_info *gsymbol, enum language language) { + gsymbol->language = language; if (gsymbol->language == language_cplus || gsymbol->language == language_d @@ -370,8 +404,10 @@ symbol_init_language_specific (struct general_symbol_info *gsymbol, || gsymbol->language == language_objc || gsymbol->language == language_fortran) { - symbol_set_demangled_name (gsymbol, NULL); + symbol_set_demangled_name (gsymbol, NULL, NULL); } + else if (gsymbol->language == language_cplus) + gsymbol->language_specific.cplus_specific = NULL; else { memset (&gsymbol->language_specific, 0, @@ -553,7 +589,7 @@ symbol_set_names (struct general_symbol_info *gsymbol, memcpy (gsymbol->name, linkage_name, len); gsymbol->name[len] = '\0'; } - symbol_set_demangled_name (gsymbol, NULL); + symbol_set_demangled_name (gsymbol, NULL, NULL); return; } @@ -649,9 +685,9 @@ symbol_set_names (struct general_symbol_info *gsymbol, gsymbol->name = (*slot)->mangled + lookup_len - len; if ((*slot)->demangled[0] != '\0') - symbol_set_demangled_name (gsymbol, (*slot)->demangled); + symbol_set_demangled_name (gsymbol, (*slot)->demangled, objfile); else - symbol_set_demangled_name (gsymbol, NULL); + symbol_set_demangled_name (gsymbol, NULL, objfile); } /* Return the source code name of a symbol. In languages where |