diff --git a/gdb/NEWS b/gdb/NEWS
index 6a2cb9b..0b76e43 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -63,6 +63,12 @@ add-auto-load-scripts-directory directory
   even in non-stop mode.  The "auto" mode has been removed, and "off"
   is now the default mode.
 
+* New options
+
+set debug symbol-lookup
+show debug symbol-lookup
+  Control display of debugging info regarding symbol lookup.
+
 * MI changes
 
   ** The -list-thread-groups command outputs an exit-code field for
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 692e177..cbab762 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -516,6 +516,16 @@ cp_lookup_symbol_imports_or_template (const char *scope,
 				      const domain_enum domain)
 {
   struct symbol *function = BLOCK_FUNCTION (block);
+  struct symbol *result;
+
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "cp_lookup_symbol_imports_or_template"
+			  " (%s, %s, %s, %s)\n",
+			  scope, name, host_address_to_string (block),
+			  domain_name (domain));
+    }
 
   if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus)
     {
@@ -524,13 +534,21 @@ cp_lookup_symbol_imports_or_template (const char *scope,
 	{
 	  struct template_symbol *templ 
 	    = (struct template_symbol *) function;
-	  struct symbol *result;
 
 	  result = search_symbol_list (name,
 				       templ->n_template_arguments,
 				       templ->template_arguments);
 	  if (result != NULL)
-	    return result;
+	    {
+	      if (symbol_lookup_debug)
+		{
+		  fprintf_unfiltered (gdb_stdlog,
+				      "cp_lookup_symbol_imports_or_template"
+				      " (...) = %s\n",
+				      host_address_to_string (result));
+		}
+	      return result;
+	    }
 	}
 
       /* Search the template parameters of the function's defining
@@ -547,7 +565,6 @@ cp_lookup_symbol_imports_or_template (const char *scope,
 
 	  while (1)
 	    {
-	      struct symbol *result;
 	      unsigned int prefix_len = cp_entire_prefix_len (name_copy);
 
 	      if (prefix_len == 0)
@@ -570,6 +587,13 @@ cp_lookup_symbol_imports_or_template (const char *scope,
 	      if (result != NULL)
 		{
 		  do_cleanups (cleanups);
+		  if (symbol_lookup_debug)
+		    {
+		      fprintf_unfiltered (gdb_stdlog,
+					  "cp_lookup_symbol_imports_or_template"
+					  " (...) = %s\n",
+					  host_address_to_string (result));
+		    }
 		  return result;
 		}
 	    }
@@ -578,7 +602,15 @@ cp_lookup_symbol_imports_or_template (const char *scope,
 	}
     }
 
-  return cp_lookup_symbol_imports (scope, name, block, domain, 1, 1);
+  result = cp_lookup_symbol_imports (scope, name, block, domain, 1, 1);
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "cp_lookup_symbol_imports_or_template (...) = %s\n",
+			  result != NULL
+			  ? host_address_to_string (result) : "NULL");
+    }
+  return result;
 }
 
  /* Searches for NAME in the current namespace, and by applying
@@ -593,12 +625,28 @@ cp_lookup_symbol_namespace (const char *scope,
                             const domain_enum domain)
 {
   struct symbol *sym;
-  
+
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "cp_lookup_symbol_namespace (%s, %s, %s, %s)\n",
+			  scope, name, host_address_to_string (block),
+			  domain_name (domain));
+    }
+
   /* First, try to find the symbol in the given namespace.  */
   sym = cp_lookup_symbol_in_namespace (scope, name,
 				       block, domain, 1);
   if (sym != NULL)
-    return sym;
+    {
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog,
+			      "cp_lookup_symbol_namespace (...) = %s\n",
+			      host_address_to_string (sym));
+	}
+      return sym;
+    }
 
   /* Search for name in namespaces imported to this and parent
      blocks.  */
@@ -608,11 +656,24 @@ cp_lookup_symbol_namespace (const char *scope,
 				      domain, 0, 1);
 
       if (sym)
-	return sym;
+	{
+	  if (symbol_lookup_debug)
+	    {
+	      fprintf_unfiltered (gdb_stdlog,
+				  "cp_lookup_symbol_namespace (...) = %s\n",
+				  host_address_to_string (sym));
+	    }
+	  return sym;
+	}
 
       block = BLOCK_SUPERBLOCK (block);
     }
 
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "cp_lookup_symbol_namespace (...) = NULL\n");
+    }
   return NULL;
 }
 
@@ -684,13 +745,35 @@ cp_lookup_symbol_nonlocal (const char *name,
   struct symbol *sym;
   const char *scope = block_scope (block);
 
-  sym = lookup_namespace_scope (name, block,
-				domain, scope, 0);
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "cp_lookup_symbol_non_local"
+			  " (%s, %s (scope %s), %s)\n",
+			  name, host_address_to_string (block), scope,
+			  domain_name (domain));
+    }
+
+  sym = lookup_namespace_scope (name, block, domain, scope, 0);
   if (sym != NULL)
-    return sym;
+    {
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog,
+			      "cp_lookup_symbol_nonlocal (...) = %s\n",
+			      host_address_to_string (sym));
+	}
+      return sym;
+    }
 
-  return cp_lookup_symbol_namespace (scope, name,
-				     block, domain);
+  sym = cp_lookup_symbol_namespace (scope, name, block, domain);
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "cp_lookup_symbol_nonlocal (...) = %s\n",
+			  sym != NULL ? host_address_to_string (sym) : "NULL");
+    }
+  return sym;
 }
 
 /* Search through the base classes of PARENT_TYPE for a base class
@@ -798,6 +881,16 @@ cp_lookup_nested_symbol (struct type *parent_type,
 
   CHECK_TYPEDEF (parent_type);
 
+  if (symbol_lookup_debug)
+    {
+      const char *type_name = type_name_no_tag (saved_parent_type);
+
+      fprintf_unfiltered (gdb_stdlog,
+			  "cp_lookup_nested_symbol (%s, %s, %s)\n",
+			  type_name != NULL ? type_name : "unnamed",
+			  nested_name, host_address_to_string (block));
+    }
+
   switch (TYPE_CODE (parent_type))
     {
     case TYPE_CODE_STRUCT:
@@ -824,7 +917,15 @@ cp_lookup_nested_symbol (struct type *parent_type,
 	char *concatenated_name;
 
 	if (sym != NULL)
-	  return sym;
+	  {
+	    if (symbol_lookup_debug)
+	      {
+		fprintf_unfiltered (gdb_stdlog,
+				    "cp_lookup_nested_symbol (...) = %s\n",
+				    host_address_to_string (sym));
+	      }
+	    return sym;
+	  }
 
 	/* Now search all static file-level symbols.  We have to do this
 	   for things like typedefs in the class.  We do not try to
@@ -838,15 +939,37 @@ cp_lookup_nested_symbol (struct type *parent_type,
 		 parent_name, nested_name);
 	sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN);
 	if (sym != NULL)
-	  return sym;
+	  {
+	    if (symbol_lookup_debug)
+	      {
+		fprintf_unfiltered (gdb_stdlog,
+				    "cp_lookup_nested_symbol (...) = %s\n",
+				    host_address_to_string (sym));
+	      }
+	    return sym;
+	  }
 
 	/* If no matching symbols were found, try searching any
 	   base classes.  */
-	return find_symbol_in_baseclass (parent_type, nested_name, block);
+	sym = find_symbol_in_baseclass (parent_type, nested_name, block);
+	if (symbol_lookup_debug)
+	  {
+	    fprintf_unfiltered (gdb_stdlog,
+				"cp_lookup_nested_symbol (...) = %s\n",
+				sym != NULL
+				? host_address_to_string (sym) : "NULL");
+	  }
+	return sym;
       }
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog,
+			      "cp_lookup_nested_symbol (...) = NULL"
+			      " (func/method)\n");
+	}
       return NULL;
 
     default:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 670c369..24e9384 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -22953,6 +22953,14 @@ Turns on or off debugging messages for FR-V shared-library code.
 @item show debug solib-frv
 Display the current state of FR-V shared-library code debugging
 messages.
+@item set debug symbol-lookup
+@cindex symbol lookup
+Turns on or off display of debugging messages related to symbol lookup.
+The default is 0 (off).
+A value of 1 provides basic information.
+A value greater than 1 provides more verbose information.
+@item show debug symbol-lookup
+Show the current state of symbol lookup debugging messages.
 @item set debug symfile
 @cindex symbol file functions
 Turns on or off display of debugging messages related to symbol file functions.
diff --git a/gdb/language.c b/gdb/language.c
index 034086d1..a5ca92e 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -990,13 +990,31 @@ language_lookup_primitive_type_by_name (const struct language_defn *la,
 					      language_gdbarch_data);
   struct type *const *p;
 
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "language_lookup_primitive_type_by_name"
+			  " (%s, %s, %s)",
+			  la->la_name, host_address_to_string (gdbarch), name);
+    }
+
   for (p = ld->arch_info[la->la_language].primitive_type_vector;
        (*p) != NULL;
        p++)
     {
       if (strcmp (TYPE_NAME (*p), name) == 0)
-	return (*p);
+	{
+	  if (symbol_lookup_debug)
+	    {
+	      fprintf_unfiltered (gdb_stdlog, " = %s\n",
+				  host_address_to_string (*p));
+	    }
+	  return (*p);
+	}
     }
+
+  if (symbol_lookup_debug)
+    fprintf_unfiltered (gdb_stdlog, " = NULL\n");
   return (NULL);
 }
 
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 2463be4..2a421fc 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -203,6 +203,14 @@ lookup_minimal_symbol (const char *name, const char *sfile,
 	     and the second over the demangled hash table.  */
         int pass;
 
+	if (symbol_lookup_debug)
+	  {
+	    fprintf_unfiltered (gdb_stdlog,
+				"lookup_minimal_symbol (%s, %s, %s)\n",
+				name, sfile != NULL ? sfile : "NULL",
+				objfile_debug_name (objfile));
+	  }
+
         for (pass = 1; pass <= 2 && found_symbol.minsym == NULL; pass++)
 	    {
             /* Select hash list according to pass.  */
@@ -282,13 +290,42 @@ lookup_minimal_symbol (const char *name, const char *sfile,
 
   /* External symbols are best.  */
   if (found_symbol.minsym != NULL)
-    return found_symbol;
+    {
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog,
+			      "lookup_minimal_symbol (...) = %s"
+			      " (external)\n",
+			      host_address_to_string (found_symbol.minsym));
+	}
+      return found_symbol;
+    }
 
   /* File-local symbols are next best.  */
   if (found_file_symbol.minsym != NULL)
-    return found_file_symbol;
+    {
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog,
+			      "lookup_minimal_symbol (...) = %s"
+			      " (file-local)\n",
+			      host_address_to_string
+			        (found_file_symbol.minsym));
+	}
+      return found_file_symbol;
+    }
 
   /* Symbols for shared library trampolines are next best.  */
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_minimal_symbol (...) = %s%s\n",
+			  trampoline_symbol.minsym != NULL
+			  ? host_address_to_string (trampoline_symbol.minsym)
+			  : "NULL",
+			  trampoline_symbol.minsym != NULL
+			  ? " (trampoline)" : "");
+    }
   return trampoline_symbol;
 }
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a5df305..4dcd2e1 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -1503,6 +1503,14 @@ objfile_name (const struct objfile *objfile)
   return objfile->original_name;
 }
 
+/* See objfiles.h.  */
+
+const char *
+objfile_debug_name (const struct objfile *objfile)
+{
+  return lbasename (objfile->original_name);
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern initialize_file_ftype _initialize_objfiles;
 
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index a888311..084af39 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -701,6 +701,10 @@ void set_objfile_per_bfd (struct objfile *obj);
 
 const char *objfile_name (const struct objfile *objfile);
 
+/* Return the name to print for OBJFILE in debugging messages.  */
+
+extern const char *objfile_debug_name (const struct objfile *objfile);
+
 /* Set the objfile's notion of the "main" name and language.  */
 
 extern void set_objfile_main_name (struct objfile *objfile,
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 8bca5b2..53c7561 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -59,14 +59,6 @@ symfile_debug_installed (struct objfile *objfile)
 	  && objfile_data (objfile, symfile_debug_objfile_data_key) != NULL);
 }
 
-/* Utility to return the name to print for OBJFILE.  */
-
-static const char *
-debug_objfile_name (const struct objfile *objfile)
-{
-  return lbasename (objfile->original_name);
-}
-
 /* Utility return the name to print for SYMTAB.  */
 
 static const char *
@@ -87,7 +79,7 @@ debug_qf_has_symbols (struct objfile *objfile)
   retval = debug_data->real_sf->qf->has_symbols (objfile);
 
   fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n",
-		    debug_objfile_name (objfile), retval);
+		    objfile_debug_name (objfile), retval);
 
   return retval;
 }
@@ -100,7 +92,7 @@ debug_qf_find_last_source_symtab (struct objfile *objfile)
   struct symtab *retval;
 
   fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   retval = debug_data->real_sf->qf->find_last_source_symtab (objfile);
 
@@ -117,7 +109,7 @@ debug_qf_forget_cached_source_info (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->qf->forget_cached_source_info (objfile);
 }
@@ -136,7 +128,7 @@ debug_qf_map_symtabs_matching_filename (struct objfile *objfile,
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->map_symtabs_matching_filename (%s, \"%s\", \"%s\", %s, %s)\n",
-		    debug_objfile_name (objfile), name,
+		    objfile_debug_name (objfile), name,
 		    real_path ? real_path : NULL,
 		    host_address_to_string (callback),
 		    host_address_to_string (data));
@@ -161,7 +153,7 @@ debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
-		    debug_objfile_name (objfile), kind, name,
+		    objfile_debug_name (objfile), kind, name,
 		    domain_name (domain));
 
   retval = debug_data->real_sf->qf->lookup_symbol (objfile, kind, name,
@@ -182,7 +174,7 @@ debug_qf_print_stats (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "qf->print_stats (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->qf->print_stats (objfile);
 }
@@ -194,7 +186,7 @@ debug_qf_dump (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->qf->dump (objfile);
 }
@@ -208,7 +200,7 @@ debug_qf_relocate (struct objfile *objfile,
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "qf->relocate (%s, %s, %s)\n",
-		    debug_objfile_name (objfile),
+		    objfile_debug_name (objfile),
 		    host_address_to_string (new_offsets),
 		    host_address_to_string (delta));
 
@@ -224,7 +216,7 @@ debug_qf_expand_symtabs_for_function (struct objfile *objfile,
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->expand_symtabs_for_function (%s, \"%s\")\n",
-		    debug_objfile_name (objfile), func_name);
+		    objfile_debug_name (objfile), func_name);
 
   debug_data->real_sf->qf->expand_symtabs_for_function (objfile, func_name);
 }
@@ -236,7 +228,7 @@ debug_qf_expand_all_symtabs (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->qf->expand_all_symtabs (objfile);
 }
@@ -250,7 +242,7 @@ debug_qf_expand_symtabs_with_fullname (struct objfile *objfile,
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
-		    debug_objfile_name (objfile), fullname);
+		    objfile_debug_name (objfile), fullname);
 
   debug_data->real_sf->qf->expand_symtabs_with_fullname (objfile, fullname);
 }
@@ -270,7 +262,7 @@ debug_qf_map_matching_symbols (struct objfile *objfile,
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n",
-		    debug_objfile_name (objfile), name,
+		    objfile_debug_name (objfile), name,
 		    domain_name (namespace), global,
 		    host_address_to_string (callback),
 		    host_address_to_string (data),
@@ -296,7 +288,7 @@ debug_qf_expand_symtabs_matching
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
-		    debug_objfile_name (objfile),
+		    objfile_debug_name (objfile),
 		    host_address_to_string (file_matcher),
 		    host_address_to_string (symbol_matcher),
 		    search_domain_name (kind),
@@ -321,7 +313,7 @@ debug_qf_find_pc_sect_compunit_symtab (struct objfile *objfile,
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
-		    debug_objfile_name (objfile),
+		    objfile_debug_name (objfile),
 		    host_address_to_string (msymbol.minsym),
 		    hex_string (pc),
 		    host_address_to_string (section),
@@ -350,7 +342,7 @@ debug_qf_map_symbol_filenames (struct objfile *objfile,
     objfile_data (objfile, symfile_debug_objfile_data_key);
   fprintf_filtered (gdb_stdlog,
 		    "qf->map_symbol_filenames (%s, %s, %s, %d)\n",
-		    debug_objfile_name (objfile),
+		    objfile_debug_name (objfile),
 		    host_address_to_string (fun),
 		    host_address_to_string (data),
 		    need_fullname);
@@ -391,7 +383,7 @@ debug_sym_get_probes (struct objfile *objfile)
 
   fprintf_filtered (gdb_stdlog,
 		    "probes->sym_get_probes (%s) = %s\n",
-		    debug_objfile_name (objfile),
+		    objfile_debug_name (objfile),
 		    host_address_to_string (retval));
 
   return retval;
@@ -411,7 +403,7 @@ debug_sym_new_init (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_new_init (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->sym_new_init (objfile);
 }
@@ -423,7 +415,7 @@ debug_sym_init (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_init (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->sym_init (objfile);
 }
@@ -435,7 +427,7 @@ debug_sym_read (struct objfile *objfile, int symfile_flags)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_read (%s, 0x%x)\n",
-		    debug_objfile_name (objfile), symfile_flags);
+		    objfile_debug_name (objfile), symfile_flags);
 
   debug_data->real_sf->sym_read (objfile, symfile_flags);
 }
@@ -447,7 +439,7 @@ debug_sym_read_psymbols (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_read_psymbols (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->sym_read_psymbols (objfile);
 }
@@ -459,7 +451,7 @@ debug_sym_finish (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_finish (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->sym_finish (objfile);
 }
@@ -472,7 +464,7 @@ debug_sym_offsets (struct objfile *objfile,
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_offsets (%s, %s)\n",
-		    debug_objfile_name (objfile),
+		    objfile_debug_name (objfile),
 		    host_address_to_string (info));
 
   debug_data->real_sf->sym_offsets (objfile, info);
@@ -494,7 +486,7 @@ debug_sym_read_linetable (struct objfile *objfile)
     objfile_data (objfile, symfile_debug_objfile_data_key);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_read_linetable (%s)\n",
-		    debug_objfile_name (objfile));
+		    objfile_debug_name (objfile));
 
   debug_data->real_sf->sym_read_linetable (objfile);
 }
@@ -510,7 +502,7 @@ debug_sym_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf)
 
   fprintf_filtered (gdb_stdlog,
 		    "sf->sym_relocate (%s, %s, %s) = %s\n",
-		    debug_objfile_name (objfile),
+		    objfile_debug_name (objfile),
 		    host_address_to_string (sectp),
 		    host_address_to_string (buf),
 		    host_address_to_string (retval));
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 54e4be4..2b17dfc 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -105,6 +105,9 @@ struct main_info
 /* When non-zero, print debugging messages related to symtab creation.  */
 unsigned int symtab_create_debug = 0;
 
+/* When non-zero, print debugging messages related to symbol lookup.  */
+unsigned int symbol_lookup_debug = 0;
+
 /* Non-zero if a file may be known by two different basenames.
    This is the uncommon case, and significantly slows down gdb.
    Default set to "off" to not slow down the common case.  */
@@ -1313,6 +1316,16 @@ lookup_language_this (const struct language_defn *lang,
   if (lang->la_name_of_this == NULL || block == NULL)
     return NULL;
 
+  if (symbol_lookup_debug > 1)
+    {
+      struct objfile *objfile = lookup_objfile_from_block (block);
+
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_language_this (%s, %s (objfile %s))",
+			  lang->la_name, host_address_to_string (block),
+			  objfile_debug_name (objfile));
+    }
+
   while (block)
     {
       struct symbol *sym;
@@ -1320,6 +1333,13 @@ lookup_language_this (const struct language_defn *lang,
       sym = block_lookup_symbol (block, lang->la_name_of_this, VAR_DOMAIN);
       if (sym != NULL)
 	{
+	  if (symbol_lookup_debug > 1)
+	    {
+	      fprintf_unfiltered (gdb_stdlog, " = %s (%s, block %s)\n",
+				  SYMBOL_PRINT_NAME (sym),
+				  host_address_to_string (sym),
+				  host_address_to_string (block));
+	    }
 	  block_found = block;
 	  return sym;
 	}
@@ -1328,6 +1348,8 @@ lookup_language_this (const struct language_defn *lang,
       block = BLOCK_SUPERBLOCK (block);
     }
 
+  if (symbol_lookup_debug > 1)
+    fprintf_unfiltered (gdb_stdlog, " = NULL\n");
   return NULL;
 }
 
@@ -1387,6 +1409,18 @@ lookup_symbol_aux (const char *name, const struct block *block,
   struct symbol *sym;
   const struct language_defn *langdef;
 
+  if (symbol_lookup_debug)
+    {
+      struct objfile *objfile = lookup_objfile_from_block (block);
+
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_aux (%s, %s (objfile %s), %s, %s)\n",
+			  name, host_address_to_string (block),
+			  objfile != NULL
+			  ? objfile_debug_name (objfile) : "NULL",
+			  domain_name (domain), language_str (language));
+    }
+
   /* Make sure we do something sensible with is_a_field_of_this, since
      the callers that set this parameter to some non-null value will
      certainly use it later.  If we don't set it, the contents of
@@ -1399,7 +1433,14 @@ lookup_symbol_aux (const char *name, const struct block *block,
 
   sym = lookup_local_symbol (name, block, domain, language);
   if (sym != NULL)
-    return sym;
+    {
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
+			      host_address_to_string (sym));
+	}
+      return sym;
+    }
 
   /* If requested to do so by the caller and if appropriate for LANGUAGE,
      check to see if NAME is a field of `this'.  */
@@ -1430,7 +1471,14 @@ lookup_symbol_aux (const char *name, const struct block *block,
 		   langdef->la_name_of_this);
 
 	  if (check_field (t, name, is_a_field_of_this))
-	    return NULL;
+	    {
+	      if (symbol_lookup_debug)
+		{
+		  fprintf_unfiltered (gdb_stdlog,
+				      "lookup_symbol_aux (...) = NULL\n");
+		}
+	      return NULL;
+	    }
 	}
     }
 
@@ -1439,12 +1487,25 @@ lookup_symbol_aux (const char *name, const struct block *block,
 
   sym = langdef->la_lookup_symbol_nonlocal (name, block, domain);
   if (sym != NULL)
-    return sym;
+    {
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
+			      host_address_to_string (sym));
+	}
+      return sym;
+    }
 
   /* Now search all static file-level symbols.  Not strictly correct,
      but more useful than an error.  */
 
-  return lookup_static_symbol (name, domain);
+  sym = lookup_static_symbol (name, domain);
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
+			  sym != NULL ? host_address_to_string (sym) : "NULL");
+    }
+  return sym;
 }
 
 /* Check to see if the symbol is defined in BLOCK or its superiors.
@@ -1522,13 +1583,31 @@ lookup_symbol_in_block (const char *name, const struct block *block,
 {
   struct symbol *sym;
 
+  if (symbol_lookup_debug > 1)
+    {
+      struct objfile *objfile = lookup_objfile_from_block (block);
+
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_in_block (%s, %s (objfile %s), %s)",
+			  name, host_address_to_string (block),
+			  objfile_debug_name (objfile),
+			  domain_name (domain));
+    }
+
   sym = block_lookup_symbol (block, name, domain);
   if (sym)
     {
+      if (symbol_lookup_debug > 1)
+	{
+	  fprintf_unfiltered (gdb_stdlog, " = %s\n",
+			      host_address_to_string (sym));
+	}
       block_found = block;
       return fixup_symbol_section (sym, NULL);
     }
 
+  if (symbol_lookup_debug > 1)
+    fprintf_unfiltered (gdb_stdlog, " = NULL\n");
   return NULL;
 }
 
@@ -1568,6 +1647,16 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
 
   gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
 
+  if (symbol_lookup_debug > 1)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)",
+			  objfile_debug_name (objfile),
+			  block_index == GLOBAL_BLOCK
+			  ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
+			  name, domain_name (domain));
+    }
+
   ALL_OBJFILE_COMPUNITS (objfile, cust)
     {
       const struct blockvector *bv;
@@ -1579,11 +1668,19 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
       sym = block_lookup_symbol_primary (block, name, domain);
       if (sym)
 	{
+	  if (symbol_lookup_debug > 1)
+	    {
+	      fprintf_unfiltered (gdb_stdlog, " = %s (block %s)\n",
+				  host_address_to_string (sym),
+				  host_address_to_string (block));
+	    }
 	  block_found = block;
 	  return fixup_symbol_section (sym, objfile);
 	}
     }
 
+  if (symbol_lookup_debug > 1)
+    fprintf_unfiltered (gdb_stdlog, " = NULL\n");
   return NULL;
 }
 
@@ -1665,15 +1762,42 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
 
   if (!objfile->sf)
     return NULL;
+
+  if (symbol_lookup_debug > 1)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_via_quick_fns (%s, %s, %s, %s)\n",
+			  objfile_debug_name (objfile),
+			  block_index == GLOBAL_BLOCK
+			  ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
+			  name, domain_name (domain));
+    }
+
   cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name, domain);
   if (cust == NULL)
-    return NULL;
+    {
+      if (symbol_lookup_debug > 1)
+	{
+	  fprintf_unfiltered (gdb_stdlog,
+			      "lookup_symbol_via_quick_fns (...) = NULL\n");
+	}
+      return NULL;
+    }
 
   bv = COMPUNIT_BLOCKVECTOR (cust);
   block = BLOCKVECTOR_BLOCK (bv, block_index);
   sym = block_lookup_symbol (block, name, domain);
   if (!sym)
     error_in_psymtab_expansion (block_index, name, cust);
+
+  if (symbol_lookup_debug > 1)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_via_quick_fns (...) = %s (block %s)\n",
+			  host_address_to_string (sym),
+			  host_address_to_string (block));
+    }
+
   block_found = block;
   return fixup_symbol_section (sym, objfile);
 }
@@ -1734,11 +1858,32 @@ lookup_symbol_in_static_block (const char *name,
 			       const domain_enum domain)
 {
   const struct block *static_block = block_static_block (block);
+  struct symbol *sym;
 
-  if (static_block != NULL)
-    return lookup_symbol_in_block (name, static_block, domain);
-  else
+  if (static_block == NULL)
     return NULL;
+
+  if (symbol_lookup_debug)
+    {
+      struct objfile *objfile = lookup_objfile_from_block (static_block);
+
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_in_static_block (%s, %s (objfile %s),"
+			  " %s)\n",
+			  name,
+			  host_address_to_string (block),
+			  objfile_debug_name (objfile),
+			  domain_name (domain));
+    }
+
+  sym = lookup_symbol_in_block (name, static_block, domain);
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_in_static_block (...) = %s\n",
+			  sym != NULL ? host_address_to_string (sym) : "NULL");
+    }
+  return sym;
 }
 
 /* Perform the standard symbol lookup of NAME in OBJFILE:
@@ -1752,14 +1897,41 @@ lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
 {
   struct symbol *result;
 
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_in_objfile (%s, %s, %s, %s)\n",
+			  objfile_debug_name (objfile),
+			  block_index == GLOBAL_BLOCK
+			  ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
+			  name, domain_name (domain));
+    }
+
   result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
 					     name, domain);
-  if (result == NULL)
+  if (result != NULL)
     {
-      result = lookup_symbol_via_quick_fns (objfile, block_index,
-					    name, domain);
+      if (symbol_lookup_debug)
+	{
+	  fprintf_unfiltered (gdb_stdlog,
+			      "lookup_symbol_in_objfile (...) = %s"
+			      " (in symtabs)\n",
+			      host_address_to_string (result));
+	}
+      return result;
     }
 
+  result = lookup_symbol_via_quick_fns (objfile, block_index,
+					name, domain);
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "lookup_symbol_in_objfile (...) = %s%s\n",
+			  result != NULL
+			  ? host_address_to_string (result)
+			  : "NULL",
+			  result != NULL ? " (via quick fns)" : "");
+    }
   return result;
 }
 
@@ -5252,5 +5424,13 @@ A value greater than 1 provides more verbose information."),
 			     NULL,
 			     &setdebuglist, &showdebuglist);
 
+  add_setshow_zuinteger_cmd ("symbol-lookup", no_class, &symbol_lookup_debug,
+			   _("\
+Set debugging of symbol lookup."), _("\
+Show debugging of symbol lookup."), _("\
+When enabled (non-zero), symbol lookups are logged."),
+			   NULL, NULL,
+			   &setdebuglist, &showdebuglist);
+
   observer_attach_executable_changed (symtab_observer_executable_changed);
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3051530..8ff7646 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1492,6 +1492,8 @@ struct objfile *lookup_objfile_from_block (const struct block *block);
 
 extern unsigned int symtab_create_debug;
 
+extern unsigned int symbol_lookup_debug;
+
 extern int basenames_may_differ;
 
 int compare_filenames_for_search (const char *filename,
