if (gsymbol->language == language_cplus
|| gsymbol->language == language_d
|| gsymbol->language == language_go
- || gsymbol->language == language_java
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
{
const char *mangled)
{
char *demangled = NULL;
+ int i;
+ int recognized;
if (gsymbol->language == language_unknown)
gsymbol->language = language_auto;
- if (gsymbol->language == language_objc
- || gsymbol->language == language_auto)
- {
- demangled =
- objc_demangle (mangled, 0);
- if (demangled != NULL)
- {
- gsymbol->language = language_objc;
- return demangled;
- }
- }
- if (gsymbol->language == language_cplus
- || gsymbol->language == language_auto)
- {
- demangled =
- gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- gsymbol->language = language_cplus;
- return demangled;
- }
- }
- if (gsymbol->language == language_java)
- {
- demangled =
- gdb_demangle (mangled,
- DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
- if (demangled != NULL)
- {
- gsymbol->language = language_java;
- return demangled;
- }
- }
- if (gsymbol->language == language_d
- || gsymbol->language == language_auto)
+ if (gsymbol->language != language_auto)
{
- demangled = d_demangle(mangled, 0);
- if (demangled != NULL)
- {
- gsymbol->language = language_d;
- return demangled;
- }
+ const struct language_defn *lang = language_def (gsymbol->language);
+
+ language_sniff_from_mangled_name (lang, mangled, &demangled);
+ return demangled;
}
- /* FIXME(dje): Continually adding languages here is clumsy.
- Better to just call la_demangle if !auto, and if auto then call
- a utility routine that tries successive languages in turn and reports
- which one it finds. I realize the la_demangle options may be different
- for different languages but there's already a FIXME for that. */
- if (gsymbol->language == language_go
- || gsymbol->language == language_auto)
+
+ for (i = language_unknown; i < nr_languages; ++i)
{
- demangled = go_demangle (mangled, 0);
- if (demangled != NULL)
+ enum language l = (enum language) i;
+ const struct language_defn *lang = language_def (l);
+
+ if (language_sniff_from_mangled_name (lang, mangled, &demangled))
{
- gsymbol->language = language_go;
+ gsymbol->language = l;
return demangled;
}
}
- /* We could support `gsymbol->language == language_fortran' here to provide
- module namespaces also for inferiors with only minimal symbol table (ELF
- symbols). Just the mangling standard is not standardized across compilers
- and there is no DW_AT_producer available for inferiors with only the ELF
- symbols to check the mangling kind. */
-
- /* Check for Ada symbols last. See comment below explaining why. */
-
- if (gsymbol->language == language_auto)
- {
- const char *demangled = ada_decode (mangled);
-
- if (demangled != mangled && demangled != NULL && demangled[0] != '<')
- {
- /* Set the gsymbol language to Ada, but still return NULL.
- 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 NULL, here, 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). */
- gsymbol->language = language_ada;
- return NULL;
- }
- }
-
return NULL;
}
comes from the per-BFD storage_obstack. LINKAGE_NAME is copied,
so the pointer can be discarded after calling this function. */
-/* We have to be careful when dealing with Java names: when we run
- into a Java minimal symbol, we don't know it's a Java symbol, so it
- gets demangled as a C++ name. This is unfortunate, but there's not
- much we can do about it: but when demangling partial symbols and
- regular symbols, we'd better not reuse the wrong demangled name.
- (See PR gdb/1039.) We solve this by putting a distinctive prefix
- on Java names when storing them in the hash table. */
-
-/* FIXME: carlton/2003-03-13: This is an unfortunate situation. I
- don't mind the Java prefix so much: different languages have
- different demangling requirements, so it's only natural that we
- need to keep language data around in our demangling cache. But
- it's not good that the minimal symbol has the wrong demangled name.
- Unfortunately, I can't think of any easy solution to that
- problem. */
-
-#define JAVA_PREFIX "##JAVA$$"
-#define JAVA_PREFIX_LEN 8
-
void
symbol_set_names (struct general_symbol_info *gsymbol,
const char *linkage_name, int len, int copy_name,
struct demangled_name_entry **slot;
/* A 0-terminated copy of the linkage name. */
const char *linkage_name_copy;
- /* A copy of the linkage name that might have a special Java prefix
- added to it, for use when looking names up in the hash table. */
- const char *lookup_name;
- /* The length of lookup_name. */
- int lookup_len;
struct demangled_name_entry entry;
struct objfile_per_bfd_storage *per_bfd = objfile->per_bfd;
if (gsymbol->language == language_ada)
{
/* In Ada, we do the symbol lookups using the mangled name, so
- we can save some space by not storing the demangled name.
-
- As a side note, we have also observed some overlap between
- the C++ mangling and Ada mangling, similarly to what has
- been observed with Java. Because we don't store the demangled
- name with the symbol, we don't need to use the same trick
- as Java. */
+ we can save some space by not storing the demangled name. */
if (!copy_name)
gsymbol->name = linkage_name;
else
if (per_bfd->demangled_names_hash == NULL)
create_demangled_names_hash (objfile);
- /* The stabs reader generally provides names that are not
- NUL-terminated; most of the other readers don't do this, so we
- can just use the given copy, unless we're in the Java case. */
- if (gsymbol->language == language_java)
+ if (linkage_name[len] != '\0')
{
char *alloc_name;
- lookup_len = len + JAVA_PREFIX_LEN;
- alloc_name = (char *) alloca (lookup_len + 1);
- memcpy (alloc_name, JAVA_PREFIX, JAVA_PREFIX_LEN);
- memcpy (alloc_name + JAVA_PREFIX_LEN, linkage_name, len);
- alloc_name[lookup_len] = '\0';
-
- lookup_name = alloc_name;
- linkage_name_copy = alloc_name + JAVA_PREFIX_LEN;
- }
- else if (linkage_name[len] != '\0')
- {
- char *alloc_name;
-
- lookup_len = len;
- alloc_name = (char *) alloca (lookup_len + 1);
+ alloc_name = (char *) alloca (len + 1);
memcpy (alloc_name, linkage_name, len);
- alloc_name[lookup_len] = '\0';
+ alloc_name[len] = '\0';
- lookup_name = alloc_name;
linkage_name_copy = alloc_name;
}
else
- {
- lookup_len = len;
- lookup_name = linkage_name;
- linkage_name_copy = linkage_name;
- }
+ linkage_name_copy = linkage_name;
- entry.mangled = lookup_name;
+ entry.mangled = linkage_name_copy;
slot = ((struct demangled_name_entry **)
htab_find_slot (per_bfd->demangled_names_hash,
&entry, INSERT));
int demangled_len = demangled_name ? strlen (demangled_name) : 0;
/* Suppose we have demangled_name==NULL, copy_name==0, and
- lookup_name==linkage_name. In this case, we already have the
+ linkage_name_copy==linkage_name. In this case, we already have the
mangled name saved, and we don't have a demangled name. So,
you might think we could save a little space by not recording
this in the hash table at all.
It turns out that it is actually important to still save such
an entry in the hash table, because storing this name gives
us better bcache hit rates for partial symbols. */
- if (!copy_name && lookup_name == linkage_name)
+ if (!copy_name && linkage_name_copy == linkage_name)
{
*slot
= ((struct demangled_name_entry *)
obstack_alloc (&per_bfd->storage_obstack,
offsetof (struct demangled_name_entry, demangled)
+ demangled_len + 1));
- (*slot)->mangled = lookup_name;
+ (*slot)->mangled = linkage_name;
}
else
{
= ((struct demangled_name_entry *)
obstack_alloc (&per_bfd->storage_obstack,
offsetof (struct demangled_name_entry, demangled)
- + lookup_len + demangled_len + 2));
+ + len + demangled_len + 2));
mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
- strcpy (mangled_ptr, lookup_name);
+ strcpy (mangled_ptr, linkage_name_copy);
(*slot)->mangled = mangled_ptr;
}
(*slot)->demangled[0] = '\0';
}
- gsymbol->name = (*slot)->mangled + lookup_len - len;
+ gsymbol->name = (*slot)->mangled;
if ((*slot)->demangled[0] != '\0')
symbol_set_demangled_name (gsymbol, (*slot)->demangled,
&per_bfd->storage_obstack);
case language_cplus:
case language_d:
case language_go:
- case language_java:
case language_objc:
case language_fortran:
if (symbol_get_demangled_name (gsymbol) != NULL)
case language_cplus:
case language_d:
case language_go:
- case language_java:
case language_objc:
case language_fortran:
dem_name = symbol_get_demangled_name (gsymbol);
struct symbol_cache *cache
= (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
int pass;
- size_t total_size;
if (cache == NULL)
return;
modified_name = name;
- /* If we are using C++, D, Go, or Java, demangle the name before doing a
+ /* If we are using C++, D, or Go, demangle the name before doing a
lookup, so we can always binary search. */
if (lang == language_cplus)
{
}
}
}
- else if (lang == language_java)
- {
- demangled_name = gdb_demangle (name,
- DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
- if (demangled_name)
- {
- modified_name = demangled_name;
- make_cleanup (xfree, demangled_name);
- }
- }
else if (lang == language_d)
{
demangled_name = d_demangle (name, 0);
domain_enum domain)
{
/* For C++ "struct foo { ... }" also defines a typedef for "foo".
- A Java class declaration also defines a typedef for the class.
Similarly, any Ada type declaration implicitly defines a typedef. */
if (symbol_language == language_cplus
|| symbol_language == language_d
- || symbol_language == language_java
|| symbol_language == language_ada)
{
if ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN)
struct type *
basic_lookup_transparent_type (const char *name)
{
- struct symbol *sym;
- struct compunit_symtab *cust;
- const struct blockvector *bv;
struct objfile *objfile;
- struct block *block;
struct type *t;
/* Now search all the global symbols. Do the symtab's first, then
struct symbol_search **new_head,
struct symbol_search **new_tail)
{
- struct symbol_search **symbols, *symp, *old_next;
+ struct symbol_search **symbols, *symp;
int i, j, nunique;
gdb_assert (found != NULL && nfound > 0);
/* Prepare SYM_TEXT_LEN for compare_symbol_name. */
if (current_language->la_language == language_cplus
- || current_language->la_language == language_java
|| current_language->la_language == language_fortran)
{
/* These languages may have parameters entered by user but they are never
gdb_assert (ops != NULL);
gdb_assert (ops->tracepoint_var_ref != NULL);
gdb_assert (ops->describe_location != NULL);
- gdb_assert (ops->read_needs_frame != NULL);
+ gdb_assert (ops->get_symbol_read_needs != NULL);
gdb_assert (ops->read_variable != NULL);
return result;