instead of matching the symbol domain explictly.
* dwarf2read.c (add_partial_symbol): Do not add new psym for
STRUCT_DOMAIN. Make sure you recognize c++ struct and java and ada
class as typedefs. See lookup_partial_symbol function.
(new_symbol): Similar to add_partial_symbol, do not create
symbol for the typedef. See lookup_block_symbol.
* symtab.c (symbol_matches_domain): New function, takes care
of dual meaning of STRUCT_DOMAIN symbol for c++, ada and java.
(lookup_partial_symbol): Use symbol_matches_domain to see if the
found psym domain matches the given domain.
(lookup_block_symbol): Likewise.
+2008-05-05 Aleksandar Ristovski <aristovski@qnx.com>
+ Joel Brobecker <brobecker@adacore.com>
+
+ * ada-lang.c: Update throughout to use symbol_matches_domain
+ instead of matching the symbol domain explictly.
+ * dwarf2read.c (add_partial_symbol): Do not add new psym for
+ STRUCT_DOMAIN. Make sure you recognize c++ struct and java and ada
+ class as typedefs. See lookup_partial_symbol function.
+ (new_symbol): Similar to add_partial_symbol, do not create
+ symbol for the typedef. See lookup_block_symbol.
+ * symtab.c (symbol_matches_domain): New function, takes care
+ of dual meaning of STRUCT_DOMAIN symbol for c++, ada and java.
+ (lookup_partial_symbol): Use symbol_matches_domain to see if the
+ found psym domain matches the given domain.
+ (lookup_block_symbol): Likewise.
+
2008-05-05 Vladimir Prus <vladimir@codesourcery.com>
* top.c (command_line_handler_continuation): Remove.
{
struct partial_symbol *psym = start[i];
- if (SYMBOL_DOMAIN (psym) == namespace
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (psym),
+ SYMBOL_DOMAIN (psym), namespace)
&& wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym)))
return psym;
}
{
struct partial_symbol *psym = start[i];
- if (SYMBOL_DOMAIN (psym) == namespace)
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (psym),
+ SYMBOL_DOMAIN (psym), namespace))
{
int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym), name_len);
{
struct partial_symbol *psym = start[i];
- if (SYMBOL_DOMAIN (psym) == namespace)
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (psym),
+ SYMBOL_DOMAIN (psym), namespace))
{
int cmp;
struct symbol *sym;
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
- if (SYMBOL_DOMAIN (sym) == domain
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+ SYMBOL_DOMAIN (sym), domain)
&& wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym)))
{
switch (SYMBOL_CLASS (sym))
{
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
- if (SYMBOL_DOMAIN (sym) == domain)
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+ SYMBOL_DOMAIN (sym), domain))
{
int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym), name_len);
if (cmp == 0
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
- if (SYMBOL_DOMAIN (sym) == domain)
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+ SYMBOL_DOMAIN (sym), domain))
{
int cmp;
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
- if (cu->language == language_cplus
- || cu->language == language_java
- || cu->language == language_ada)
- {
- /* For C++ and Java, these implicitly act as typedefs as well. */
- add_psymbol_to_list (actual_name, strlen (actual_name),
- VAR_DOMAIN, LOC_TYPEDEF,
- &objfile->global_psymbols,
- 0, (CORE_ADDR) 0, cu->language, objfile);
- }
break;
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
/* The semantics of C++ state that "struct foo { ... }" also
defines a typedef for "foo". A Java class declaration also
- defines a typedef for the class. Synthesize a typedef symbol
- so that "ptype foo" works as expected. */
+ defines a typedef for the class. */
if (cu->language == language_cplus
|| cu->language == language_java
|| cu->language == language_ada)
{
- struct symbol *typedef_sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct symbol));
- *typedef_sym = *sym;
- SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;
/* The symbol's name is already allocated along with
this objfile, so we don't need to duplicate it for
the type. */
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_SEARCH_NAME (sym);
- add_symbol_to_list (typedef_sym, list_to_add);
}
}
break;
domain, symtab);
}
+int
+symbol_matches_domain (enum language symbol_language,
+ domain_enum symbol_domain,
+ 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_java
+ || symbol_language == language_ada)
+ {
+ if ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN)
+ && symbol_domain == STRUCT_DOMAIN)
+ return 1;
+ }
+ /* For all other languages, strict match is required. */
+ return (symbol_domain == domain);
+}
+
/* Look, in partial_symtab PST, for symbol whose natural name is NAME.
If LINKAGE_NAME is non-NULL, check in addition that the symbol's
linkage name matches it. Check the global symbols if GLOBAL, the
? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0
: SYMBOL_MATCHES_SEARCH_NAME (*top,name)))
{
- if (SYMBOL_DOMAIN (*top) == domain)
- {
- return (*top);
- }
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
+ SYMBOL_DOMAIN (*top), domain))
+ return (*top);
top++;
}
}
{
for (psym = start; psym < start + length; psym++)
{
- if (domain == SYMBOL_DOMAIN (*psym))
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
+ SYMBOL_DOMAIN (*psym), domain))
{
if (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0
sym != NULL;
sym = dict_iter_name_next (name, &iter))
{
- if (SYMBOL_DOMAIN (sym) == domain
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+ SYMBOL_DOMAIN (sym), domain)
&& (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
return sym;
sym != NULL;
sym = dict_iter_name_next (name, &iter))
{
- if (SYMBOL_DOMAIN (sym) == domain
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+ SYMBOL_DOMAIN (sym), domain)
&& (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
{
const char *multiple_symbols_select_mode (void);
+int symbol_matches_domain (enum language symbol_language,
+ domain_enum symbol_domain,
+ domain_enum domain);
+
/* lookup a symbol table by source file name */
extern struct symtab *lookup_symtab (const char *);