* ada-lang.c: Update throughout to use symbol_matches_domain
authorAleksandar Ristovski <aristovski@qnx.com>
Mon, 5 May 2008 14:37:32 +0000 (14:37 +0000)
committerAleksandar Ristovski <aristovski@qnx.com>
Mon, 5 May 2008 14:37:32 +0000 (14:37 +0000)
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.

gdb/ChangeLog
gdb/ada-lang.c
gdb/dwarf2read.c
gdb/symtab.c
gdb/symtab.h

index 0302842cbc0392e1e6ab3e59403b69fd6642e0c4..7474370a8f09e800a36f5b1c3e32bc16ca8ffc4c 100644 (file)
@@ -1,3 +1,19 @@
+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.
index 3508a6264ca4827ee37ff818ba438fdbb8c262c3..8206f943023a3f4b3736e54c8af553cebd795a05 100644 (file)
@@ -4177,7 +4177,8 @@ ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name,
         {
           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;
         }
@@ -4211,7 +4212,8 @@ ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name,
         {
           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);
 
@@ -4254,7 +4256,8 @@ ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name,
         {
           struct partial_symbol *psym = start[i];
 
-          if (SYMBOL_DOMAIN (psym) == namespace)
+          if (symbol_matches_domain (SYMBOL_LANGUAGE (psym),
+                                     SYMBOL_DOMAIN (psym), namespace))
             {
               int cmp;
 
@@ -5254,7 +5257,8 @@ ada_add_block_symbols (struct obstack *obstackp,
       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))
@@ -5284,7 +5288,8 @@ ada_add_block_symbols (struct obstack *obstackp,
     {
       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
@@ -5329,7 +5334,8 @@ ada_add_block_symbols (struct obstack *obstackp,
 
       ALL_BLOCK_SYMBOLS (block, iter, sym)
       {
-        if (SYMBOL_DOMAIN (sym) == domain)
+        if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+                                   SYMBOL_DOMAIN (sym), domain))
           {
             int cmp;
 
index 13571789c1f162f5a2f5e6d593da900df4679f79..4f1cb1e32967d80dca33b6a8b17842a5e2e33121 100644 (file)
@@ -2066,16 +2066,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
                           : &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),
@@ -7565,23 +7555,16 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 
            /* 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;
index 6c16b955b79c5840613b892a4eb99d01aeb7e1c6..3d4389ebf17abd81b605dad259e4c348caffcc8c 100644 (file)
@@ -1650,6 +1650,26 @@ lookup_symbol_global (const char *name,
                                     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
@@ -1714,10 +1734,9 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
                 ? 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++;
        }
     }
@@ -1729,7 +1748,8 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
     {                  
       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
@@ -1914,7 +1934,8 @@ lookup_block_symbol (const struct block *block, const char *name,
           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;
@@ -1935,7 +1956,8 @@ lookup_block_symbol (const struct block *block, const char *name,
           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))
            {
index cfdd2a465ff0f9be7a220a6a6148a47a29857456..ef8cade3a2efc2eec5e9c934c8ee404f25248ebf 100644 (file)
@@ -998,6 +998,10 @@ extern const char multiple_symbols_cancel[];
 
 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 *);