* Makefile.am (libbfd_la_LIBADD): Add @WIN32LIBADD@.
[deliverable/binutils-gdb.git] / gdb / symtab.c
index 61bbe28b50cfcf09c447b291eb7428babe81411f..422a67e79550bda1acc40e32e26e0f71ef9f905e 100644 (file)
@@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "expression.h"
 #include "language.h"
 #include "demangle.h"
+#include "inferior.h"
 
 #include "obstack.h"
 
@@ -86,12 +87,18 @@ static struct partial_symbol *
 lookup_partial_symbol PARAMS ((struct partial_symtab *, const char *,
                               int, namespace_enum));
 
+static struct partial_symbol *
+fixup_psymbol_section PARAMS ((struct partial_symbol *, struct objfile *));
+
 static struct symtab *
 lookup_symtab_1 PARAMS ((char *));
 
 static void
 cplusplus_hint PARAMS ((char *));
 
+static struct symbol *
+find_active_alias PARAMS ((struct symbol *sym, CORE_ADDR addr));
+
 /* */
 
 /* The single non-language-specific builtin type */
@@ -305,12 +312,11 @@ gdb_mangle_name (type, i, j)
   if (len == 0)
     {
       sprintf (buf, "__%s%s", const_prefix, volatile_prefix);
-      if (strcmp(buf, "__") == 0)
-       buf[0] = '\0';
     }
-  else if (newname != NULL && strchr (newname, '<') != NULL)
+  else if (physname[0] == 't' || physname[0] == 'Q')
     {
-      /* Template methods are fully mangled.  */
+      /* The physname for template and qualified methods already includes
+        the class name.  */
       sprintf (buf, "__%s%s", const_prefix, volatile_prefix);
       newname = NULL;
       len = 0;
@@ -359,12 +365,6 @@ gdb_mangle_name (type, i, j)
 
 \f
 
-struct symbol         * fixup_symbol_section  PARAMS ((struct symbol  *,
-                                                      struct objfile *));
-struct partial_symbol * fixup_psymbol_section PARAMS ((struct partial_symbol *,
-                                                      struct objfile *));
-
-
 /* Find which partial symtab on contains PC and SECTION.  Return 0 if none.  */
 
 struct partial_symtab *
@@ -523,8 +523,6 @@ fixup_symbol_section (sym, objfile)
      struct symbol *sym;
      struct objfile *objfile;
 {
-  struct minimal_symbol *msym;
-
   if (!sym)
     return NULL;
 
@@ -536,13 +534,11 @@ fixup_symbol_section (sym, objfile)
   return sym;
 }
 
-struct partial_symbol *
+static struct partial_symbol *
 fixup_psymbol_section (psym, objfile)
      struct partial_symbol *psym;
      struct objfile *objfile;
 {
-  struct minimal_symbol *msym;
-
   if (!psym)
     return NULL;
 
@@ -1024,6 +1020,15 @@ lookup_block_symbol (block, name, namespace)
          if (SYMBOL_NAMESPACE (sym) == namespace &&
              SYMBOL_MATCHES_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
+                PC, then use the main symbol.
+
+                ?!? Is checking the current pc correct?  Is this routine
+                ever called to look up a symbol from another context?  */
+              if (SYMBOL_ALIASES (sym))
+                sym = find_active_alias (sym, read_pc ());
+
              sym_found = sym;
              if (SYMBOL_CLASS (sym) != LOC_ARG &&
                  SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
@@ -1041,6 +1046,39 @@ lookup_block_symbol (block, name, namespace)
   return (sym_found);          /* Will be NULL if not found. */
 }
 
+/* Given a main symbol SYM and ADDR, search through the alias
+   list to determine if an alias is active at ADDR and return
+   the active alias.
+
+   If no alias is active, then return SYM.  */
+
+static struct symbol *
+find_active_alias (sym, addr)
+  struct symbol *sym;
+  CORE_ADDR addr;
+{
+  struct range_list *r;
+  struct alias_list *aliases;
+
+  /* If we have aliases, check them first.  */
+  aliases = SYMBOL_ALIASES (sym);
+
+  while (aliases)
+    {
+      if (!SYMBOL_RANGES (aliases->sym))
+        return aliases->sym;
+      for (r = SYMBOL_RANGES (aliases->sym); r; r = r->next)
+       {
+         if (r->start <= addr && r->end > addr)
+           return aliases->sym;
+       }
+      aliases = aliases->next;
+    }
+
+  /* Nothing found, return the main symbol.  */
+  return sym;
+}
+
 \f
 /* Return the symbol for the function which contains a specified
    lexical block, described by a struct block BL.  */
@@ -1069,7 +1107,7 @@ find_pc_sect_symtab (pc, section)
   register struct symtab *best_s = NULL;
   register struct partial_symtab *ps;
   register struct objfile *objfile;
-  int distance = 0;
+  CORE_ADDR distance = 0;
 
   /* Search all symtabs for the one whose file contains our address, and which
      is the smallest of all the ones containing the address.  This is designed
@@ -1299,6 +1337,9 @@ find_pc_sect_line (pc, section, notcurrent)
   s = find_pc_sect_symtab (pc, section);
   if (!s)
     {
+      /* if no symbol information, return previous pc */
+      if (notcurrent)
+       pc++;
       val.pc = pc;
       return val;
     }
@@ -2086,15 +2127,25 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
        }
       if (p[0] == ':' || p[0] == ' ' || p[0] == '\t')
        break;
+      if (p[0] == '.' && strchr (p, ':') == NULL) /* Java qualified method. */
+       {
+         /* Find the *last* '.', since the others are package qualifiers. */
+         for (p1 = p;  *p1;  p1++)
+           {
+             if (*p1 == '.')
+               p = p1;
+           }
+         break;
+       }
     }
   while (p[0] == ' ' || p[0] == '\t') p++;
 
-  if ((p[0] == ':') && !has_parens)
+  if ((p[0] == ':' || p[0] == '.') && !has_parens)
     {
 
-      /*  C++  */
+      /*  C++ or Java */
       if (is_quoted) *argptr = *argptr+1;
-      if (p[1] ==':')
+      if (p[0] == '.' || p[1] ==':')
        {
          /* Extract the class name.  */
          p1 = p;
@@ -2104,7 +2155,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
          copy[p - *argptr] = 0;
 
          /* Discard the class name from the arg.  */
-         p = p1 + 2;
+         p = p1 + (p1[0] == ':' ? 2 : 1);
          while (*p == ' ' || *p == '\t') p++;
          *argptr = p;
 
@@ -3498,7 +3549,7 @@ are listed.");
   add_info ("sources", sources_info,
            "Source files in the program.");
 
-  add_com ("rbreak", no_class, rbreak_command,
+  add_com ("rbreak", class_breakpoint, rbreak_command,
            "Set a breakpoint for all functions matching REGEXP.");
 
   /* Initialize the one built-in type that isn't language dependent... */
This page took 0.031354 seconds and 4 git commands to generate.