This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[dictionary] move stuff from cp-support.c to cp-namespace.c


This patch moves some of the stuff that was in cp-support.c in my
branch but not in mainline to cp-namespace.c, where it more properly
belongs.  It also changes the 'maint print namespace' command in the
branch to be 'maint cplus namespace'.  There's nothing substantial
here, just mechanical stuff.

David Carlton
carlton@bactrian.org

2003-04-30  David Carlton  <carlton@bactrian.org>

	* Makefile.in (cp-namespace.o): Update dependencies.
	(cp-support.o): Ditto.
	* cp-support.h: Declare maint_cplus_cmd_list.
	* cp-namespace.c: Move variables namespace_block,
	possible_namespace_block, namespace_objfile here from
	cp-support.c.
	Move functions initialize_namespace_blocks, get_namespace_block,
	get_possible_namespace_block, free_namespace_blocks,
	check_one_possible_namespace_symbol,
	check_possible_namespace_symbols_loop, maintenance_print_namespace
	here from cp-support.c.
	Include objfiles.h, gdbtypes.h, dictionary.h, gdbcmd.h.
	* cp-namespace.c (_initialize_cp_namespace): New.
	(maintenance_cplus_namespace): Rename from
	maintenance_print_namespace.
	* cp-support.c (cp_find_first_component): Fix typo in comment.
	(_initialize_cp_support): Don't add 'maint print
	namespace'.
	Make maint_cplus_cmd_list extern.
	Prune includes.

2003-04-30  David Carlton  <carlton@bactrian.org>

	* gdb.c++/maint.exp (test_help): Refactor, and add test for maint
	cp namespace.
	(test_namespace): New.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.262.2.28
diff -u -p -r1.262.2.28 Makefile.in
--- Makefile.in	16 Apr 2003 19:56:48 -0000	1.262.2.28
+++ Makefile.in	30 Apr 2003 23:09:22 -0000
@@ -1619,11 +1619,10 @@ corelow.o: corelow.c $(defs_h) $(gdb_str
 cp-abi.o: cp-abi.c $(defs_h) $(value_h) $(cp_abi_h) $(command_h) \
 	$(gdbcmd_h) $(ui_out_h) $(gdb_string_h)
 cp-namespace.o: cp-namespace.c $(defs_h) $(cp_support_h) $(gdb_obstack_h) \
-	$(symtab_h) $(symfile_h) $(gdb_assert_h) $(block_h)
+	$(symtab_h) $(symfile_h) $(gdb_assert_h) $(block_h) $(objfiles_h) \
+	$(gdbtypes_h) $(dictionary_h) $(gdbcmd_h)
 cp-support.o: cp-support.c $(defs_h) $(cp_support_h) $(gdb_string_h) \
-	$(demangle_h) $(gdb_assert_h) $(gdb_obstack_h) $(symtab_h) \
-	$(symfile_h) $(block_h) $(objfiles_h) $(gdbtypes_h) $(dictionary_h) \
-	$(gdbcmd_h)
+	$(demangle_h) $(gdb_assert_h) $(symtab_h) $(gdbcmd_h)
 cp-valprint.o: cp-valprint.c $(defs_h) $(gdb_obstack_h) $(symtab_h) \
 	$(gdbtypes_h) $(expression_h) $(value_h) $(command_h) $(gdbcmd_h) \
 	$(demangle_h) $(annotate_h) $(gdb_string_h) $(c_lang_h) $(target_h) \
Index: cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 cp-namespace.c
--- cp-namespace.c	16 Apr 2003 19:56:51 -0000	1.1.2.1
+++ cp-namespace.c	30 Apr 2003 23:09:23 -0000
@@ -27,6 +27,10 @@
 #include "symfile.h"
 #include "gdb_assert.h"
 #include "block.h"
+#include "objfiles.h"
+#include "gdbtypes.h"
+#include "dictionary.h"
+#include "gdbcmd.h"
 
 /* When set, the file that we're processing seems to have debugging
    info for C++ namespaces, so cp-namespace.c shouldn't try to guess
@@ -52,6 +56,35 @@ static struct using_direct *cp_add_using
 static struct using_direct *cp_copy_usings (struct using_direct *using,
 					    struct obstack *obstack);
 
+/* This block exists only to store symbols associated to namespaces.
+   Normally, try to avoid accessing it directly: instead, use
+   get_namespace_block if you can.  Similarly with
+   possible_namespace_block and namespace_objfile.  */
+
+static struct block *namespace_block = NULL;
+
+static struct block *possible_namespace_block = NULL;
+
+static struct objfile *namespace_objfile = NULL;
+
+static void initialize_namespace_blocks (void);
+
+static struct block *get_namespace_block (void);
+
+static struct block *get_possible_namespace_block (void);
+
+static struct objfile *get_namespace_objfile (void);
+
+static void free_namespace_blocks (struct symtab *symtab);
+
+static int check_one_possible_namespace_symbol (const char *name,
+						int len);
+
+static int check_possible_namespace_symbols_loop (const char *name,
+						  int len);
+
+static void maintenance_print_namespace (char *args, int from_tty);
+
 /* Set up support for dealing with C++ namespace info in the current
    symtab.  */
 
@@ -263,4 +296,274 @@ cp_copy_usings (struct using_direct *usi
 
       return retval;
     }
+}
+
+/* Allocate everything necessary for namespace_block and
+   possible_namespace_block.  */
+
+static void
+initialize_namespace_blocks (void)
+{
+  struct objfile *objfile = get_namespace_objfile ();
+  struct symtab *namespace_symtab;
+  struct blockvector *bv;
+  struct block *bl;
+
+  namespace_symtab = allocate_symtab ("<C++-namespaces>", objfile);
+  namespace_symtab->language = language_cplus;
+  namespace_symtab->free_code = free_nothing;
+  namespace_symtab->dirname = NULL;
+
+  /* 2 = 3 blocks (global = namespace_block, static = NULL,
+     possible_namespace_block) - 1 block that's always part of struct
+     blockvector.  */
+  bv = obstack_alloc (&objfile->symbol_obstack,
+		      sizeof (struct blockvector)
+		      + 2 * sizeof (struct block *));
+  BLOCKVECTOR_NBLOCKS (bv) = 3;
+  BLOCKVECTOR (namespace_symtab) = bv;
+  
+  /* Allocate dummy STATIC_BLOCK. */
+  bl = allocate_block (&objfile->symbol_obstack);
+  BLOCK_DICT (bl) = dict_create_linear (&objfile->symbol_obstack,
+					NULL);
+  BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
+
+  /* Allocate GLOBAL_BLOCK, which is namespace_block.  */
+  bl = allocate_block (&objfile->symbol_obstack);
+  BLOCK_DICT (bl) = dict_create_hashed_expandable ();
+  BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
+  namespace_block = bl;
+
+  /* Allocate possible_namespace_block; we put it where the first
+     local block will live, though I don't think there's any need to
+     pretend that it's actually a local block (e.g. by setting
+     BLOCK_SUPERBLOCK appropriately).  */
+  bl = allocate_block (&objfile->symbol_obstack);
+  BLOCK_DICT (bl) = dict_create_hashed_expandable ();
+  BLOCKVECTOR_BLOCK (bv, 2) = bl;
+  possible_namespace_block = bl;
+
+  namespace_symtab->free_func = free_namespace_blocks;
+}
+
+/* Locate namespace_block, allocating it if necessary.  */
+
+static struct block *
+get_namespace_block (void)
+{
+  if (namespace_block == NULL)
+    initialize_namespace_blocks ();
+
+  return namespace_block;
+}
+
+/* Locate possible_namespace_block, allocating it if necessary.  */
+
+static struct block *
+get_possible_namespace_block (void)
+{
+  if (namespace_block == NULL)
+    initialize_namespace_blocks ();
+
+  return possible_namespace_block;
+}
+
+/* Free the dictionary associated to the namespace block.  */
+
+static void
+free_namespace_blocks (struct symtab *symtab)
+{
+  gdb_assert (namespace_block != NULL);
+  dict_free (BLOCK_DICT (namespace_block));
+  namespace_block = NULL;
+  dict_free (BLOCK_DICT (possible_namespace_block));
+  possible_namespace_block = NULL;
+  namespace_objfile = NULL;
+}
+
+/* Locate the namespace objfile, allocating it if necessary.  */
+
+static struct objfile *
+get_namespace_objfile (void)
+{
+  if (namespace_objfile == NULL)
+    {
+      namespace_objfile = allocate_objfile (NULL, 0);
+      namespace_objfile->name = "<C++-namespaces>";
+    }
+
+  return namespace_objfile;
+}
+
+/* Check to see if there's already a namespace symbol corresponding to
+   the initial substring of NAME whose length is LEN; if there isn't
+   one, allocate one and add it to the namespace symtab.  Return the
+   symbol in question.  */
+
+struct symbol *
+cp_check_namespace_symbol (const char *name, int len)
+{
+  struct objfile *objfile = get_namespace_objfile ();
+  char *name_copy = obsavestring (name, len, &objfile->symbol_obstack);
+  struct symbol *sym = cp_lookup_namespace_symbol (name_copy);
+
+  if (sym == NULL)
+    {
+      struct type *type = init_type (TYPE_CODE_NAMESPACE, 0, 0,
+				     name_copy, objfile);
+      TYPE_TAG_NAME (type) = TYPE_NAME (type);
+
+      sym = obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
+      memset (sym, 0, sizeof (struct symbol));
+      SYMBOL_LANGUAGE (sym) = language_cplus;
+      DEPRECATED_SYMBOL_NAME (sym) = name_copy;
+      SYMBOL_CLASS (sym) = LOC_TYPEDEF;
+      SYMBOL_TYPE (sym) = type;
+      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+
+      dict_add_symbol (BLOCK_DICT (get_namespace_block ()), sym);
+    }
+  else
+    {
+      obstack_free (&objfile->symbol_obstack, name_copy);
+    }
+
+  return sym;
+}
+
+/* Look for a symbol in namespace_block named NAME.  */
+
+struct symbol *
+cp_lookup_namespace_symbol (const char *name)
+{
+  return lookup_block_symbol (get_namespace_block (), name, NULL,
+			      VAR_NAMESPACE);
+}
+
+/* The next few functions deal with "possible namespace symbols".
+   These are symbols that claim to be associated to namespaces,
+   whereas in fact we don't know if the object of that name is a
+   namespace or a class.  So don't trust them until you've searched
+   through all the global symbols to see if there's a class of that
+   name or not.  */
+
+/* FIXME: carlton/2002-12-18: This concept is a hack.  But it seems to
+   be the easiest way to deal with our desire for namespace symbols,
+   given the commonness of compilers that don't generate debugging
+   info for them.  Once such compilers are more common, we should
+   delete all the possible namespace stuff.  */
+
+/* Check to see if there's already a possible namespace symbol whose
+   name is the initial substring of NAME of length LEN.  If not,
+   create one and return 0; otherwise, return 1.  */
+
+static int
+check_one_possible_namespace_symbol (const char *name, int len)
+{
+  struct objfile *objfile = get_namespace_objfile ();
+  char *name_copy = obsavestring (name, len, &objfile->symbol_obstack);
+  const struct block *block = get_possible_namespace_block ();
+  struct symbol *sym = lookup_block_symbol (block, name_copy,
+					    NULL, VAR_NAMESPACE);
+
+  if (sym == NULL)
+    {
+      struct type *type = init_type (TYPE_CODE_NAMESPACE, 0, 0,
+				     name_copy, objfile);
+      TYPE_TAG_NAME (type) = TYPE_NAME (type);
+
+      sym = obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
+      memset (sym, 0, sizeof (struct symbol));
+      SYMBOL_LANGUAGE (sym) = language_cplus;
+      DEPRECATED_SYMBOL_NAME (sym) = name_copy;
+      SYMBOL_CLASS (sym) = LOC_TYPEDEF;
+      SYMBOL_TYPE (sym) = type;
+      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+
+      dict_add_symbol (BLOCK_DICT (block), sym);
+      return 0;
+    }
+  else
+    {
+      obstack_free (&objfile->symbol_obstack, name_copy);
+      return 1;
+    }
+}
+
+/* This is a helper loop for cp_check_possible_namespace_symbols; it
+   ensures that there are namespace symbols for all namespaces that
+   are initial substrings of NAME of length LEN.  It returns 1 if a
+   previous loop had already created the shortest such symbol and 0
+   otherwise.  */
+
+static int
+check_possible_namespace_symbols_loop (const char *name, int len)
+{
+  if (name[len] == ':')
+    {
+      int done;
+      int next_len = len + 2;
+
+      next_len += cp_find_first_component (name + next_len);
+      done = check_possible_namespace_symbols_loop (name, next_len);
+
+      if (!done)
+	{
+	  done = check_one_possible_namespace_symbol (name, len);
+	}
+
+      return done;
+    }
+  else
+    return 0;
+}
+
+/* Ensure that there are symbols in possible_namespace_block for all
+   initial substrings of NAME that look like namespaces or
+   classes.  */
+
+void
+cp_check_possible_namespace_symbols (const char *name)
+{
+  check_possible_namespace_symbols_loop (name,
+					 cp_find_first_component (name));
+}
+
+/* Look for a symbol in possible_namespace_block named NAME.  */
+
+struct symbol *
+cp_lookup_possible_namespace_symbol (const char *name)
+{
+  return lookup_block_symbol (get_possible_namespace_block (),
+			      name, NULL, VAR_NAMESPACE);
+}
+
+static void
+maintenance_cplus_namespace (char *args, int from_tty)
+{
+  const struct block *namespace_block = get_namespace_block ();
+  const struct block *possible_namespace_block
+    = get_possible_namespace_block ();
+  struct dict_iterator iter;
+  struct symbol *sym;
+
+  printf_unfiltered ("Definite namespaces:\n");
+  ALL_BLOCK_SYMBOLS (namespace_block, iter, sym)
+    {
+      printf_unfiltered ("%s\n", SYMBOL_PRINT_NAME (sym));
+    }
+  printf_unfiltered ("Possible namespaces:\n");
+  ALL_BLOCK_SYMBOLS (possible_namespace_block, iter, sym)
+    {
+      printf_unfiltered ("%s\n", SYMBOL_PRINT_NAME (sym));
+    }
+}
+
+void
+_initialize_cp_namespace (void)
+{
+  add_cmd ("namespace", class_maintenance, maintenance_cplus_namespace,
+	   "Print the list of current known C++ namespaces.",
+	   &maint_cplus_cmd_list);
 }
Index: cp-support.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-support.c,v
retrieving revision 1.1.2.19
diff -u -p -r1.1.2.19 cp-support.c
--- cp-support.c	18 Apr 2003 18:10:48 -0000	1.1.2.19
+++ cp-support.c	30 Apr 2003 23:09:24 -0000
@@ -1,7 +1,7 @@
 /* Helper routines for C++ support in GDB.
    Copyright 2002, 2003 Free Software Foundation, Inc.
 
-   Contributed by MontaVista Software and Stanford University.
+   Contributed by MontaVista Software.
 
    This file is part of GDB.
 
@@ -26,18 +26,12 @@
 #include "gdb_string.h"
 #include "demangle.h"
 #include "gdb_assert.h"
-#include "gdb_obstack.h"
 #include "symtab.h"
-#include "symfile.h"
-#include "block.h"
-#include "objfiles.h"
-#include "gdbtypes.h"
-#include "dictionary.h"
 #include "gdbcmd.h"
 
 /* The list of "maint cplus" commands.  */
 
-static struct cmd_list_element *maint_cplus_cmd_list = NULL;
+struct cmd_list_element *maint_cplus_cmd_list = NULL;
 
 /* The actual commands.  */
 
@@ -46,35 +40,6 @@ static void first_component_command (cha
 
 static const char *find_last_component (const char *name);
 
-/* This block exists only to store symbols associated to namespaces.
-   Normally, try to avoid accessing it directly: instead, use
-   get_namespace_block if you can.  Similarly with
-   possible_namespace_block and namespace_objfile.  */
-
-static struct block *namespace_block = NULL;
-
-static struct block *possible_namespace_block = NULL;
-
-static struct objfile *namespace_objfile = NULL;
-
-static void initialize_namespace_blocks (void);
-
-static struct block *get_namespace_block (void);
-
-static struct block *get_possible_namespace_block (void);
-
-static struct objfile *get_namespace_objfile (void);
-
-static void free_namespace_blocks (struct symtab *symtab);
-
-static int check_one_possible_namespace_symbol (const char *name,
-						int len);
-
-static int check_possible_namespace_symbols_loop (const char *name,
-						  int len);
-
-static void maintenance_print_namespace (char *args, int from_tty);
-
 /* Here are some random pieces of trivia to keep in mind while trying
    to take apart demangled names:
 
@@ -284,7 +249,7 @@ cp_find_first_component (const char *nam
 	case ':':
 	  return index;
 	case 'o':
-	  /* Operator names can screw up the recurson.  */
+	  /* Operator names can screw up the recursion.  */
 	  if (operator_possible
 	      && strncmp (name + index, "operator", LENGTH_OF_OPERATOR) == 0)
 	    {
@@ -362,268 +327,6 @@ cp_entire_prefix_len (const char *name)
   return previous_len;
 }
 
-/* Allocate everything necessary for namespace_block and
-   possible_namespace_block.  */
-
-static void
-initialize_namespace_blocks (void)
-{
-  struct objfile *objfile = get_namespace_objfile ();
-  struct symtab *namespace_symtab;
-  struct blockvector *bv;
-  struct block *bl;
-
-  namespace_symtab = allocate_symtab ("<C++-namespaces>", objfile);
-  namespace_symtab->language = language_cplus;
-  namespace_symtab->free_code = free_nothing;
-  namespace_symtab->dirname = NULL;
-
-  /* 2 = 3 blocks (global = namespace_block, static = NULL,
-     possible_namespace_block) - 1 block that's always part of struct
-     blockvector.  */
-  bv = obstack_alloc (&objfile->symbol_obstack,
-		      sizeof (struct blockvector)
-		      + 2 * sizeof (struct block *));
-  BLOCKVECTOR_NBLOCKS (bv) = 3;
-  BLOCKVECTOR (namespace_symtab) = bv;
-  
-  /* Allocate dummy STATIC_BLOCK. */
-  bl = allocate_block (&objfile->symbol_obstack);
-  BLOCK_DICT (bl) = dict_create_linear (&objfile->symbol_obstack,
-					NULL);
-  BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
-
-  /* Allocate GLOBAL_BLOCK, which is namespace_block.  */
-  bl = allocate_block (&objfile->symbol_obstack);
-  BLOCK_DICT (bl) = dict_create_hashed_expandable ();
-  BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
-  namespace_block = bl;
-
-  /* Allocate possible_namespace_block; we put it where the first
-     local block will live, though I don't think there's any need to
-     pretend that it's actually a local block (e.g. by setting
-     BLOCK_SUPERBLOCK appropriately).  */
-  bl = allocate_block (&objfile->symbol_obstack);
-  BLOCK_DICT (bl) = dict_create_hashed_expandable ();
-  BLOCKVECTOR_BLOCK (bv, 2) = bl;
-  possible_namespace_block = bl;
-
-  namespace_symtab->free_func = free_namespace_blocks;
-}
-
-/* Locate namespace_block, allocating it if necessary.  */
-
-static struct block *
-get_namespace_block (void)
-{
-  if (namespace_block == NULL)
-    initialize_namespace_blocks ();
-
-  return namespace_block;
-}
-
-/* Locate possible_namespace_block, allocating it if necessary.  */
-
-static struct block *
-get_possible_namespace_block (void)
-{
-  if (namespace_block == NULL)
-    initialize_namespace_blocks ();
-
-  return possible_namespace_block;
-}
-
-/* Free the dictionary associated to the namespace block.  */
-
-static void
-free_namespace_blocks (struct symtab *symtab)
-{
-  gdb_assert (namespace_block != NULL);
-  dict_free (BLOCK_DICT (namespace_block));
-  namespace_block = NULL;
-  dict_free (BLOCK_DICT (possible_namespace_block));
-  possible_namespace_block = NULL;
-  namespace_objfile = NULL;
-}
-
-/* Locate the namespace objfile, allocating it if necessary.  */
-
-static struct objfile *
-get_namespace_objfile (void)
-{
-  if (namespace_objfile == NULL)
-    {
-      namespace_objfile = allocate_objfile (NULL, 0);
-      namespace_objfile->name = "<C++-namespaces>";
-    }
-
-  return namespace_objfile;
-}
-
-/* Check to see if there's already a namespace symbol corresponding to
-   the initial substring of NAME whose length is LEN; if there isn't
-   one, allocate one and add it to the namespace symtab.  Return the
-   symbol in question.  */
-
-struct symbol *
-cp_check_namespace_symbol (const char *name, int len)
-{
-  struct objfile *objfile = get_namespace_objfile ();
-  char *name_copy = obsavestring (name, len, &objfile->symbol_obstack);
-  struct symbol *sym = cp_lookup_namespace_symbol (name_copy);
-
-  if (sym == NULL)
-    {
-      struct type *type = init_type (TYPE_CODE_NAMESPACE, 0, 0,
-				     name_copy, objfile);
-      TYPE_TAG_NAME (type) = TYPE_NAME (type);
-
-      sym = obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
-      memset (sym, 0, sizeof (struct symbol));
-      SYMBOL_LANGUAGE (sym) = language_cplus;
-      DEPRECATED_SYMBOL_NAME (sym) = name_copy;
-      SYMBOL_CLASS (sym) = LOC_TYPEDEF;
-      SYMBOL_TYPE (sym) = type;
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
-
-      dict_add_symbol (BLOCK_DICT (get_namespace_block ()), sym);
-    }
-  else
-    {
-      obstack_free (&objfile->symbol_obstack, name_copy);
-    }
-
-  return sym;
-}
-
-/* Look for a symbol in namespace_block named NAME.  */
-
-struct symbol *
-cp_lookup_namespace_symbol (const char *name)
-{
-  return lookup_block_symbol (get_namespace_block (), name, NULL,
-			      VAR_NAMESPACE);
-}
-
-/* The next few functions deal with "possible namespace symbols".
-   These are symbols that claim to be associated to namespaces,
-   whereas in fact we don't know if the object of that name is a
-   namespace or a class.  So don't trust them until you've searched
-   through all the global symbols to see if there's a class of that
-   name or not.  */
-
-/* FIXME: carlton/2002-12-18: This concept is a hack.  But it seems to
-   be the easiest way to deal with our desire for namespace symbols,
-   given the commonness of compilers that don't generate debugging
-   info for them.  Once such compilers are more common, we should
-   delete all the possible namespace stuff.  */
-
-/* Check to see if there's already a possible namespace symbol whose
-   name is the initial substring of NAME of length LEN.  If not,
-   create one and return 0; otherwise, return 1.  */
-
-static int
-check_one_possible_namespace_symbol (const char *name, int len)
-{
-  struct objfile *objfile = get_namespace_objfile ();
-  char *name_copy = obsavestring (name, len, &objfile->symbol_obstack);
-  const struct block *block = get_possible_namespace_block ();
-  struct symbol *sym = lookup_block_symbol (block, name_copy,
-					    NULL, VAR_NAMESPACE);
-
-  if (sym == NULL)
-    {
-      struct type *type = init_type (TYPE_CODE_NAMESPACE, 0, 0,
-				     name_copy, objfile);
-      TYPE_TAG_NAME (type) = TYPE_NAME (type);
-
-      sym = obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
-      memset (sym, 0, sizeof (struct symbol));
-      SYMBOL_LANGUAGE (sym) = language_cplus;
-      DEPRECATED_SYMBOL_NAME (sym) = name_copy;
-      SYMBOL_CLASS (sym) = LOC_TYPEDEF;
-      SYMBOL_TYPE (sym) = type;
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
-
-      dict_add_symbol (BLOCK_DICT (block), sym);
-      return 0;
-    }
-  else
-    {
-      obstack_free (&objfile->symbol_obstack, name_copy);
-      return 1;
-    }
-}
-
-/* This is a helper loop for cp_check_possible_namespace_symbols; it
-   ensures that there are namespace symbols for all namespaces that
-   are initial substrings of NAME of length LEN.  It returns 1 if a
-   previous loop had already created the shortest such symbol and 0
-   otherwise.  */
-
-static int
-check_possible_namespace_symbols_loop (const char *name, int len)
-{
-  if (name[len] == ':')
-    {
-      int done;
-      int next_len = len + 2;
-
-      next_len += cp_find_first_component (name + next_len);
-      done = check_possible_namespace_symbols_loop (name, next_len);
-
-      if (!done)
-	{
-	  done = check_one_possible_namespace_symbol (name, len);
-	}
-
-      return done;
-    }
-  else
-    return 0;
-}
-
-/* Ensure that there are symbols in possible_namespace_block for all
-   initial substrings of NAME that look like namespaces or
-   classes.  */
-
-void
-cp_check_possible_namespace_symbols (const char *name)
-{
-  check_possible_namespace_symbols_loop (name,
-					 cp_find_first_component (name));
-}
-
-/* Look for a symbol in possible_namespace_block named NAME.  */
-
-struct symbol *
-cp_lookup_possible_namespace_symbol (const char *name)
-{
-  return lookup_block_symbol (get_possible_namespace_block (),
-			      name, NULL, VAR_NAMESPACE);
-}
-
-static void
-maintenance_print_namespace (char *args, int from_tty)
-{
-  const struct block *namespace_block = get_namespace_block ();
-  const struct block *possible_namespace_block
-    = get_possible_namespace_block ();
-  struct dict_iterator iter;
-  struct symbol *sym;
-
-  printf_unfiltered ("Definite namespaces:\n");
-  ALL_BLOCK_SYMBOLS (namespace_block, iter, sym)
-    {
-      printf_unfiltered ("%s\n", SYMBOL_PRINT_NAME (sym));
-    }
-  printf_unfiltered ("Possible namespaces:\n");
-  ALL_BLOCK_SYMBOLS (possible_namespace_block, iter, sym)
-    {
-      printf_unfiltered ("%s\n", SYMBOL_PRINT_NAME (sym));
-    }
-}
-
 /* If FULL_NAME is the demangled name of a C++ function (including an
    arg list, possibly including namespace/class qualifications),
    return a new string containing only the function name (without the
@@ -688,7 +391,4 @@ _initialize_cp_support (void)
   add_cmd ("first_component", class_maintenance, first_component_command,
 	   "Print the first class/namespace component of NAME.",
 	   &maint_cplus_cmd_list);
-  add_cmd ("namespace", class_maintenance, maintenance_print_namespace,
-	   "Print the list of current known C++ namespaces.",
-	   &maintenanceprintlist);
 }
Index: cp-support.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-support.h,v
retrieving revision 1.1.2.14
diff -u -p -r1.1.2.14 cp-support.h
--- cp-support.h	16 Apr 2003 19:56:51 -0000	1.1.2.14
+++ cp-support.h	30 Apr 2003 23:09:24 -0000
@@ -88,4 +88,8 @@ extern void cp_set_block_scope (const st
 
 extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
 
+/* The list of "maint cplus" commands.  */
+
+extern struct cmd_list_element *maint_cplus_cmd_list;
+
 #endif /* CP_SUPPORT_H */
Index: testsuite/gdb.c++/maint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/maint.exp,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 maint.exp
--- testsuite/gdb.c++/maint.exp	18 Apr 2003 18:10:50 -0000	1.1.2.2
+++ testsuite/gdb.c++/maint.exp	30 Apr 2003 23:09:45 -0000
@@ -29,13 +29,19 @@ if $tracelevel then {
 # Test the help messages.
 
 proc test_help {} {
-    gdb_test "help maintenance cplus" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
+    set first_component_help "Print the first class/namespace component of NAME"
+    set namespace_help "Print the list of current known C\\+\\+ namespaces"
 
-    gdb_test "help maint cp" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
+    set multiple_help_body "List of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- ${first_component_help}\r\nmaintenance cplus namespace -- ${namespace_help}\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
 
-    gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
+    set help_maint_cp "C\\+\\+ maintenance commands.\r\n\r\n${multiple_help_body}"
 
-    gdb_test "help maint cp first_component" "Print the first class/namespace component of NAME."
+    gdb_test "help maintenance cplus" "${help_maint_cp}"
+    gdb_test "help maint cp" "${help_maint_cp}"
+    gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\n${multiple_help_body}"
+
+    gdb_test "help maint cp first_component" "${first_component_help}."
+    gdb_test "help maint cp namespace" "${namespace_help}."
 }
 
 # This is used when NAME should contain only a single component.  Be
@@ -74,11 +80,20 @@ proc test_first_component {} {
     gdb_test "maint cp first_component C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >::bar" "C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >"
 }
 
+proc test_namespace {} {
+    # FIXME: carlton/2003-04-28: I should think of more tests to add
+    # here.  Unfortunately, it's hard to predict exactly what will be
+    # picked up from the library, or what order it will be in.
+
+    gdb_test "maint cp namespace" "Definite namespaces:\r\nPossible namespaces:"
+}
+
 gdb_exit
 gdb_start
 
 test_help
 test_first_component
+test_namespace
 
 gdb_exit
 return 0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]