]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2002-10-28 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Tue, 29 Oct 2002 01:07:47 +0000 (01:07 +0000)
committerDavid Carlton <carlton@bactrian.org>
Tue, 29 Oct 2002 01:07:47 +0000 (01:07 +0000)
* linespec.c (dl1_initialize_defaults): New function.
(dl1_indirect): Ditto.
(dl1_set_flags): Ditto.
(dl1_locate_first_half): Ditto.
(decode_line_1): Call the above functions.
* symtab.c (lookup_symbol_aux_minsyms): Add block_index argument,
and delete is_a_field_of_this argument.
(lookup_symbol_aux_nonlocal): Add call to
lookup_symbol_aux_minsyms, and expand HP comment.
(lookup_symbol_aux): Delete calls to lookup_symbol_aux_minsyms.
Expand on comment before lookup_transparent_type.

gdb/ChangeLog
gdb/ada-lang.c
gdb/c-valprint.c
gdb/linespec.c
gdb/objc-lang.c
gdb/p-valprint.c
gdb/symtab.c

index bb524bd9e2c2faba45f18167dc9cb166755cc7c0..80bdff7dea974a3c40725f7e1d6c3af344a8b942 100644 (file)
@@ -1,3 +1,25 @@
+2002-10-28  David Carlton  <carlton@math.stanford.edu>
+
+       * linespec.c (dl1_initialize_defaults): New function.
+       (dl1_indirect): Ditto.
+       (dl1_set_flags): Ditto.
+       (dl1_locate_first_half): Ditto.
+       (decode_line_1): Call the above functions.
+       * symtab.c (lookup_symbol_aux_minsyms): Add block_index argument,
+       and delete is_a_field_of_this argument.
+       (lookup_symbol_aux_nonlocal): Add call to
+       lookup_symbol_aux_minsyms, and expand HP comment.
+       (lookup_symbol_aux): Delete calls to lookup_symbol_aux_minsyms.
+       Expand on comment before lookup_transparent_type.
+
+2002-10-25  David Carlton  <carlton@math.stanford.edu>
+
+       * ada-lang.c (standard_lookup): Set last argument to lookup_symbol
+       to NULL.
+       * p-valprint.c (pascal_val_print): Ditto.
+       * objc-lang.c (find_imps): Ditto.
+       * c-valprint.c (c_val_print): Ditto.
+
 2002-10-25  David Carlton  <carlton@math.stanford.edu>
 
        * symtab.c (lookup_symbol_aux_block): New function.
index bb3060fc53b1a343efab464c6e30e758f50991d8..2843aeb93da2a6a8021908080cb87496b1d0ac31 100644 (file)
@@ -3180,8 +3180,8 @@ static struct symbol *
 standard_lookup (const char *name, namespace_enum namespace)
 {
   struct symbol *sym;
-  struct symtab *symtab;
-  sym = lookup_symbol (name, (struct block *) NULL, namespace, 0, &symtab);
+
+  sym = lookup_symbol (name, (struct block *) NULL, namespace, 0, NULL);
   return sym;
 }
 
index 925d9c5469c5f12142438f3f0628b5626505338f..1098cab585dd95c2431e08462fbf16792c150d65 100644 (file)
@@ -213,13 +213,12 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
                  struct value *vt_val;
                  struct symbol *wsym = (struct symbol *) NULL;
                  struct type *wtype;
-                 struct symtab *s;
                  struct block *block = (struct block *) NULL;
                  int is_this_fld;
 
                  if (msymbol != NULL)
                    wsym = lookup_symbol (SYMBOL_NAME (msymbol), block,
-                                         VAR_NAMESPACE, &is_this_fld, &s);
+                                         VAR_NAMESPACE, &is_this_fld, NULL);
 
                  if (wsym)
                    {
index 3d0ed5441d0efa2599a3190bc2ca2e785c427650..b506d693119e966aa362c368f8b95ce7860d8e1d 100644 (file)
@@ -54,6 +54,16 @@ static char *find_toplevel_char (char *s, char c);
 static struct symtabs_and_lines decode_line_2 (struct symbol *[],
                                               int, int, char ***);
 
+static void dl1_initialize_defaults (struct symtab **default_symtab,
+                                    int *default_line);
+
+static struct symtabs_and_lines dl1_indirect (char **argptr);
+
+static void dl1_set_flags (char **argptr, int *is_quoted,
+                          char **paren_pointer);
+
+static char *dl1_locate_first_half (char **argptr, int *is_quote_enclosed);
+
 /* Helper functions. */
 
 /* Issue a helpful hint on using the command completion feature on
@@ -512,185 +522,51 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
   struct symtabs_and_lines values;
   struct symtab_and_line val;
   register char *p, *p1;
-  char *q, *pp, *ii, *p2;
-#if 0
-  char *q1;
-#endif
-  register struct symtab *s;
+  char *q, *ii, *p2;
+  /* This is NULL if there are no parens in argptr, or a pointer to
+     the closing parenthesis if there are parens.  */
+  char *paren_pointer;
+  register struct symtab *s = NULL;
 
   register struct symbol *sym;
   /* The symtab that SYM was found in.  */
   struct symtab *sym_symtab;
 
-  register CORE_ADDR pc;
   register struct minimal_symbol *msymbol;
   char *copy;
   struct symbol *sym_class;
   int i1;
   int is_quoted;
   int is_quote_enclosed;
-  int has_parens;
-  int has_if = 0;
-  int has_comma = 0;
   struct symbol **sym_arr;
   struct type *t;
   char *saved_arg = *argptr;
-  extern char *gdb_completer_quote_characters;
 
   init_sal (&val);             /* initialize to zeroes */
 
   /* Defaults have defaults.  */
 
-  if (default_symtab == 0)
-    {
-      /* Use whatever we have for the default source line.  We don't use
-         get_current_or_default_symtab_and_line as it can recurse and call
-        us back! */
-      struct symtab_and_line cursal = 
-                       get_current_source_symtab_and_line ();
-      
-      default_symtab = cursal.symtab;
-      default_line = cursal.line;
-    }
-
+  dl1_initialize_defaults (&default_symtab, &default_line);
+  
   /* See if arg is *PC */
 
   if (**argptr == '*')
-    {
-      (*argptr)++;
-      pc = parse_and_eval_address_1 (argptr);
-
-      values.sals = (struct symtab_and_line *)
-       xmalloc (sizeof (struct symtab_and_line));
-
-      values.nelts = 1;
-      values.sals[0] = find_pc_line (pc, 0);
-      values.sals[0].pc = pc;
-      values.sals[0].section = find_pc_overlay (pc);
-
-      return values;
-    }
-
-  /* 'has_if' is for the syntax:
-   *     (gdb) break foo if (a==b)
-   */
-  if ((ii = strstr (*argptr, " if ")) != NULL ||
-      (ii = strstr (*argptr, "\tif ")) != NULL ||
-      (ii = strstr (*argptr, " if\t")) != NULL ||
-      (ii = strstr (*argptr, "\tif\t")) != NULL ||
-      (ii = strstr (*argptr, " if(")) != NULL ||
-      (ii = strstr (*argptr, "\tif( ")) != NULL)
-    has_if = 1;
-  /* Temporarily zap out "if (condition)" to not
-   * confuse the parenthesis-checking code below.
-   * This is undone below. Do not change ii!!
-   */
-  if (has_if)
-    {
-      *ii = '\0';
-    }
+    return dl1_indirect (argptr);
 
   /* Set various flags.
-   * 'has_parens' is important for overload checking, where
+   * 'paren_pointer' is important for overload checking, where
    * we allow things like: 
    *     (gdb) break c::f(int)
    */
 
-  /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
-
-  is_quoted = (**argptr
-              && strchr (get_gdb_completer_quote_characters (),
-                         **argptr) != NULL);
+  dl1_set_flags (argptr, &is_quoted, &paren_pointer);
 
-  has_parens = ((pp = strchr (*argptr, '(')) != NULL
-               && (pp = strrchr (pp, ')')) != NULL);
+  /* Locate the first half of the linespec, ending in a colon, period,
+     or whitespace.  (More or less.)  */
 
-  /* Now that we're safely past the has_parens check,
-   * put back " if (condition)" so outer layers can see it 
-   */
-  if (has_if)
-    *ii = ' ';
-
-  /* Maybe we were called with a line range FILENAME:LINENUM,FILENAME:LINENUM
-     and we must isolate the first half.  Outer layers will call again later
-     for the second half.
-
-     Don't count commas that appear in argument lists of overloaded
-     functions, or in quoted strings.  It's stupid to go to this much
-     trouble when the rest of the function is such an obvious roach hotel.  */
-  ii = find_toplevel_char (*argptr, ',');
-  has_comma = (ii != 0);
+  p = dl1_locate_first_half (argptr, &is_quote_enclosed);
 
-  /* Temporarily zap out second half to not
-   * confuse the code below.
-   * This is undone below. Do not change ii!!
-   */
-  if (has_comma)
-    {
-      *ii = '\0';
-    }
-
-  /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
-  /* May also be CLASS::MEMBER, or NAMESPACE::NAME */
-  /* Look for ':', but ignore inside of <> */
-
-  s = NULL;
-  p = *argptr;
-  if (p[0] == '"')
-    {
-      is_quote_enclosed = 1;
-      (*argptr)++;
-      p++;
-    }
-  else
-    is_quote_enclosed = 0;
-  for (; *p; p++)
-    {
-      if (p[0] == '<')
-       {
-         char *temp_end = find_template_name_end (p);
-         if (!temp_end)
-           error ("malformed template specification in command");
-         p = temp_end;
-       }
-      /* Check for the end of the first half of the linespec.  End of line,
-         a tab, a double colon or the last single colon, or a space.  But
-         if enclosed in double quotes we do not break on enclosed spaces */
-      if (!*p
-         || p[0] == '\t'
-         || ((p[0] == ':')
-             && ((p[1] == ':') || (strchr (p + 1, ':') == NULL)))
-         || ((p[0] == ' ') && !is_quote_enclosed))
-       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 the closing double quote was left at the end, remove it */
-  if (is_quote_enclosed)
-    {
-      char *closing_quote = strchr (p - 1, '"');
-      if (closing_quote && closing_quote[1] == '\0')
-       *closing_quote = '\0';
-    }
-
-  /* Now that we've safely parsed the first half,
-   * put back ',' so outer layers can see it 
-   */
-  if (has_comma)
-    *ii = ',';
-
-  if ((p[0] == ':' || p[0] == '.') && !has_parens)
+  if ((p[0] == ':' || p[0] == '.') && paren_pointer == NULL)
     {
       /*  C++ */
       /*  ... or Java */
@@ -767,36 +643,16 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
                      while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':')
                        p++;
                    }
-/*
-   q = operator_chars (*argptr, &q1);
-   if (q1 - q)
-   {
-   char *opname;
-   char *tmp = alloca (q1 - q + 1);
-   memcpy (tmp, q, q1 - q);
-   tmp[q1 - q] = '\0';
-   opname = cplus_mangle_opname (tmp, DMGL_ANSI);
-   if (opname == NULL)
-   {
-   cplusplus_error (saved_arg, "no mangling for \"%s\"\n", tmp);
-   }
-   copy = (char*) alloca (3 + strlen(opname));
-   sprintf (copy, "__%s", opname);
-   p = q1;
-   }
-   else
- */
-                 {
-                   copy = (char *) alloca (p - *argptr + 1);
-                   memcpy (copy, *argptr, p - *argptr);
-                   copy[p - *argptr] = '\0';
-                   if (p != *argptr
-                       && copy[p - *argptr - 1]
-                       && strchr (get_gdb_completer_quote_characters (),
-                                  copy[p - *argptr - 1]) != NULL)
-                     copy[p - *argptr - 1] = '\0';
-                 }
 
+                 copy = (char *) alloca (p - *argptr + 1);
+                 memcpy (copy, *argptr, p - *argptr);
+                 copy[p - *argptr] = '\0';
+                 if (p != *argptr
+                     && copy[p - *argptr - 1]
+                     && strchr (get_gdb_completer_quote_characters (),
+                                copy[p - *argptr - 1]) != NULL)
+                   copy[p - *argptr - 1] = '\0';
+                 
                  /* no line number may be specified */
                  while (*p == ' ' || *p == '\t')
                    p++;
@@ -960,43 +816,6 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
        p++;
       *argptr = p;
     }
-#if 0
-  /* No one really seems to know why this was added. It certainly
-     breaks the command line, though, whenever the passed
-     name is of the form ClassName::Method. This bit of code
-     singles out the class name, and if funfirstline is set (for
-     example, you are setting a breakpoint at this function),
-     you get an error. This did not occur with earlier
-     verions, so I am ifdef'ing this out. 3/29/99 */
-  else
-    {
-      /* Check if what we have till now is a symbol name */
-
-      /* We may be looking at a template instantiation such
-         as "foo<int>".  Check here whether we know about it,
-         instead of falling through to the code below which
-         handles ordinary function names, because that code
-         doesn't like seeing '<' and '>' in a name -- the
-         skip_quoted call doesn't go past them.  So see if we
-         can figure it out right now. */
-
-      copy = (char *) alloca (p - *argptr + 1);
-      memcpy (copy, *argptr, p - *argptr);
-      copy[p - *argptr] = '\000';
-      sym = lookup_symbol (copy, 0, VAR_NAMESPACE, 0, &sym_symtab);
-      if (sym)
-       {
-         /* Yes, we have a symbol; jump to symbol processing */
-         /* Code after symbol_found expects S, SYM_SYMTAB, SYM, 
-            and COPY to be set correctly */
-         *argptr = (*p == '\'') ? p + 1 : p;
-         s = (struct symtab *) 0;
-         goto symbol_found;
-       }
-      /* Otherwise fall out from here and go to file/line spec
-         processing, etc. */
-    }
-#endif
 
   /* S is specified file's symtab, or 0 if no file specified.
      arg no longer contains the file name.  */
@@ -1098,9 +917,9 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
       if (p[-1] != '\'')
        error ("Unmatched single quote.");
     }
-  else if (has_parens)
+  else if (paren_pointer != NULL)
     {
-      p = pp + 1;
+      p = paren_pointer + 1;
     }
   else
     {
@@ -1278,3 +1097,184 @@ minimal_symbol_found:           /* We also jump here from the case for variables
   error ("Function \"%s\" not defined.", copy);
   return values;               /* for lint */
 }
+
+/* Now come a bunch of helper functions for decode_line_1.  */
+
+/* Defaults have defaults.  */
+
+static void
+dl1_initialize_defaults (struct symtab **default_symtab, int *default_line)
+{
+  if (*default_symtab == NULL)
+    {
+      /* Use whatever we have for the default source line.  We don't use
+         get_current_or_default_symtab_and_line as it can recurse and call
+        us back! */
+      struct symtab_and_line cursal
+       = get_current_source_symtab_and_line ();
+      
+      *default_symtab = cursal.symtab;
+      *default_line = cursal.line;
+    }
+}
+
+/* See if arg is *PC */
+
+static struct symtabs_and_lines
+dl1_indirect (char **argptr)
+{
+  struct symtabs_and_lines values;
+  CORE_ADDR pc;
+
+  (*argptr)++;
+  pc = parse_and_eval_address_1 (argptr);
+
+  values.sals = (struct symtab_and_line *)
+    xmalloc (sizeof (struct symtab_and_line));
+
+  values.nelts = 1;
+  values.sals[0] = find_pc_line (pc, 0);
+  values.sals[0].pc = pc;
+  values.sals[0].section = find_pc_overlay (pc);
+
+  return values;
+}
+
+static void
+dl1_set_flags (char **argptr, int *is_quoted, char **paren_pointer)
+{
+  char *ii;
+  int has_if = 0;
+  
+  /* 'has_if' is for the syntax:
+   *     (gdb) break foo if (a==b)
+   */
+  if ((ii = strstr (*argptr, " if ")) != NULL ||
+      (ii = strstr (*argptr, "\tif ")) != NULL ||
+      (ii = strstr (*argptr, " if\t")) != NULL ||
+      (ii = strstr (*argptr, "\tif\t")) != NULL ||
+      (ii = strstr (*argptr, " if(")) != NULL ||
+      (ii = strstr (*argptr, "\tif( ")) != NULL)
+    has_if = 1;
+  /* Temporarily zap out "if (condition)" to not
+   * confuse the parenthesis-checking code below.
+   * This is undone below. Do not change ii!!
+   */
+  if (has_if)
+    {
+      *ii = '\0';
+    }
+
+  /* Set various flags.
+   * 'paren_pointer' is important for overload checking, where
+   * we allow things like: 
+   *     (gdb) break c::f(int)
+   */
+
+  /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
+
+  *is_quoted = (**argptr
+               && strchr (get_gdb_completer_quote_characters (),
+                          **argptr) != NULL);
+
+  *paren_pointer = strchr (*argptr, '(');
+
+  if (*paren_pointer != NULL)
+    *paren_pointer = strrchr (*paren_pointer, ')');
+
+  /* Now that we're safely past the has_parens check,
+   * put back " if (condition)" so outer layers can see it 
+   */
+  if (has_if)
+    *ii = ' ';
+}
+
+static char *
+dl1_locate_first_half (char **argptr, int *is_quote_enclosed)
+{
+  char *ii;
+  char *p, *p1;
+  int has_comma;
+
+  /* Maybe we were called with a line range
+     FILENAME:LINENUM,FILENAME:LINENUM and we must isolate the first
+     half.  Outer layers will call again later for the second half.
+
+     Don't count commas that appear in argument lists of overloaded
+     functions, or in quoted strings.  It's stupid to go to this much
+     trouble when the rest of the function is such an obvious roach
+     hotel.  */
+  
+  ii = find_toplevel_char (*argptr, ',');
+  has_comma = (ii != 0);
+
+  /* Temporarily zap out second half to not
+   * confuse the code below.
+   * This is undone below. Do not change ii!!
+   */
+  if (has_comma)
+    {
+      *ii = '\0';
+    }
+
+  /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
+  /* May also be CLASS::MEMBER, or NAMESPACE::NAME */
+  /* Look for ':', but ignore inside of <> */
+
+  p = *argptr;
+  if (p[0] == '"')
+    {
+      *is_quote_enclosed = 1;
+      (*argptr)++;
+      p++;
+    }
+  else
+    *is_quote_enclosed = 0;
+  for (; *p; p++)
+    {
+      if (p[0] == '<')
+       {
+         char *temp_end = find_template_name_end (p);
+         if (!temp_end)
+           error ("malformed template specification in command");
+         p = temp_end;
+       }
+      /* Check for the end of the first half of the linespec.  End of line,
+         a tab, a double colon or the last single colon, or a space.  But
+         if enclosed in double quotes we do not break on enclosed spaces */
+      if (!*p
+         || p[0] == '\t'
+         || ((p[0] == ':')
+             && ((p[1] == ':') || (strchr (p + 1, ':') == NULL)))
+         || ((p[0] == ' ') && !*is_quote_enclosed))
+       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 the closing double quote was left at the end, remove it */
+  if (*is_quote_enclosed)
+    {
+      char *closing_quote = strchr (p - 1, '"');
+      if (closing_quote && closing_quote[1] == '\0')
+       *closing_quote = '\0';
+    }
+
+  /* Now that we've safely parsed the first half,
+   * put back ',' so outer layers can see it 
+   */
+  if (has_comma)
+    *ii = ',';
+
+  return p;
+}
index 17bc66f519d4c73a4cb550b0c1cb000eae9ba3be..3234d10a69a70a0190c900b69ab57d398f327655 100644 (file)
@@ -1436,8 +1436,6 @@ char *find_imps (struct symtab *symtab, struct block *block,
   tmp = parse_method (buf, &type, &class, &category, &selector);
 
   if (tmp == NULL) {
-    
-    struct symtab *sym_symtab = NULL;
     struct symbol *sym = NULL;
     struct minimal_symbol *msym = NULL;
     
@@ -1447,7 +1445,7 @@ char *find_imps (struct symtab *symtab, struct block *block,
     if (tmp == NULL)
       return NULL;
     
-    sym = lookup_symbol (selector, block, VAR_NAMESPACE, 0, &sym_symtab);
+    sym = lookup_symbol (selector, block, VAR_NAMESPACE, 0, NULL);
     if (sym != NULL) 
       {
        if (syms)
index a99d4e989723de67e9aeb3c0e0d36fddc706219f..5f32ea52febd3ce54d6f430e3f31f8416557144f 100644 (file)
@@ -221,13 +221,12 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
                  struct value *vt_val;
                  struct symbol *wsym = (struct symbol *) NULL;
                  struct type *wtype;
-                 struct symtab *s;
                  struct block *block = (struct block *) NULL;
                  int is_this_fld;
 
                  if (msymbol != NULL)
                    wsym = lookup_symbol (SYMBOL_NAME (msymbol), block,
-                                         VAR_NAMESPACE, &is_this_fld, &s);
+                                         VAR_NAMESPACE, &is_this_fld, NULL);
 
                  if (wsym)
                    {
index c892462c1b93970fa7bdefdef58fb80c0668c3d2..1ee2d0c6a32972389ab4314e7c5f2e44f93ebc68 100644 (file)
@@ -139,10 +139,10 @@ struct symbol *lookup_symbol_aux_using_loop (const char *prefix,
                                             struct symtab **symtab);
 
 static
-struct symbol *lookup_symbol_aux_minsyms (const char *name,
+struct symbol *lookup_symbol_aux_minsyms (int block_index,
+                                         const char *name,
                                          const char *mangled_name,
                                          const namespace_enum namespace,
-                                         int *is_a_field_of_this,
                                          struct symtab **symtab);
 
 
@@ -862,10 +862,11 @@ lookup_symbol_aux (const char *name, const char *mangled_name,
        return sym;
     }
 
-  /* Now search all global blocks.  Do the symtab's first, then
-     check the psymtab's. If a psymtab indicates the existence
-     of the desired name as a global, then do psymtab-to-symtab
-     conversion on the fly and return the found symbol.
+  /* Now search all global blocks.  Do the symtab's first, then the
+     minsyms, then check the psymtab's. If minsyms or psymtabs
+     indicate the existence of the desired name as a global, then
+     generate the appropriate symtab on the fly and return the found
+     symbol.
 
      We do this from within lookup_symbol_aux_using: that will apply
      appropriate using directives in the C++ case.  But it works fine
@@ -873,67 +874,28 @@ lookup_symbol_aux (const char *name, const char *mangled_name,
 
   /* NOTE: carlton/2002-10-22: Is it worthwhile to try to figure out
      whether or not we're in the C++ case?  Doing
-     lookup_symbol_aux_using won't slow things down much at all in the
-     general case, though: other parts of this function are much, much
-     more expensive.  */
+     lookup_symbol_aux_using won't slow things down significantly in
+     the general case, though: other parts of this function are much,
+     much more expensive.  */
 
   sym = lookup_symbol_aux_using (name, mangled_name, block, namespace,
                                 symtab);
   if (sym != NULL)
     return sym;
 
-#ifndef HPUXHPPA
-
-  /* Check for the possibility of the symbol being a function or a
-     mangled variable that is stored in one of the minimal symbol
-     tables.  Eventually, all global symbols might be resolved in this
-     way.  */
-
-  sym = lookup_symbol_aux_minsyms (name, mangled_name,
-                                  namespace, is_a_field_of_this,
-                                  symtab);
-  if (sym != NULL)
-    return sym;
-
-#endif
-
   /* Now search all static file-level symbols.  Not strictly correct,
-     but more useful than an error.  Do the symtabs first, then check
-     the psymtabs.  If a psymtab indicates the existence of the
-     desired name as a file-level static, then do psymtab-to-symtab
-     conversion on the fly and return the found symbol. */
+     but more useful than an error.  */
+
+  /* FIXME: carlton/2002-10-28: See my FIXME comment in
+     lookup_symbol_aux_minsyms about the possible desirability of
+     having a msymbol_found flag that could cause us to skip the
+     STATIC_BLOCK search.  */
 
   sym = lookup_symbol_aux_nonlocal (STATIC_BLOCK, name, mangled_name,
                                    namespace, symtab);
   if (sym != NULL)
     return sym;
 
-#ifdef HPUXHPPA
-
-  /* Check for the possibility of the symbol being a function or a
-     global variable that is stored in one of the minimal symbol
-     tables.  The "minimal symbol table" is built from linker-supplied
-     info.
-
-     RT: I moved this check to last, after the complete search of the
-     global (p)symtab's and static (p)symtab's. For HP-generated
-     symbol tables, this check was causing a premature exit from
-     lookup_symbol with NULL return, and thus messing up symbol
-     lookups of things like "c::f". It seems to me a check of the
-     minimal symbol table ought to be a last resort in any case. I'm
-     vaguely worried about the comment within
-     lookup_symbol_aux_minsyms which talks about FORTRAN routines
-     "foo_" though... is it saying we need to do the "minsym" check
-     before the static check in this case?  */
-
-  sym = lookup_symbol_aux_minsyms (name, mangled_name,
-                                  namespace, is_a_field_of_this,
-                                  symtab);
-  if (sym != NULL)
-    return sym;
-
-#endif
-
   if (symtab != NULL)
     *symtab = NULL;
   return NULL;
@@ -1039,8 +1001,63 @@ lookup_symbol_aux_nonlocal (int block_index,
   if (sym != NULL)
     return sym;
 
-  return lookup_symbol_aux_psymtabs (block_index, name, mangled_name,
-                                    namespace, symtab);
+#ifndef HPUXHPPA
+  sym = lookup_symbol_aux_minsyms (block_index, name, mangled_name,
+                                  namespace, symtab);
+  if (sym != NULL)
+    return sym;
+#endif
+
+  sym = lookup_symbol_aux_psymtabs (block_index, name, mangled_name,
+                                   namespace, symtab);
+  if (sym != NULL)
+    return sym;
+
+#ifdef HPUXHPPA
+
+  /* FIXME: carlton/2002-10-28: The following comment was present in
+     lookup_symbol_aux before I broke it up: at that time, the HP
+     search order for nonlocal stuff was global symtab, global
+     psymtab, static symtab, static psymtab, global and static
+     minsyms.  (The minsyms are stored so that it's just as easy to do
+     global and static searches of them at the same time.)  Now it's
+     global symtab, global psymtab, global minsyms, static symtab,
+     static psymtab, static minsyms.  Also, it's now impossible for a
+     global minsym search to cause a NULL return by itself: if a
+     minsym search returns NULL, then the next search after that is
+     still performed.
+
+     Given that that's the case, I'm pretty sure that my search order
+     is safe; indeed, given that the comment below warns against
+     premature NULL returns, it even seems plausible to me that we can
+     treat HP symbol tables the same as non-HP symbol tables.  It
+     would be great if somebody who has access to HP machines (or,
+     even better, who understands the reason behind the HP special
+     case in the first place) could check on this.
+
+     But there's still the comment about "foo_" symbols in
+     lookup_symbol_aux_minsyms which I really don't understand, sigh.
+     _Should_ a minsym lookup sometimes be able to force a NULL return
+     from lookup_symbol?  */
+
+  /* RT: I moved this check to last, after the complete search of the
+     global (p)symtab's and static (p)symtab's. For HP-generated
+     symbol tables, this check was causing a premature exit from
+     lookup_symbol with NULL return, and thus messing up symbol
+     lookups of things like "c::f". It seems to me a check of the
+     minimal symbol table ought to be a last resort in any case. I'm
+     vaguely worried about the comment within
+     lookup_symbol_aux_minsyms which talks about FORTRAN routines
+     "foo_" though... is it saying we need to do the "minsym" check
+     before the static check in this case?  */
+
+  sym = lookup_symbol_aux_minsyms (block_index, name, mangled_name,
+                                  namespace, symtab);
+  if (sym != NULL)
+    return sym;
+#endif
+
+  return NULL;
 }
 
 /* Check to see if the symbol is defined in one of the symtabs.
@@ -1270,10 +1287,9 @@ lookup_symbol_aux_using_loop (const char *prefix,
    way.  */
 
 static struct symbol *
-lookup_symbol_aux_minsyms (const char *name,
+lookup_symbol_aux_minsyms (int block_index, const char *name,
                           const char *mangled_name,
                           const namespace_enum namespace,
-                          int *is_a_field_of_this,
                           struct symtab **symtab)
 {
   struct symbol *sym;
@@ -1297,7 +1313,30 @@ lookup_symbol_aux_minsyms (const char *name,
             know about demangled names, but we were given a mangled
             name...  */
 
-         /* We first use the address in the msymbol to try to locate
+         /* First, check to see that the symbol looks like it's
+            global or static (depending on what we were asked to look
+            for).  */
+
+         /* NOTE: carlton/2002-10-28: lookup_minimal_symbol gives
+            preference to global symbols over static symbols, so if
+            block_index is STATIC_BLOCK then this might well miss
+            static symbols that are shadowed by global symbols.  But
+            that's okay: this is only called with block_index equal
+            to STATIC_BLOCK if a global search has failed.  */
+
+         switch (MSYMBOL_TYPE (msymbol))
+           {
+           case mst_file_text:
+           case mst_file_data:
+           case mst_file_bss:
+             if (block_index == GLOBAL_BLOCK)
+               return NULL;
+           default:
+             if (block_index == STATIC_BLOCK)
+               return NULL;
+           }
+         
+         /* We next use the address in the msymbol to try to locate
             the appropriate symtab. Note that find_pc_sect_symtab()
             has a side-effect of doing psymtab-to-symtab expansion,
             for the found symtab.  */
@@ -1307,7 +1346,7 @@ lookup_symbol_aux_minsyms (const char *name,
            {
              /* This is a function which has a symtab for its address.  */
              bv = BLOCKVECTOR (s);
-             block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+             block = BLOCKVECTOR_BLOCK (bv, block_index);
 
              /* This call used to pass `SYMBOL_NAME (msymbol)' as the
                 `name' argument to lookup_block_symbol.  But the name
@@ -1316,14 +1355,16 @@ lookup_symbol_aux_minsyms (const char *name,
                 unmangled name.  */
              sym =
                lookup_block_symbol (block, name, mangled_name, namespace);
-             /* We kept static functions in minimal symbol table as well as
-                in static scope. We want to find them in the symbol table. */
-             if (!sym)
-               {
-                 block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-                 sym = lookup_block_symbol (block, name,
-                                            mangled_name, namespace);
-               }
+
+             /* FIXME: carlton/2002-10-28: this next comment dates
+                from when this code was part of lookup_symbol_aux, so
+                this return could return NULL from lookup_symbol_aux.
+                Are there really situations where we want a minimal
+                symbol lookup to be able to force a NULL return from
+                lookup_symbol?  If so, maybe the thing to do would be
+                to have lookup_symbol_aux_minsym to set a
+                minsym_found flag, and to have lookup_symbol_aux only
+                do the psymtab search if that flag is zero.  */
 
              /* sym == 0 if symbol was found in the minimal symbol table
                 but not in the symtab.
@@ -1344,13 +1385,15 @@ lookup_symbol_aux_minsyms (const char *name,
            }
          else if (MSYMBOL_TYPE (msymbol) != mst_text
                   && MSYMBOL_TYPE (msymbol) != mst_file_text
-                  && !STREQ (name, SYMBOL_NAME (msymbol)))
+                  && strcmp (name, SYMBOL_NAME (msymbol)) != 0)
            {
              /* This is a mangled variable, look it up by its
                 mangled name.  */
-             return lookup_symbol_aux (SYMBOL_NAME (msymbol), mangled_name,
-                                       NULL, namespace, is_a_field_of_this,
-                                       symtab);
+             return lookup_symbol_aux_nonlocal (block_index,
+                                                SYMBOL_NAME (msymbol),
+                                                mangled_name,
+                                                namespace,
+                                                symtab);
            }
        }
     }
@@ -1456,8 +1499,13 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
 
 /* FIXME: carlton/2002-10-25: This function duplicates too much of
    lookup_symbol_aux's code: it's a maintenance burden.  That should
-   be taken care of.  Or perhaps this function should eventually get
-   removed: it's only called in one place, I believe.  */
+   be taken care of.  Unfortunately, right now there's no clean fix
+   for that.  The obvious thing to do is to put in calls to
+   lookup_symbol_aux_nonlocal; but, if I'm reading its caller, it
+   seems like this is used when there are perhaps multiple definitions
+   for NAME, in which case lookup_symbol_aux_nonlocal might find the
+   wrong one.  Something to keep in mind when we have iterators,
+   though.  */
 
 struct type *
 lookup_transparent_type (const char *name)