2003-03-27 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / symtab.c
index f3f55e12d164bdcfd3b4192ddb1ecd9eff3708b5..173d08a48f9a37519eec82dc6de093033d3319f4 100644 (file)
@@ -76,6 +76,7 @@ static int find_line_common (struct linetable *, int, int *);
 char *operator_chars (char *p, char **end);
 
 static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
+                                                    const char *,
                                                     const char *, int,
                                                     namespace_enum);
 
@@ -1201,7 +1202,8 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name,
   ALL_PSYMTABS (objfile, ps)
   {
     if (!ps->readin
-       && lookup_partial_symbol (ps, name, psymtab_index, namespace))
+       && lookup_partial_symbol (ps, name, mangled_name,
+                                 psymtab_index, namespace))
       {
        s = PSYMTAB_TO_SYMTAB (ps);
        bv = BLOCKVECTOR (s);
@@ -1367,11 +1369,14 @@ lookup_symbol_aux_minsyms (const char *name,
   return NULL;
 }
 
-/* Look, in partial_symtab PST, for symbol NAME.  Check the global
-   symbols if GLOBAL, the static symbols if not */
+/* 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
+   static symbols if not */
 
 static struct partial_symbol *
-lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
+lookup_partial_symbol (struct partial_symtab *pst, const char *name,
+                      const char *linkage_name, int global,
                       namespace_enum namespace)
 {
   struct partial_symbol *temp;
@@ -1423,10 +1428,10 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
       if (!(top == bottom))
        internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
-      /* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
-        we don't have to force a linear search on C++. Probably holds true
-        for JAVA as well, no way to check.*/
-      while (top <= real_top && SYMBOL_MATCHES_NAME (*top,name))
+      while (top <= real_top
+            && (linkage_name != NULL
+                ? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0
+                : SYMBOL_MATCHES_NATURAL_NAME (*top,name)))
        {
          if (SYMBOL_NAMESPACE (*top) == namespace)
            {
@@ -1445,7 +1450,9 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
        {
          if (namespace == SYMBOL_NAMESPACE (*psym))
            {
-             if (SYMBOL_MATCHES_NAME (*psym, name))
+             if (linkage_name != NULL
+                 ? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0
+                 : SYMBOL_MATCHES_NATURAL_NAME (*psym, name))
                {
                  return (*psym);
                }
@@ -1492,7 +1499,8 @@ lookup_transparent_type (const char *name)
 
   ALL_PSYMTABS (objfile, ps)
   {
-    if (!ps->readin && lookup_partial_symbol (ps, name, 1, STRUCT_NAMESPACE))
+    if (!ps->readin && lookup_partial_symbol (ps, name, NULL,
+                                             1, STRUCT_NAMESPACE))
       {
        s = PSYMTAB_TO_SYMTAB (ps);
        bv = BLOCKVECTOR (s);
@@ -1539,7 +1547,7 @@ lookup_transparent_type (const char *name)
 
   ALL_PSYMTABS (objfile, ps)
   {
-    if (!ps->readin && lookup_partial_symbol (ps, name, 0, STRUCT_NAMESPACE))
+    if (!ps->readin && lookup_partial_symbol (ps, name, NULL, 0, STRUCT_NAMESPACE))
       {
        s = PSYMTAB_TO_SYMTAB (ps);
        bv = BLOCKVECTOR (s);
@@ -1580,7 +1588,7 @@ find_main_psymtab (void)
 
   ALL_PSYMTABS (objfile, pst)
   {
-    if (lookup_partial_symbol (pst, main_name (), 1, VAR_NAMESPACE))
+    if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_NAMESPACE))
       {
        return (pst);
       }
@@ -1623,7 +1631,7 @@ lookup_block_symbol (register const struct block *block, const char *name,
          if (SYMBOL_NAMESPACE (sym) == namespace 
              && (mangled_name
                  ? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
-                 : SYMBOL_MATCHES_NAME (sym, name)))
+                 : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
            return sym;
        }
       return NULL;
@@ -1693,7 +1701,7 @@ lookup_block_symbol (register const struct block *block, const char *name,
          if (SYMBOL_NAMESPACE (sym) == namespace
              && (mangled_name
                  ? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
-                 : SYMBOL_MATCHES_NAME (sym, name)))
+                 : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
            {
              return sym;
            }
@@ -1728,7 +1736,7 @@ lookup_block_symbol (register const struct block *block, const char *name,
          if (SYMBOL_NAMESPACE (sym) == namespace
              && (mangled_name
                  ? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
-                 : SYMBOL_MATCHES_NAME (sym, name)))
+                 : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
            {
              /* If SYM has aliases, then use any alias that is active
                 at the current PC.  If no alias is active at the current
@@ -2931,7 +2939,8 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
            /* If it would match (logic taken from loop below)
               load the file and go on to the next one */
            if (file_matches (ps->filename, files, nfiles)
-               && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (*psym))
+               && ((regexp == NULL
+                    || re_exec (SYMBOL_NATURAL_NAME (*psym)) != 0)
                    && ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
                         && SYMBOL_CLASS (*psym) != LOC_BLOCK)
                        || (kind == FUNCTIONS_NAMESPACE && SYMBOL_CLASS (*psym) == LOC_BLOCK)
@@ -2968,7 +2977,8 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
            MSYMBOL_TYPE (msymbol) == ourtype3 ||
            MSYMBOL_TYPE (msymbol) == ourtype4)
          {
-           if (regexp == NULL || SYMBOL_MATCHES_REGEXP (msymbol))
+           if (regexp == NULL
+               || re_exec (SYMBOL_NATURAL_NAME (msymbol)) != 0)
              {
                if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)))
                  {
@@ -3008,7 +3018,8 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
            {
              QUIT;
              if (file_matches (s->filename, files, nfiles)
-                 && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
+                 && ((regexp == NULL
+                      || re_exec (SYMBOL_NATURAL_NAME (sym)) != 0)
                      && ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (sym) != LOC_TYPEDEF
                           && SYMBOL_CLASS (sym) != LOC_BLOCK
                           && SYMBOL_CLASS (sym) != LOC_CONST)
@@ -3062,7 +3073,8 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
            MSYMBOL_TYPE (msymbol) == ourtype3 ||
            MSYMBOL_TYPE (msymbol) == ourtype4)
          {
-           if (regexp == NULL || SYMBOL_MATCHES_REGEXP (msymbol))
+           if (regexp == NULL
+               || re_exec (SYMBOL_NATURAL_NAME (msymbol)) != 0)
              {
                /* Functions:  Look up by address. */
                if (kind != FUNCTIONS_NAMESPACE ||
@@ -4026,8 +4038,10 @@ make_symbol_overload_list (struct symbol *fsym)
     if (ps->readin)
       continue;
 
-    if ((lookup_partial_symbol (ps, oload_name, 1, VAR_NAMESPACE) != NULL)
-       || (lookup_partial_symbol (ps, oload_name, 0, VAR_NAMESPACE) != NULL))
+    if ((lookup_partial_symbol (ps, oload_name, NULL, 1, VAR_NAMESPACE)
+        != NULL)
+       || (lookup_partial_symbol (ps, oload_name, NULL, 0, VAR_NAMESPACE)
+           != NULL))
       PSYMTAB_TO_SYMTAB (ps);
   }
 
This page took 0.042501 seconds and 4 git commands to generate.