]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2002-11-27 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Thu, 28 Nov 2002 00:53:26 +0000 (00:53 +0000)
committerDavid Carlton <carlton@bactrian.org>
Thu, 28 Nov 2002 00:53:26 +0000 (00:53 +0000)
* dwarf2read.c (add_partial_enumeration): New function.
(scan_partial_symbols): Call add_partial_enumeration.
(locate_pdi_sibling): New function.
(scan_partial_symbols): Call locate_pdi_sibling.  Get rid of
nesting_level.
(pdi_needs_namespace): New function.
(add_partial_symbol): Add 'namespace' arg; calculate full name
when appropriate.
(scan_partial_symbols): Update calls to add_partial_symbol.
(add_partial_enumeration): Ditto.
(read_enumeration): Add processing_current_prefix to name when
appropriate.
(new_symbol): Set names of enumerators and typedefs appropriately
if processing_has_namespace_info.
* symtab.c (lookup_symbol_namespace): Rename 'namespace' argument
to 'namespace_name'.
* symtab.h: Ditto.
* symtab.c (lookup_symbol_namespace): Delete FIXME comments; add a
new one.
(lookup_symbol_aux_file): New function.
(lookup_symbol_aux): Delete FIXME comment.
(lookup_symbol_aux): Don't search static block explicitly; delete
FIXME comments.
* valops.c (value_namespace_elt): Update call to
lookup_symbol_namespace.
* symtab.h: Update declaration for lookup_symbol_namespace.
* symtab.c (lookup_symbol_namespace): Delete 'using' argument and
add 'block' argument; get using directives via iterators.
(lookup_symbol_aux_using_loop): Delete 'using' argument and add
'block' argument.
(lookup_symbol_aux_using): Don't calculate using directives.
* block.c (block_using_iterator_first): New function.
(block_using_iterator_next): Ditto.
* block.h: Add comment.
(struct block_using_iterator): New struct.
Declare block_using_iterator_first, block_using_iterator_next.

2002-11-26  David Carlton  <carlton@math.stanford.edu>

* dwarf2read.c (read_structure_scope): Set type name and
processing_current_prefix appropriately.
(new_symbol): Make sure that, in symbols associated to class
types, the name includes appropriate namespaces.
* buildsym.h: Rename processing_current_namespace to
processing_current_prefix.
* buildsym.c (finish_block): Ditto.
* dwarf2read.c (psymtab_to_symtab_1): Ditto.
(read_namespace): Ditto.  Also rename previous_namespace to
previous_prefix.

Now come a thousand and one const correctness fixes:
* p-typeprint.c (pascal_print_type): Const.
(pascal_type_print_method_args): Const.
* p-lang.h: Const.
* m2-typeprint.c (m2_print_type): Const.
* valops.c (hand_function_call): Const.
* jv-lang.c (java_primitive_type_from_name): Const.
* jv-lang.h: Const.
* jv-typeprint.c (java_print_type): Const.
* language.c: (unk_lang_print_type): Const.
* stack.c (frame_info): Const.
* linespec.c (find_methods): Const.
(find_method_name): Const
* f-lang.h: Const.
* f-typeprint.c (f_print_type): Const.
* c-typeprint.c (c_print_type): Const.
* c-lang.h: Const.
* gdbtypes.h: Const.
* gdbtypes.c (lookup_primitive_typename): Const.
* stack.c (print_frame): Const.
(func_command): Delete pointless cast.
* linespec.c (find_method_name): Const.
* language.h: Const.
* symfile.c (compare_psymbols): Const.
* symtab.c (completion_list_add_name): Const.
* breakpoint.c (break_at_finish_at_depth_command_1): Remove
useless cast.
(break_at_finish_command_1): Ditto.
* typeprint.c (type_print): Const.
* symtab.h: Const.
* symtab.c (gdb_mangle_name): Const.
(symbol_init_demangled_name): Const.
(symbol_demangled_name): Const.
* defs.h: Const.
* printcmd.c (build_address_symbolic): Const.
* valops.c (search_struct_method): Const.
* cp-valprint.c (cp_is_vtbl_ptr_type): Const.
(cp_print_value): Const.
(cp_print_class_member): Const.
* c-typeprint.c (cp_type_print_derivation_info): Const.
(c_type_print_varspec_prefix): Const.
(c_type_print_base): Const.
* p-valprint.c (pascal_object_is_vtbl_ptr_type): Const.
(pascal_object_print_value): Const.
(pascal_object_print_class_member): Const.
* p-typeprint.c (pascal_type_print_derivation_info): Const.
(pascal_type_print_varspec_prefix): Const.
(pascal_type_print_base): Const.
* jv-typeprint.c (java_type_print_base): Const.
* jv-lang.h (java_demangle_type_signature): Const.
* jv-lang.c (java_demangle_type_signature): Const.
(java_demangled_signature_length): Const.
(java_demangled_signature_copy): Const.
* jv-typeprint.c (java_type_print_derivation_info): Const.
* jv-valprint.c (java_value_print): Const.
(java_print_value_fields): Const.
* jv-lang.c (is_object_type): Const.
(evaluate_subexp_java): Const.
* stabsread.c (read_cpp_abbrev): Const.
(complain_about_struct_wipeout): Const.
(cleanup_undefined_types): Const.
* gdbtypes.h: Const.
* gdbtypes.c (add_name): Second arg const.
(lookup_typename): Const.
(lookup_unsigned_typename): Const.
(lookup_signed_typename): Const.
* linespec.c (find_methods): const char *class_name.
* symtab.c (gdb_mangle_name): const char *newname.
* valops.c (destructor_name_p): const char *dname.
(search_struct_field): First arg const.
* gdbtypes.c (check_typedef): const char *name (multiple places).
(cfront_mangle_name): const char *newname.
* gdbtypes.c (add_mangled_type): const char *tname.
* valops.c (find_overload_match): const char *obj_type_name.
* utils.c (gdb_print_host_address): Make first arg const.
* defs.h: Declare first arg of gdb_print_host_address to be
const.
* valarith.c (find_size_for_pointer_math): const char *name.

2002-11-27  David Carlton  <carlton@math.stanford.edu>

* gdb.c++/m-data.cc (main): Add marker comment.
* gdb.c++/m-data.exp: Use marker comment instead of line numbers.
* gdb.c++/m-data.cc: Delete superfluous namespace.
* gdb.c++/m-static.cc: Ditto.
* gdb.c++/m-static1.cc: Ditto.
* carlton_runtest: Compare based on gdb.sum, not based on output.
* carlton_runnamespace: Ditto.

2002-11-26  David Carlton  <carlton@math.stanford.edu>

* gdb.c++/namespace.exp: Put tests for CClass.
* gdb.c++/namespace.cc (C): Add CClass.

47 files changed:
gdb/ChangeLog
gdb/block.c
gdb/block.h
gdb/breakpoint.c
gdb/buildsym.c
gdb/buildsym.h
gdb/c-lang.h
gdb/c-typeprint.c
gdb/cp-valprint.c
gdb/defs.h
gdb/dwarf2read.c
gdb/f-lang.h
gdb/f-typeprint.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/jv-lang.c
gdb/jv-lang.h
gdb/jv-typeprint.c
gdb/jv-valprint.c
gdb/language.c
gdb/language.h
gdb/linespec.c
gdb/m2-lang.h
gdb/m2-typeprint.c
gdb/p-lang.h
gdb/p-typeprint.c
gdb/p-valprint.c
gdb/printcmd.c
gdb/stabsread.c
gdb/stack.c
gdb/symfile.c
gdb/symtab.c
gdb/symtab.h
gdb/testsuite/ChangeLog
gdb/testsuite/carlton_runnamespace
gdb/testsuite/carlton_runtest
gdb/testsuite/gdb.c++/m-data.cc
gdb/testsuite/gdb.c++/m-data.exp
gdb/testsuite/gdb.c++/m-static.cc
gdb/testsuite/gdb.c++/m-static1.cc
gdb/testsuite/gdb.c++/namespace.cc
gdb/testsuite/gdb.c++/namespace.exp
gdb/typeprint.c
gdb/utils.c
gdb/valarith.c
gdb/valops.c
gdb/value.h

index 26ea576e5ea8ad582ab5e5787139f9056ada00b0..a925f6322f13eddfaf5a8013631eff68faf894a3 100644 (file)
@@ -1,3 +1,134 @@
+2002-11-27  David Carlton  <carlton@math.stanford.edu>
+
+       * dwarf2read.c (add_partial_enumeration): New function.
+       (scan_partial_symbols): Call add_partial_enumeration.
+       (locate_pdi_sibling): New function.
+       (scan_partial_symbols): Call locate_pdi_sibling.  Get rid of
+       nesting_level.
+       (pdi_needs_namespace): New function.
+       (add_partial_symbol): Add 'namespace' arg; calculate full name
+       when appropriate.
+       (scan_partial_symbols): Update calls to add_partial_symbol.
+       (add_partial_enumeration): Ditto.
+       (read_enumeration): Add processing_current_prefix to name when
+       appropriate.
+       (new_symbol): Set names of enumerators and typedefs appropriately
+       if processing_has_namespace_info.
+       * symtab.c (lookup_symbol_namespace): Rename 'namespace' argument
+       to 'namespace_name'.
+       * symtab.h: Ditto.
+       * symtab.c (lookup_symbol_namespace): Delete FIXME comments; add a
+       new one.
+       (lookup_symbol_aux_file): New function.
+       (lookup_symbol_aux): Delete FIXME comment.
+       (lookup_symbol_aux): Don't search static block explicitly; delete
+       FIXME comments.
+       * valops.c (value_namespace_elt): Update call to
+       lookup_symbol_namespace.
+       * symtab.h: Update declaration for lookup_symbol_namespace.
+       * symtab.c (lookup_symbol_namespace): Delete 'using' argument and
+       add 'block' argument; get using directives via iterators.
+       (lookup_symbol_aux_using_loop): Delete 'using' argument and add
+       'block' argument.
+       (lookup_symbol_aux_using): Don't calculate using directives.
+       * block.c (block_using_iterator_first): New function.
+       (block_using_iterator_next): Ditto.
+       * block.h: Add comment.
+       (struct block_using_iterator): New struct.
+       Declare block_using_iterator_first, block_using_iterator_next.
+
+2002-11-26  David Carlton  <carlton@math.stanford.edu>
+
+       * dwarf2read.c (read_structure_scope): Set type name and
+       processing_current_prefix appropriately.
+       (new_symbol): Make sure that, in symbols associated to class
+       types, the name includes appropriate namespaces.
+       * buildsym.h: Rename processing_current_namespace to
+       processing_current_prefix.
+       * buildsym.c (finish_block): Ditto.
+       * dwarf2read.c (psymtab_to_symtab_1): Ditto.
+       (read_namespace): Ditto.  Also rename previous_namespace to
+       previous_prefix.
+       
+       Now come a thousand and one const correctness fixes:
+       * p-typeprint.c (pascal_print_type): Const.
+       (pascal_type_print_method_args): Const.
+       * p-lang.h: Const.
+       * m2-typeprint.c (m2_print_type): Const.
+       * valops.c (hand_function_call): Const.
+       * jv-lang.c (java_primitive_type_from_name): Const.
+       * jv-lang.h: Const.
+       * jv-typeprint.c (java_print_type): Const.
+       * language.c: (unk_lang_print_type): Const.
+       * stack.c (frame_info): Const.
+       * linespec.c (find_methods): Const.
+       (find_method_name): Const
+       * f-lang.h: Const.
+       * f-typeprint.c (f_print_type): Const.
+       * c-typeprint.c (c_print_type): Const.
+       * c-lang.h: Const.
+       * gdbtypes.h: Const.
+       * gdbtypes.c (lookup_primitive_typename): Const.
+       * stack.c (print_frame): Const.
+       (func_command): Delete pointless cast.
+       * linespec.c (find_method_name): Const.
+       * language.h: Const.
+       * symfile.c (compare_psymbols): Const.
+       * symtab.c (completion_list_add_name): Const.
+       * breakpoint.c (break_at_finish_at_depth_command_1): Remove
+       useless cast.
+       (break_at_finish_command_1): Ditto.
+       * typeprint.c (type_print): Const.
+       * symtab.h: Const.
+       * symtab.c (gdb_mangle_name): Const.
+       (symbol_init_demangled_name): Const.
+       (symbol_demangled_name): Const.
+       * defs.h: Const.
+       * printcmd.c (build_address_symbolic): Const.
+       * valops.c (search_struct_method): Const.
+       * cp-valprint.c (cp_is_vtbl_ptr_type): Const.
+       (cp_print_value): Const.
+       (cp_print_class_member): Const.
+       * c-typeprint.c (cp_type_print_derivation_info): Const.
+       (c_type_print_varspec_prefix): Const.
+       (c_type_print_base): Const.
+       * p-valprint.c (pascal_object_is_vtbl_ptr_type): Const.
+       (pascal_object_print_value): Const.
+       (pascal_object_print_class_member): Const.
+       * p-typeprint.c (pascal_type_print_derivation_info): Const.
+       (pascal_type_print_varspec_prefix): Const.
+       (pascal_type_print_base): Const.
+       * jv-typeprint.c (java_type_print_base): Const.
+       * jv-lang.h (java_demangle_type_signature): Const.
+       * jv-lang.c (java_demangle_type_signature): Const.
+       (java_demangled_signature_length): Const.
+       (java_demangled_signature_copy): Const.
+       * jv-typeprint.c (java_type_print_derivation_info): Const.
+       * jv-valprint.c (java_value_print): Const.
+       (java_print_value_fields): Const.
+       * jv-lang.c (is_object_type): Const.
+       (evaluate_subexp_java): Const.
+       * stabsread.c (read_cpp_abbrev): Const.
+       (complain_about_struct_wipeout): Const.
+       (cleanup_undefined_types): Const.
+       * gdbtypes.h: Const.
+       * gdbtypes.c (add_name): Second arg const.
+       (lookup_typename): Const.
+       (lookup_unsigned_typename): Const.
+       (lookup_signed_typename): Const.
+       * linespec.c (find_methods): const char *class_name.
+       * symtab.c (gdb_mangle_name): const char *newname.
+       * valops.c (destructor_name_p): const char *dname.
+       (search_struct_field): First arg const.
+       * gdbtypes.c (check_typedef): const char *name (multiple places).
+       (cfront_mangle_name): const char *newname.
+       * gdbtypes.c (add_mangled_type): const char *tname.
+       * valops.c (find_overload_match): const char *obj_type_name.
+       * utils.c (gdb_print_host_address): Make first arg const.
+       * defs.h: Declare first arg of gdb_print_host_address to be
+       const.
+       * valarith.c (find_size_for_pointer_math): const char *name.
+
 2002-11-24  David Carlton  <carlton@bactrian.org>
 
        * Makefile.in (c-typeprint.o): Depend on gdb_assert_h.
index 18b30863970caff949a25df5448d7637e03ca559..dd6557a245d81061bc1bd6c2acb24e095b873eb5 100644 (file)
@@ -154,3 +154,54 @@ block_static_block (const struct block *block)
 
   return block;
 }
+
+/* Initialize ITERATOR to point at the first using directive valid for
+   BLOCK, and return that using directive, or NULL if there aren't
+   any.  */
+
+struct using_direct *
+block_using_iterator_first (const struct block *block,
+                           struct block_using_iterator *iterator)
+{
+  if (block == NULL)
+    return NULL;
+  
+  iterator->current_block = block;
+  iterator->next_node = block_using (block);
+
+  return block_using_iterator_next (iterator);
+}
+
+/* Advance ITERATOR, and return the next using directive, or NULL if
+   there aren't any more.  Don't call this if you've previously
+   received NULL from block_using_iterator_first or
+   block_using_iterator_next during this iteration.  */
+
+struct using_direct *
+block_using_iterator_next (struct block_using_iterator *iterator)
+{
+  if (iterator->next_node != NULL)
+    {
+      struct using_direct *retval = iterator->next_node->current;
+      iterator->next_node = iterator->next_node->next;
+      return retval;
+    }
+  else
+    {
+      while (BLOCK_SUPERBLOCK (iterator->current_block) != NULL)
+       {
+         iterator->current_block
+           = BLOCK_SUPERBLOCK (iterator->current_block);
+         iterator->next_node = block_using (iterator->current_block); 
+         if (iterator->next_node != NULL)
+           {
+             struct using_direct *retval = iterator->next_node->current;
+             iterator->next_node = iterator->next_node->next;
+             return retval;
+           }
+       }
+
+      /* We didn't find any superblocks with using directives.  */
+      return NULL;
+    }
+}
index 6ad2086cee19a4b1e6b38b687d9662a68d1a933b..7e5c0cd3ac4cea52c060e712742352bb133f0b17 100644 (file)
@@ -137,6 +137,11 @@ extern struct symbol *block_function (const struct block *);
 
 extern int contained_in (const struct block *, const struct block *);
 
+/* NOTE: carlton/2002-11-27: I'm a little bit torn about whether many
+   of these should go here or in cp-support.h.  I ended up putting
+   them here, since they really do use the block structure, but one
+   could argue with my decision.  */
+
 extern struct using_direct_node *block_using (const struct block *);
 
 extern struct using_direct_node *block_all_usings (const struct block *block);
@@ -151,3 +156,30 @@ extern void block_set_scope (struct block *block, const char *scope,
                             struct obstack *obstack);
 
 extern const struct block *block_static_block (const struct block *block);
+
+/* In an ideal world, this would be opaque: don't access it directly,
+   just use the iterator functions.  */
+
+struct block_using_iterator
+{
+  const struct block *current_block;
+  const struct using_direct_node *next_node;
+};
+
+/* Initialize ITERATOR to point at the first using directive valid for
+   BLOCK, and return that using directive, or NULL if there aren't
+   any.  */
+
+extern struct
+using_direct *block_using_iterator_first (const struct block *block,
+                                         struct block_using_iterator
+                                         *iterator);
+
+/* Advance ITERATOR, and return the next using directive, or NULL if
+   there aren't any more.  Don't call this if you've previously
+   received NULL from block_using_iterator_first or
+   block_using_iterator_next during this iteration.  */
+
+extern struct
+using_direct *block_using_iterator_next (struct block_using_iterator
+                                        *iterator);
index fed39be3c7892225299c5eb1dc1bd989081aa2ad..df74c3db19c54f462a670d72e0c98af377357d35 100644 (file)
@@ -5005,7 +5005,7 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
 
   if (selected_pc)
     {
-      if (find_pc_partial_function (selected_pc, (char **) NULL, &low, &high))
+      if (find_pc_partial_function (selected_pc, NULL, &low, &high))
        {
          addr_string = (char *) xmalloc (26 + extra_args_len);
          if (extra_args_len)
@@ -5087,7 +5087,7 @@ break_at_finish_command_1 (char *arg, int flag, int from_tty)
   for (i = 0; (i < sals.nelts); i++)
     {
       sal = sals.sals[i];
-      if (find_pc_partial_function (sal.pc, (char **) NULL, &low, &high))
+      if (find_pc_partial_function (sal.pc, NULL, &low, &high))
        {
          break_string = (char *) xmalloc (extra_args_len + 26);
          if (extra_args_len)
index 7d5009baa1b203a44995b102f0f5a21d186dad45..6d0fd5f00d7ea78f01a55c80561ad6aed5ef3837 100644 (file)
@@ -452,7 +452,7 @@ finish_block (struct symbol *symbol, struct pending **listhead,
          const char *next;
 
          if (processing_has_namespace_info)
-           block_set_scope (block, processing_current_namespace,
+           block_set_scope (block, processing_current_prefix,
                             &objfile->symbol_obstack);
          else
            {
index 7249ab868a174b9edc15b682891bd5ca6a328585..92e101ebea32ed59da5f39a1cf2401089bbba5ab 100644 (file)
@@ -100,11 +100,12 @@ EXTERN unsigned char processing_hp_compilation;
 EXTERN unsigned char processing_has_namespace_info;
 
 /* If processing_has_namespace_info is nonzero, this string should
-   contain the name of the current namespace.  Other people shouldn't
-   have to copy it when referring to it, so don't free its previous
-   contents when setting this to a new value.  */
+   contain the name of the current prefix (namespaces plus classes).
+   Other people shouldn't have to copy it when referring to it, so
+   don't free its previous contents when setting this to a new
+   value.  */
 
-EXTERN const char *processing_current_namespace;
+EXTERN const char *processing_current_prefix;
 
 /* Count symbols as they are processed, for error messages.  */
 
index 7d7cd03a55771645d94c1d217a54e904af3d550b..0c6c730ab0502f29c9043ef9de195f3ef342f91c 100644 (file)
@@ -32,7 +32,7 @@ extern int c_parse (void);    /* Defined in c-exp.y */
 extern void c_error (char *);  /* Defined in c-exp.y */
 
 /* Defined in c-typeprint.c */
-extern void c_print_type (struct type *, char *, struct ui_file *, int,
+extern void c_print_type (struct type *, const char *, struct ui_file *, int,
                          int);
 
 extern int c_val_print (struct type *, char *, int, CORE_ADDR,
index e29973866603b63dbed20f92d5aa8d36584e221c..07a84497fdb855d01f557a4f6998d0f246341cfb 100644 (file)
@@ -63,7 +63,7 @@ static void c_type_print_modifier (struct type *, struct ui_file *,
 /* LEVEL is the depth to indent lines by.  */
 
 void
-c_print_type (struct type *type, char *varstring, struct ui_file *stream,
+c_print_type (struct type *type, const char *varstring, struct ui_file *stream,
              int show, int level)
 {
   register enum type_code code;
@@ -132,7 +132,7 @@ c_print_type (struct type *type, char *varstring, struct ui_file *stream,
 static void
 cp_type_print_derivation_info (struct ui_file *stream, struct type *type)
 {
-  char *name;
+  const char *name;
   int i;
 
   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
@@ -205,7 +205,7 @@ void
 c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
                             int show, int passed_a_ptr, int need_post_space)
 {
-  char *name;
+  const char *name;
   if (type == 0)
     return;
 
@@ -933,7 +933,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
              struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
              int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
              char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
-             char *name = type_name_no_tag (type);
+             const char *name = type_name_no_tag (type);
              int is_constructor = name && STREQ (method_name, name);
              for (j = 0; j < len2; j++)
                {
index f362d8475369202fe4771f9be4b4796dc4a48474..33b476ce897fb741c1f57500523b3dba09b9a967 100644 (file)
@@ -174,7 +174,7 @@ const char hpacc_vtbl_ptr_type_name[] = "__vftyp";
 int
 cp_is_vtbl_ptr_type (struct type *type)
 {
-  char *typename = type_name_no_tag (type);
+  const char *typename = type_name_no_tag (type);
 
   return (typename != NULL && !strcmp (typename, vtbl_ptr_name));
 }
@@ -520,7 +520,7 @@ cp_print_value (struct type *type, struct type *real_type, char *valaddr,
       int boffset;
       int skip;
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
-      char *basename = TYPE_NAME (baseclass);
+      const char *basename = TYPE_NAME (baseclass);
       char *base_valaddr;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -717,7 +717,7 @@ cp_print_class_member (char *valaddr, struct type *domain,
     }
   if (i < len)
     {
-      char *name;
+      const char *name;
       fprintf_filtered (stream, prefix);
       name = type_name_no_tag (domain);
       if (name)
index 48eb509ebe6a49f7ca5c27ead7bc26dc52e6807c..eded2389f7b1ec0f048739c6391d89780f5c7f2f 100644 (file)
@@ -480,7 +480,7 @@ extern void fputstr_unfiltered (const char *str, int quotr, struct ui_file * str
 extern void fputstrn_unfiltered (const char *str, int n, int quotr, struct ui_file * stream);
 
 /* Display the host ADDR on STREAM formatted as ``0x%x''. */
-extern void gdb_print_host_address (void *addr, struct ui_file *stream);
+extern void gdb_print_host_address (const void *addr, struct ui_file *stream);
 
 /* Convert a CORE_ADDR into a HEX string.  paddr() is like %08lx.
    paddr_nz() is like %lx.  paddr_u() is like %lu. paddr_width() is
@@ -501,7 +501,7 @@ extern const char *core_addr_to_string (const CORE_ADDR addr);
 extern const char *core_addr_to_string_nz (const CORE_ADDR addr);
 extern CORE_ADDR string_to_core_addr (const char *my_string);
 
-extern void fprintf_symbol_filtered (struct ui_file *, char *,
+extern void fprintf_symbol_filtered (struct ui_file *, const char *,
                                     enum language, int);
 
 extern NORETURN void perror_with_name (const char *) ATTR_NORETURN;
index 07375390cfa5b4425e2a57dd6778432cd8c94346..0c5bb17f22dc582859f1702d11c4ec7a8905656e 100644 (file)
@@ -711,7 +711,10 @@ static char *scan_partial_symbols (char *, struct objfile *,
                                   const char *namespace);
 
 static void add_partial_symbol (struct partial_die_info *, struct objfile *,
-                               const struct comp_unit_head *);
+                               const struct comp_unit_head *,
+                               const char *namespace);
+
+static int pdi_needs_namespace (enum dwarf_tag tag, const char *namespace);
 
 static char *add_partial_namespace (struct partial_die_info *pdi,
                                    char *info_ptr,
@@ -720,6 +723,17 @@ static char *add_partial_namespace (struct partial_die_info *pdi,
                                    const struct comp_unit_head *cu_header,
                                    const char *namespace);
 
+static char *add_partial_enumeration (struct partial_die_info *enum_pdi,
+                                     char *info_ptr,
+                                     struct objfile *objfile,
+                                     const struct comp_unit_head *cu_header,
+                                     const char *namespace);
+
+static char *locate_pdi_sibling (struct partial_die_info *orig_pdi,
+                                char *info_ptr,
+                                bfd *abfd,
+                                const struct comp_unit_head *cu_header);
+
 static void dwarf2_psymtab_to_symtab (struct partial_symtab *);
 
 static void psymtab_to_symtab_1 (struct partial_symtab *);
@@ -1347,9 +1361,9 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
 /* Read in all interesting dies to the end of the compilation unit or
    to the end of the current namespace.  NAMESPACE is NULL if we
    haven't yet encountered any DW_TAG_namespace entries; otherwise,
-   it's the name of the current namespace.  (In particular, it's the
+   it's the name of the current namespace.  In particular, it's the
    empty string if we're currently in the global namespace but have
-   previously encountered a DW_TAG_namespace.)  */
+   previously encountered a DW_TAG_namespace.  */
 
 static char *
 scan_partial_symbols (char *info_ptr, struct objfile *objfile,
@@ -1360,21 +1374,20 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
   bfd *abfd = objfile->obfd;
   struct partial_die_info pdi;
 
-  /* This function is called after we've read in the comp_unit_die in
-     order to read its children.  We start the nesting level at 1 since
-     we have pushed 1 level down in order to read the comp unit's children.
-     The comp unit itself is at level 0, so we stop reading when we pop
-     back to that level. */
+  /* Now, march along the PDI's, descending into ones which have
+     interesting children but skipping the children of the other ones,
+     until we reach the end of the compilation unit.  */
 
-  int nesting_level = 1;
-
-  while (nesting_level)
+  while (1)
     {
       info_ptr = read_partial_die (&pdi, abfd, info_ptr, cu_header);
 
-      /* Anonymous namespaces have no name but are interesting.  */
+      /* Anonymous namespaces have no name but have interesting
+        children, so we need to look at them.  Ditto for anonymous
+        enums.  */
 
-      if (pdi.name != NULL || pdi.tag == DW_TAG_namespace)
+      if (pdi.name != NULL || pdi.tag == DW_TAG_namespace
+         || pdi.tag == DW_TAG_enumeration_type)
        {
          switch (pdi.tag)
            {
@@ -1389,10 +1402,9 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
                    {
                      *highpc = pdi.highpc;
                    }
-                 if ((pdi.is_external || nesting_level == 1)
-                     && !pdi.is_declaration)
+                 if (!pdi.is_declaration)
                    {
-                     add_partial_symbol (&pdi, objfile, cu_header);
+                     add_partial_symbol (&pdi, objfile, cu_header, namespace);
                    }
                }
              break;
@@ -1401,26 +1413,23 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
            case DW_TAG_class_type:
            case DW_TAG_structure_type:
            case DW_TAG_union_type:
-           case DW_TAG_enumeration_type:
-             if ((pdi.is_external || nesting_level == 1)
-                 && !pdi.is_declaration)
+             if (!pdi.is_declaration)
                {
-                 add_partial_symbol (&pdi, objfile, cu_header);
+                 add_partial_symbol (&pdi, objfile, cu_header, namespace);
                }
              break;
-           case DW_TAG_enumerator:
-             /* File scope enumerators are added to the partial
-                symbol table.  They're children of the enumeration
-                type die, so they occur at a level one higher than we
-                normally look for.  */
-             if (nesting_level == 2)
-               add_partial_symbol (&pdi, objfile, cu_header);
+           case DW_TAG_enumeration_type:
+             if (!pdi.is_declaration)
+               {
+                 info_ptr = add_partial_enumeration (&pdi, info_ptr,
+                                                     objfile, cu_header,
+                                                     namespace);
+               }
              break;
            case DW_TAG_base_type:
              /* File scope base type definitions are added to the partial
                 symbol table.  */
-             if (nesting_level == 1)
-               add_partial_symbol (&pdi, objfile, cu_header);
+             add_partial_symbol (&pdi, objfile, cu_header, namespace);
              break;
            case DW_TAG_namespace:
              /* We've hit a DW_TAG_namespace entry, so we know this
@@ -1436,26 +1445,16 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
            }
        }
 
-      /* If the die has a sibling, skip to the sibling.  Do not skip
-         enumeration types, we want to record their enumerators.  Do
-         not skip namespaces, the add_partial_namespace call has
-         already updated info_ptr for us.  */
-      if (pdi.sibling
-         && pdi.tag != DW_TAG_enumeration_type
-         && pdi.tag != DW_TAG_namespace)
-       {
-         info_ptr = pdi.sibling;
-       }
-      else if (pdi.has_children && pdi.tag != DW_TAG_namespace)
-       {
-         /* Die has children, but either the optional DW_AT_sibling
-            attribute is missing or we want to look at them.  */
-         nesting_level++;
-       }
-
       if (pdi.tag == 0)
+       break;
+
+      /* If the die has a sibling, skip to the sibling, unless another
+        function has already updated info_ptr for us.  */
+
+      if (pdi.tag != DW_TAG_enumeration_type
+         && pdi.tag != DW_TAG_namespace)
        {
-         nesting_level--;
+         info_ptr = locate_pdi_sibling (&pdi, info_ptr, abfd, cu_header);
        }
     }
 
@@ -1464,27 +1463,40 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
 
 static void
 add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
-                   const struct comp_unit_head *cu_header)
+                   const struct comp_unit_head *cu_header,
+                   const char *namespace)
 {
   CORE_ADDR addr = 0;
+  char *actual_name = pdi->name;
+
+  /* If we're not in the global namespace and if the namespace name
+     isn't encoded in a mangled actual_name, add it.  */
+  
+  if (pdi_needs_namespace (pdi->tag, namespace))
+    {
+      actual_name = alloca (strlen (pdi->name) + 2 + strlen (namespace) + 1);
+      strcpy (actual_name, namespace);
+      strcat (actual_name, "::");
+      strcat (actual_name, pdi->name);
+    }
 
   switch (pdi->tag)
     {
     case DW_TAG_subprogram:
       if (pdi->is_external)
        {
-         /*prim_record_minimal_symbol (pdi->name, pdi->lowpc + baseaddr,
+         /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
             mst_text, objfile); */
-         add_psymbol_to_list (pdi->name, strlen (pdi->name),
+         add_psymbol_to_list (actual_name, strlen (actual_name),
                               VAR_NAMESPACE, LOC_BLOCK,
                               &objfile->global_psymbols,
                            0, pdi->lowpc + baseaddr, cu_language, objfile);
        }
       else
        {
-         /*prim_record_minimal_symbol (pdi->name, pdi->lowpc + baseaddr,
+         /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
             mst_file_text, objfile); */
-         add_psymbol_to_list (pdi->name, strlen (pdi->name),
+         add_psymbol_to_list (actual_name, strlen (actual_name),
                               VAR_NAMESPACE, LOC_BLOCK,
                               &objfile->static_psymbols,
                            0, pdi->lowpc + baseaddr, cu_language, objfile);
@@ -1509,7 +1521,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
          if (pdi->locdesc)
            addr = decode_locdesc (pdi->locdesc, objfile, cu_header);
          if (pdi->locdesc || pdi->has_type)
-           add_psymbol_to_list (pdi->name, strlen (pdi->name),
+           add_psymbol_to_list (actual_name, strlen (actual_name),
                                 VAR_NAMESPACE, LOC_STATIC,
                                 &objfile->global_psymbols,
                                 0, addr + baseaddr, cu_language, objfile);
@@ -1520,9 +1532,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
          if (pdi->locdesc == NULL)
            return;
          addr = decode_locdesc (pdi->locdesc, objfile, cu_header);
-         /*prim_record_minimal_symbol (pdi->name, addr + baseaddr,
+         /*prim_record_minimal_symbol (actual_name, addr + baseaddr,
             mst_file_data, objfile); */
-         add_psymbol_to_list (pdi->name, strlen (pdi->name),
+         add_psymbol_to_list (actual_name, strlen (actual_name),
                               VAR_NAMESPACE, LOC_STATIC,
                               &objfile->static_psymbols,
                               0, addr + baseaddr, cu_language, objfile);
@@ -1530,7 +1542,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
       break;
     case DW_TAG_typedef:
     case DW_TAG_base_type:
-      add_psymbol_to_list (pdi->name, strlen (pdi->name),
+      add_psymbol_to_list (actual_name, strlen (actual_name),
                           VAR_NAMESPACE, LOC_TYPEDEF,
                           &objfile->static_psymbols,
                           0, (CORE_ADDR) 0, cu_language, objfile);
@@ -1543,7 +1555,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
          references.  */
       if (pdi->has_children == 0)
        return;
-      add_psymbol_to_list (pdi->name, strlen (pdi->name),
+      add_psymbol_to_list (actual_name, strlen (actual_name),
                           STRUCT_NAMESPACE, LOC_TYPEDEF,
                           &objfile->static_psymbols,
                           0, (CORE_ADDR) 0, cu_language, objfile);
@@ -1551,14 +1563,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
       if (cu_language == language_cplus)
        {
          /* For C++, these implicitly act as typedefs as well. */
-         add_psymbol_to_list (pdi->name, strlen (pdi->name),
+         add_psymbol_to_list (actual_name, strlen (actual_name),
                               VAR_NAMESPACE, LOC_TYPEDEF,
                               &objfile->static_psymbols,
                               0, (CORE_ADDR) 0, cu_language, objfile);
        }
       break;
     case DW_TAG_enumerator:
-      add_psymbol_to_list (pdi->name, strlen (pdi->name),
+      add_psymbol_to_list (actual_name, strlen (actual_name),
                           VAR_NAMESPACE, LOC_CONST,
                           &objfile->static_psymbols,
                           0, (CORE_ADDR) 0, cu_language, objfile);
@@ -1568,6 +1580,26 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
     }
 }
 
+static int
+pdi_needs_namespace (enum dwarf_tag tag, const char *namespace)
+{
+  if (namespace == NULL || namespace[0] == '\0')
+    return 0;
+
+  switch (tag)
+    {
+    case DW_TAG_typedef:
+    case DW_TAG_class_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_union_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_enumerator:
+      return 1;
+    default:
+      return 0;
+    }
+}
+
 /* Read a partial die corresponding to a namespace; also, add a symbol
    corresponding to that namespace to the symbol table.  NAMESPACE is
    the name of the enclosing namespace.  */
@@ -1604,6 +1636,66 @@ add_partial_namespace (struct partial_die_info *pdi, char *info_ptr,
   return info_ptr;
 }
 
+/* Read a partial die corresponding to an enumeration type.  */
+
+static char *
+add_partial_enumeration (struct partial_die_info *enum_pdi, char *info_ptr,
+                        struct objfile *objfile,
+                        const struct comp_unit_head *cu_header,
+                        const char *namespace)
+{
+  bfd *abfd = objfile->obfd;
+  struct partial_die_info pdi;
+
+  if (enum_pdi->name != NULL)
+    add_partial_symbol (enum_pdi, objfile, cu_header, namespace);
+  
+  while (1)
+    {
+      info_ptr = read_partial_die (&pdi, abfd, info_ptr, cu_header);
+      if (pdi.tag == 0)
+       break;
+      gdb_assert (pdi.tag == DW_TAG_enumerator);
+      gdb_assert (pdi.name != NULL);
+      add_partial_symbol (&pdi, objfile, cu_header, namespace);
+    }
+
+  return info_ptr;
+}
+
+/* Locate ORIG_PDI's sibling; INFO_PTR points to the next PDI after
+   ORIG_PDI.  */
+
+static char *
+locate_pdi_sibling (struct partial_die_info *orig_pdi, char *info_ptr,
+                   bfd *abfd, const struct comp_unit_head *cu_header)
+{
+  /* Do we know the sibling already?  */
+  
+  if (orig_pdi->sibling)
+    return orig_pdi->sibling;
+
+  /* Are there any children to deal with?  */
+
+  if (!orig_pdi->has_children)
+    return info_ptr;
+
+  /* Okay, we don't know the sibling, but we have children that we
+     want to skip.  So read children until we run into one without a
+     tag; return whatever follows it.  */
+
+  while (1)
+    {
+      struct partial_die_info pdi;
+      
+      info_ptr = read_partial_die (&pdi, abfd, info_ptr, cu_header);
+
+      if (pdi.tag == 0)
+       return info_ptr;
+      else
+       info_ptr = locate_pdi_sibling (&pdi, info_ptr, abfd, cu_header);
+    }
+}
 
 /* Expand this partial symbol table into a full symbol table.  */
 
@@ -1664,7 +1756,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
   info_ptr = dwarf_info_buffer + offset;
 
   /* We're in the global namespace.  */
-  processing_current_namespace = "";
+  processing_current_prefix = "";
 
   obstack_init (&dwarf2_tmp_obstack);
   back_to = make_cleanup (dwarf2_free_tmp_obstack, NULL);
@@ -2592,6 +2684,7 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
   struct type *type;
   struct attribute *attr;
   char *name;
+  const char *previous_prefix = processing_current_prefix;
 
   type = alloc_type (objfile);
 
@@ -2599,8 +2692,26 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
   name = dwarf2_name (die);
   if (name != NULL)
     {
-      TYPE_TAG_NAME (type) = obsavestring (name, strlen (name),
-                                          &objfile->type_obstack);
+      if (processing_has_namespace_info)
+       {
+         /* FIXME: carlton/2002-11-26: This variable exists only for
+            const-correctness reasons.  When I tried to change
+            TYPE_TAG_NAME to be a const char *, I ran into a cascade
+            of changes which would have forced decode_line_1 to take
+            a const char **.  */
+         char *new_prefix = obconcat (&objfile->type_obstack,
+                                      previous_prefix,
+                                      previous_prefix[0] == '\0'
+                                      ? "" : "::",
+                                      name);
+         TYPE_TAG_NAME (type) = new_prefix;
+         processing_current_prefix = new_prefix;
+       }
+      else
+       {
+         TYPE_TAG_NAME (type) = obsavestring (name, strlen (name),
+                                              &objfile->type_obstack);
+       }
     }
 
   if (die->tag == DW_TAG_structure_type)
@@ -2730,6 +2841,8 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
       /* No children, must be stub. */
       TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
     }
+
+  processing_current_prefix = previous_prefix;
 }
 
 /* Given a pointer to a die which begins an enumeration, process all
@@ -2760,8 +2873,19 @@ read_enumeration (struct die_info *die, struct objfile *objfile,
   name = dwarf2_name (die);
   if (name != NULL)
     {
-      TYPE_TAG_NAME (type) = obsavestring (name, strlen (name),
-                                          &objfile->type_obstack);
+      if (processing_has_namespace_info)
+       {
+         TYPE_TAG_NAME (type) = obconcat (&objfile->type_obstack,
+                                          processing_current_prefix,
+                                          processing_current_prefix[0] == '\0'
+                                          ? "" : "::",
+                                          name);
+       }
+      else
+       {
+         TYPE_TAG_NAME (type) = obsavestring (name, strlen (name),
+                                              &objfile->type_obstack);
+       }
     }
 
   attr = dwarf_attr (die, DW_AT_byte_size);
@@ -3036,7 +3160,7 @@ static void
 read_namespace (struct die_info *die, struct objfile *objfile,
                const struct comp_unit_head *cu_header)
 {
-  const char *previous_namespace = processing_current_namespace;
+  const char *previous_prefix = processing_current_prefix;
   const char *name = NULL;
   int is_anonymous;
   struct die_info *current_die;
@@ -3059,19 +3183,19 @@ read_namespace (struct die_info *die, struct objfile *objfile,
 
   /* Now build the name of the current namespace.  */
 
-  processing_current_namespace = obconcat (&objfile->symbol_obstack,
-                                          previous_namespace,
-                                          previous_namespace[0] == '\0'
-                                          ? "" : "::",
-                                          name);
+  processing_current_prefix = obconcat (&objfile->symbol_obstack,
+                                       previous_prefix,
+                                       previous_prefix[0] == '\0'
+                                       ? "" : "::",
+                                       name);
 
   /* If it's an anonymous namespace that we're seeing for the first
      time, add a using directive.  */
 
   if (is_anonymous && dwarf_attr (die, DW_AT_extension) == NULL)
-    add_using_directive (processing_current_namespace,
-                        strlen (previous_namespace),
-                        strlen (processing_current_namespace));
+    add_using_directive (processing_current_prefix,
+                        strlen (previous_prefix),
+                        strlen (processing_current_prefix));
   
   
   if (die->has_children)
@@ -3085,7 +3209,7 @@ read_namespace (struct die_info *die, struct objfile *objfile,
        }
     }
 
-  processing_current_namespace = previous_namespace;
+  processing_current_prefix = previous_prefix;
 }
 
 /* Extract all information from a DW_TAG_pointer_type DIE and add to
@@ -5098,6 +5222,24 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
        case DW_TAG_enumeration_type:
          SYMBOL_CLASS (sym) = LOC_TYPEDEF;
          SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
+
+         /* Make sure that the symbol includes appropriate
+            namespaces in its name.  */
+
+         if (processing_has_namespace_info)
+           {
+             struct type *type = SYMBOL_TYPE (sym);
+             
+             if (TYPE_TAG_NAME (type) != NULL)
+               {
+                 SYMBOL_NAME (sym)
+                   = obsavestring (TYPE_TAG_NAME (type),
+                                   strlen (TYPE_TAG_NAME (type)),
+                                   &objfile->symbol_obstack);
+                 gdb_assert (SYMBOL_DEMANGLED_NAME (sym) == NULL);
+               }
+           }
+         
          add_symbol_to_list (sym, list_in_scope);
 
          /* The semantics of C++ state that "struct foo { ... }" also
@@ -5119,12 +5261,32 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
            }
          break;
        case DW_TAG_typedef:
+         if (processing_has_namespace_info
+             && processing_current_prefix[0] != '\0')
+           {
+             SYMBOL_NAME (sym) = obconcat (&objfile->symbol_obstack,
+                                           processing_current_prefix,
+                                           "::",
+                                           name);
+           }
+         SYMBOL_CLASS (sym) = LOC_TYPEDEF;
+         SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+         add_symbol_to_list (sym, list_in_scope);
+         break;
        case DW_TAG_base_type:
          SYMBOL_CLASS (sym) = LOC_TYPEDEF;
          SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
          add_symbol_to_list (sym, list_in_scope);
          break;
        case DW_TAG_enumerator:
+         if (processing_has_namespace_info
+             && processing_current_prefix[0] != '\0')
+           {
+             SYMBOL_NAME (sym) = obconcat (&objfile->symbol_obstack,
+                                           processing_current_prefix,
+                                           "::",
+                                           name);
+           }
          attr = dwarf_attr (die, DW_AT_const_value);
          if (attr)
            {
index d929b919fc0a51be7f3439967f7e299aff44af5f..26be322e8c470dbea89867c0f90cfaf636c291e6 100644 (file)
@@ -25,7 +25,7 @@ extern int f_parse (void);
 
 extern void f_error (char *);  /* Defined in f-exp.y */
 
-extern void f_print_type (struct type *, char *, struct ui_file *, int,
+extern void f_print_type (struct type *, const char *, struct ui_file *, int,
                          int);
 
 extern int f_val_print (struct type *, char *, int, CORE_ADDR,
index 2eba3912401bcf20878351dc7b216f2a07a42ed5..1b9a9b258c112976b5ae81cfc8f9c7374641a7ad 100644 (file)
@@ -55,7 +55,8 @@ void f_type_print_base (struct type *, struct ui_file *, int, int);
 /* LEVEL is the depth to indent lines by.  */
 
 void
-f_print_type (struct type *type, char *varstring, struct ui_file *stream,
+f_print_type (struct type *type, const char *varstring,
+             struct ui_file *stream,
              int show, int level)
 {
   register enum type_code code;
index 1df5c21c9e26a3c7228a58006980dd009a6f4d9b..5b283277fe9324d1f60117d4a62257a5bb588472 100644 (file)
@@ -126,7 +126,7 @@ struct extra
     int len;
   };                           /* maximum extension is 128! FIXME */
 
-static void add_name (struct extra *, char *);
+static void add_name (struct extra *, const char *);
 static void add_mangled_type (struct extra *, struct type *);
 #if 0
 static void cfront_mangle_name (struct type *, int, int);
@@ -1015,7 +1015,7 @@ type_name_no_tag (register const struct type *type)
    Return zero if NAME is not a primitive type. */
 
 struct type *
-lookup_primitive_typename (char *name)
+lookup_primitive_typename (const char *name)
 {
   struct type **const *p;
 
@@ -1034,7 +1034,7 @@ lookup_primitive_typename (char *name)
    If NOERR is nonzero, return zero if NAME is not suitably defined.  */
 
 struct type *
-lookup_typename (char *name, struct block *block, int noerr)
+lookup_typename (const char *name, struct block *block, int noerr)
 {
   register struct symbol *sym;
   register struct type *tmp;
@@ -1060,7 +1060,7 @@ lookup_typename (char *name, struct block *block, int noerr)
 }
 
 struct type *
-lookup_unsigned_typename (char *name)
+lookup_unsigned_typename (const char *name)
 {
   char *uns = alloca (strlen (name) + 10);
 
@@ -1070,7 +1070,7 @@ lookup_unsigned_typename (char *name)
 }
 
 struct type *
-lookup_signed_typename (char *name)
+lookup_signed_typename (const char *name)
 {
   struct type *t;
   char *uns = alloca (strlen (name) + 8);
@@ -1354,7 +1354,7 @@ check_typedef (struct type *type)
     {
       if (!TYPE_TARGET_TYPE (type))
        {
-         char *name;
+         const char *name;
          struct symbol *sym;
 
          /* It is dangerous to call lookup_symbol if we are currently
@@ -1392,7 +1392,7 @@ check_typedef (struct type *type)
 
   if (TYPE_IS_OPAQUE (type) && opaque_type_resolution && !currently_reading_symtab)
     {
-      char *name = type_name_no_tag (type);
+      const char *name = type_name_no_tag (type);
       struct type *newtype;
       if (name == NULL)
        {
@@ -1406,7 +1406,7 @@ check_typedef (struct type *type)
   /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
   else if (TYPE_STUB (type) && !currently_reading_symtab)
     {
-      char *name = type_name_no_tag (type);
+      const char *name = type_name_no_tag (type);
       /* FIXME: shouldn't we separately check the TYPE_NAME and the
          TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
          as appropriate?  (this code was written before TYPE_NAME and
@@ -1460,7 +1460,7 @@ check_typedef (struct type *type)
 #define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; }
 
 static void
-add_name (struct extra *pextras, char *n)
+add_name (struct extra *pextras, const char *n)
 {
   int nlen;
 
@@ -1475,7 +1475,7 @@ add_mangled_type (struct extra *pextras, struct type *t)
 {
   enum type_code tcode;
   int tlen, tflags;
-  char *tname;
+  const char *tname;
 
   tcode = TYPE_CODE (t);
   tlen = TYPE_LENGTH (t);
@@ -1617,7 +1617,7 @@ cfront_mangle_name (struct type *type, int i, int j)
       struct fn_field *method = &f[j];
       char *field_name = TYPE_FN_FIELDLIST_NAME (type, i);
       char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
-      char *newname = type_name_no_tag (type);
+      const char *newname = type_name_no_tag (type);
 
       struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
       int nargs = TYPE_NFIELDS (ftype);                /* number of args */
index 450aac9302c128acd4aa8adc473c626a2c9d39f0..91f156e3297cc2051bac08f55c1c829a51b1e51c 100644 (file)
@@ -1138,9 +1138,9 @@ extern struct type *create_set_type (struct type *, struct type *);
 
 /* OBSOLETE extern int chill_varying_type (struct type *); */
 
-extern struct type *lookup_unsigned_typename (char *);
+extern struct type *lookup_unsigned_typename (const char *);
 
-extern struct type *lookup_signed_typename (char *);
+extern struct type *lookup_signed_typename (const char *);
 
 extern struct type *check_typedef (struct type *);
 
@@ -1148,13 +1148,13 @@ extern struct type *check_typedef (struct type *);
 
 extern void check_stub_method_group (struct type *, int);
 
-extern struct type *lookup_primitive_typename (char *);
+extern struct type *lookup_primitive_typename (const char *);
 
 extern char *gdb_mangle_name (struct type *, int, int);
 
 extern struct type *builtin_type (char **);
 
-extern struct type *lookup_typename (char *, struct block *, int);
+extern struct type *lookup_typename (const char *, struct block *, int);
 
 extern struct type *lookup_template_type (char *, struct type *,
                                          struct block *);
index 4f60a4af6c5ec58c87f87a37519e9645607944b3..8e6a69858f56538b705ef0c29a28e478085904f2 100644 (file)
@@ -51,8 +51,8 @@ struct type *java_void_type;
 
 extern void _initialize_java_language (void);
 
-static int java_demangled_signature_length (char *);
-static void java_demangled_signature_copy (char *, char *);
+static int java_demangled_signature_length (const char *);
+static void java_demangled_signature_copy (char *, const char *);
 
 static struct symtab *get_java_class_symtab (void);
 static char *get_java_utf8_name (struct obstack *obstack, struct value *name);
@@ -608,7 +608,7 @@ is_object_type (struct type *type)
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
     {
       struct type *ttype = check_typedef (TYPE_TARGET_TYPE (type));
-      char *name;
+      const char *name;
       if (TYPE_CODE (ttype) != TYPE_CODE_STRUCT)
        return 0;
       while (TYPE_N_BASECLASSES (ttype) > 0)
@@ -658,7 +658,7 @@ java_primitive_type (int signature)
    return that type.  Otherwise, return NULL. */
 
 struct type *
-java_primitive_type_from_name (char *name, int namelen)
+java_primitive_type_from_name (const char *name, int namelen)
 {
   switch (name[0])
     {
@@ -703,7 +703,7 @@ java_primitive_type_from_name (char *name, int namelen)
    signature string SIGNATURE. */
 
 static int
-java_demangled_signature_length (char *signature)
+java_demangled_signature_length (const char *signature)
 {
   int array = 0;
   for (; *signature == '['; signature++)
@@ -721,7 +721,7 @@ java_demangled_signature_length (char *signature)
 /* Demangle the Java type signature SIGNATURE, leaving the result in RESULT. */
 
 static void
-java_demangled_signature_copy (char *result, char *signature)
+java_demangled_signature_copy (char *result, const char *signature)
 {
   int array = 0;
   char *ptr;
@@ -746,11 +746,14 @@ java_demangled_signature_copy (char *result, char *signature)
        }
       break;
     default:
-      ptr = TYPE_NAME (java_primitive_type (signature[0]));
-      i = strlen (ptr);
-      strcpy (result, ptr);
-      ptr = result + i;
-      break;
+      {
+       const char *tempptr
+         = TYPE_NAME (java_primitive_type (signature[0]));
+       i = strlen (tempptr);
+       strcpy (result, tempptr);
+       ptr = result + i;
+       break;
+      }
     }
   while (--array >= 0)
     {
@@ -763,7 +766,7 @@ java_demangled_signature_copy (char *result, char *signature)
    as a freshly allocated copy. */
 
 char *
-java_demangle_type_signature (char *signature)
+java_demangle_type_signature (const char *signature)
 {
   int length = java_demangled_signature_length (signature);
   char *result = xmalloc (length + 1);
@@ -854,7 +857,7 @@ evaluate_subexp_java (struct type *expect_type, register struct expression *exp,
 {
   int pc = *pos;
   int i;
-  char *name;
+  const char *name;
   enum exp_opcode op = exp->elts[*pos].opcode;
   struct value *arg1;
   struct value *arg2;
index 61fb9430aedf7d2fd65b3d18ee613b23aff6eeec..e13e7326175ccc452cb74a498f3870dee23284f2 100644 (file)
@@ -53,7 +53,7 @@ extern struct type *type_from_class (struct value *);
 
 extern struct type *java_primitive_type (int signature);
 
-extern struct type *java_primitive_type_from_name (char *, int);
+extern struct type *java_primitive_type_from_name (const char *, int);
 
 extern struct type *java_array_type (struct type *, int);
 
@@ -65,9 +65,10 @@ extern struct type *java_lookup_class (char *);
 extern int is_object_type (struct type *);
 
 /* Defined in jv-typeprint.c */
-extern void java_print_type (struct type *, char *, struct ui_file *, int,
+extern void java_print_type (struct type *, const char *,
+                            struct ui_file *, int,
                             int);
 
-extern char *java_demangle_type_signature (char *);
+extern char *java_demangle_type_signature (const char *);
 
 #endif
index 893082cc187ebb9e7498024cc670c2bad7c60768..ab15f46c076259a760152b8c8ae9173fdd7df645 100644 (file)
@@ -39,7 +39,7 @@ static void java_type_print_base (struct type * type,
 static void
 java_type_print_derivation_info (struct ui_file *stream, struct type *type)
 {
-  char *name;
+  const char *name;
   int i;
   int n_bases;
   int prev;
@@ -208,7 +208,7 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show,
              struct fn_field *f;
              int j;
              char *method_name;
-             char *name;
+             const char *name;
              int is_constructor;
              int n_overloads;
 
@@ -322,7 +322,8 @@ extern void c_type_print_varspec_suffix (struct type *, struct ui_file *,
                                         int, int, int);
 
 void
-java_print_type (struct type *type, char *varstring, struct ui_file *stream,
+java_print_type (struct type *type, const char *varstring,
+                struct ui_file *stream,
                 int show, int level)
 {
   int demangled_args;
index 1ddfcb576c66e91f8681db3eadd1aa9307ff7528..38439aa2fc68feeb5740c910a9562cd9e783e661 100644 (file)
@@ -48,7 +48,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
   struct type *type;
   CORE_ADDR address;
   int i;
-  char *name;
+  const char *name;
 
   type = VALUE_TYPE (val);
   address = VALUE_ADDRESS (val) + VALUE_OFFSET (val);
@@ -262,7 +262,7 @@ java_print_value_fields (struct type *type, char *valaddr, CORE_ADDR address,
        {
          int boffset;
          struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
-         char *basename = TYPE_NAME (baseclass);
+         const char *basename = TYPE_NAME (baseclass);
          char *base_valaddr;
 
          if (BASETYPE_VIA_VIRTUAL (type, i))
index 3941920108036ab9fe93fe17396df700e2d1ff5e..6d5d9611ee7067c38a55da357025132a5832d144 100644 (file)
@@ -89,7 +89,7 @@ static void unk_lang_printstr (struct ui_file * stream, char *string,
 
 static struct type *unk_lang_create_fundamental_type (struct objfile *, int);
 
-static void unk_lang_print_type (struct type *, char *, struct ui_file *,
+static void unk_lang_print_type (struct type *, const char *, struct ui_file *,
                                 int, int);
 
 static int unk_lang_val_print (struct type *, char *, int, CORE_ADDR,
@@ -1393,7 +1393,7 @@ unk_lang_create_fundamental_type (struct objfile *objfile, int typeid)
 }
 
 static void
-unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
+unk_lang_print_type (struct type *type, const char *varstring, struct ui_file *stream,
                     int show, int level)
 {
   error ("internal error - unimplemented function unk_lang_print_type called.");
index b15544fead924083c5e6548f272921b4ed4e69e8..683d90dd45bebec1d713a77cd3a0d338ff004692 100644 (file)
@@ -188,7 +188,7 @@ struct language_defn
 
     /* Print a type using syntax appropriate for this language. */
 
-    void (*la_print_type) (struct type *, char *, struct ui_file *, int,
+    void (*la_print_type) (struct type *, const char *, struct ui_file *, int,
                           int);
 
     /* Print a value using syntax appropriate for this language. */
index 9803011c5bed632c89bfc1042ef083c67fc3d475..952d51d2c231f2cf293ae1c5e786176b4462f43b 100644 (file)
@@ -79,8 +79,9 @@ static int count_methods (struct type *class_type, char *method,
 static int find_methods (struct type *class_type, char *method,
                         struct symbol **sym_arr);
 
-static char *find_method_name (struct type *class_type, int method_counter,
-                              char *dem_opname);
+static const char *find_method_name (struct type *class_type,
+                                    int method_counter,
+                                    char *dem_opname);
 
 static int add_matching_methods (int method_counter, struct type *class_type,
                                 struct symbol **sym_arr);
@@ -896,7 +897,7 @@ find_methods (struct type *class_type, char *method,
 {
   int count = 0;
   int ibase;
-  char *class_name = type_name_no_tag (class_type);
+  const char *class_name = type_name_no_tag (class_type);
 
   /* Ignore this class if it doesn't have a name.  This is ugly, but
      unless we figure out how to get the physname without the name of
@@ -920,7 +921,7 @@ find_methods (struct type *class_type, char *method,
        {
          int field_counter;
          char dem_opname[64];
-         char *current_method_name
+         const char *current_method_name
            = find_method_name (class_type, method_counter, dem_opname);
 
          if (strcmp_iw (method, current_method_name) == 0)
@@ -959,11 +960,11 @@ find_methods (struct type *class_type, char *method,
    used as storage space.  Note that this function is g++
    specific.  */
 
-static char *
+static const char *
 find_method_name (struct type *class_type, int method_counter,
                  char *dem_opname)
 {
-  char *name = TYPE_FN_FIELDLIST_NAME (class_type, method_counter);
+  const char *name = TYPE_FN_FIELDLIST_NAME (class_type, method_counter);
   if (strncmp (name, "__", 2) == 0
       || strncmp (name, "op", 2) == 0
       || strncmp (name, "type", 4) == 0)
index a31c5ae30842f27685ba868f274929a6850eff85..1d2422e71679f82d3a1f41e9401efe1f50234d4b 100644 (file)
@@ -23,7 +23,7 @@ extern int m2_parse (void);   /* Defined in m2-exp.y */
 extern void m2_error (char *); /* Defined in m2-exp.y */
 
 /* Defined in m2-typeprint.c */
-extern void m2_print_type (struct type *, char *, struct ui_file *, int,
+extern void m2_print_type (struct type *, const char *, struct ui_file *, int,
                           int);
 
 extern int m2_val_print (struct type *, char *, int, CORE_ADDR,
index 90aefae66e748fd9c4d175294ae04fcd8eb7b9c5..f16d4ddec7eb2c47c25e3da98688bca8f9440a73 100644 (file)
 #include <errno.h>
 
 void
-m2_print_type (struct type *type, char *varstring, struct ui_file *stream,
+m2_print_type (struct type *type, const char *varstring,
+              struct ui_file *stream,
               int show, int level)
 {
-  extern void c_print_type (struct type *, char *, struct ui_file *, int,
+  extern void c_print_type (struct type *, const char *, struct ui_file *, int,
                            int);
 
   c_print_type (type, varstring, stream, show, level); /* FIXME */
index 39eb0435f09c0e9a03e8ea2d124656ccb8c0d2a4..060cee6d1c549dd5752aa73ac1e532e1788989b1 100644 (file)
@@ -26,14 +26,14 @@ extern int pascal_parse (void);     /* Defined in p-exp.y */
 extern void pascal_error (char *);     /* Defined in p-exp.y */
 
 /* Defined in p-typeprint.c */
-extern void pascal_print_type (struct type *, char *, struct ui_file *, int, int);
+extern void pascal_print_type (struct type *, const char *, struct ui_file *, int, int);
 
 extern int pascal_val_print (struct type *, char *, int, CORE_ADDR, struct ui_file *, int, int,
                             int, enum val_prettyprint);
 
 extern int pascal_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
 
-extern void pascal_type_print_method_args (char *, char *,
+extern void pascal_type_print_method_args (char *, const char *,
                                           struct ui_file *);
 
 /* These are in p-lang.c: */
index 293de70b575c6ee2d3d31f800bbbb82855ae108d..4ba0645eee561d6964333cb69b8efd783beed8f5 100644 (file)
@@ -47,7 +47,8 @@ void pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int
 /* LEVEL is the depth to indent lines by.  */
 
 void
-pascal_print_type (struct type *type, char *varstring, struct ui_file *stream,
+pascal_print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream,
                   int show, int level)
 {
   register enum type_code code;
@@ -115,7 +116,7 @@ pascal_print_type (struct type *type, char *varstring, struct ui_file *stream,
 static void
 pascal_type_print_derivation_info (struct ui_file *stream, struct type *type)
 {
-  char *name;
+  const char *name;
   int i;
 
   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
@@ -136,7 +137,7 @@ pascal_type_print_derivation_info (struct ui_file *stream, struct type *type)
 /* Print the Pascal method arguments ARGS to the file STREAM.  */
 
 void
-pascal_type_print_method_args (char *physname, char *methodname,
+pascal_type_print_method_args (char *physname, const char *methodname,
                               struct ui_file *stream)
 {
   int is_constructor = STREQN (physname, "__ct__", 6);
@@ -191,7 +192,7 @@ void
 pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
                                  int show, int passed_a_ptr)
 {
-  char *name;
+  const char *name;
   if (type == 0)
     return;
 
@@ -628,8 +629,8 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
            {
              struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
              int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
-             char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
-             char *name = type_name_no_tag (type);
+             const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
+             const char *name = type_name_no_tag (type);
              /* this is GNU C++ specific
                 how can we know constructor/destructor?
                 It might work for GNU pascal */
index 5f32ea52febd3ce54d6f430e3f31f8416557144f..1a145f99b68cf74c6127f3c86515f359b0c00a70 100644 (file)
@@ -687,7 +687,7 @@ const char pascal_vtbl_ptr_name[] =
 int
 pascal_object_is_vtbl_ptr_type (struct type *type)
 {
-  char *typename = type_name_no_tag (type);
+  const char *typename = type_name_no_tag (type);
 
   return (typename != NULL
          && (STREQ (typename, pascal_vtbl_ptr_name)));
@@ -925,7 +925,7 @@ pascal_object_print_value (struct type *type, char *valaddr, CORE_ADDR address,
     {
       int boffset;
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
-      char *basename = TYPE_NAME (baseclass);
+      const char *basename = TYPE_NAME (baseclass);
       char *base_valaddr;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -1076,7 +1076,7 @@ pascal_object_print_class_member (char *valaddr, struct type *domain,
     }
   if (i < len)
     {
-      char *name;
+      const char *name;
       fprintf_filtered (stream, prefix);
       name = type_name_no_tag (domain);
       if (name)
index b4753d000f75589bf9c75925e0cc15a6d732d059..e7f4cf971fc386ae864a8f2dcc216e102959a7b2 100644 (file)
@@ -611,7 +611,7 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
   struct symtab *symtab = 0;
   CORE_ADDR name_location = 0;
   asection *section = 0;
-  char *name_temp = "";
+  const char *name_temp = "";
   
   /* Let's say it is unmapped. */
   *unmapped = 0;
index fcd6046d8dd0cf36ab62c66f710358e0acc93c4d..7c09d769370282f658a0852ed0bf533764598655 100644 (file)
@@ -3600,7 +3600,7 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
                 struct objfile *objfile)
 {
   register char *p;
-  char *name;
+  const char *name;
   char cpp_abbrev;
   struct type *context;
 
@@ -4411,7 +4411,7 @@ static struct deprecated_complaint multiply_defined_struct =
 static void 
 complain_about_struct_wipeout (struct type *type)
 {
-  char *name = "";
+  const char *name = "";
   char *kind = "";
 
   if (TYPE_TAG_NAME (type))
@@ -5355,7 +5355,7 @@ cleanup_undefined_types (void)
                struct pending *ppt;
                int i;
                /* Name of the type, without "struct" or "union" */
-               char *typename = TYPE_TAG_NAME (*type);
+               const char *typename = TYPE_TAG_NAME (*type);
 
                if (typename == NULL)
                  {
index 74e1711aa13a37e7826b16c37950e0bc1499a7ca..5aa362114a7a384203030ced16e286d35f21207e 100644 (file)
@@ -465,7 +465,7 @@ print_frame (struct frame_info *fi,
             struct symtab_and_line sal)
 {
   struct symbol *func;
-  register char *funname = 0;
+  register const char *funname = 0;
   enum language funlang = language_unknown;
   struct ui_stream *stb;
   struct cleanup *old_chain;
@@ -783,7 +783,7 @@ frame_info (char *addr_exp, int from_tty)
   struct symtab *s;
   struct frame_info *calling_frame_info;
   int i, count, numregs;
-  char *funname = 0;
+  const char *funname = 0;
   enum language funlang = language_unknown;
 
   if (!target_has_stack)
@@ -1877,7 +1877,7 @@ func_command (char *arg, int from_tty)
     {
       if (sals.sals[i].pc == (CORE_ADDR) 0 ||
          find_pc_partial_function (sals.sals[i].pc,
-                                   (char **) NULL,
+                                   NULL,
                                    &func_bounds[i].low,
                                    &func_bounds[i].high) == 0)
        {
index 6dc0b6ae24193bb47329305e82ee15df95fd5aa6..af21a7ebdea932e05b2c8877af5cf492141504ad 100644 (file)
@@ -230,7 +230,7 @@ static int
 compare_psymbols (const void *s1p, const void *s2p)
 {
   register struct partial_symbol **s1, **s2;
-  register char *st1, *st2;
+  register const char *st1, *st2;
 
   s1 = (struct partial_symbol **) s1p;
   s2 = (struct partial_symbol **) s2p;
index 957bc2266194f69d0e06a489fd4cba9c32594a2e..085b8faae36270b94634d4572f5239d385c0c9c6 100644 (file)
@@ -56,7 +56,8 @@
 
 /* Prototypes for local functions */
 
-static void completion_list_add_name (char *, char *, int, char *, char *);
+static void completion_list_add_name (const char *, char *, int, char *,
+                                     char *);
 
 static void rbreak_command (char *, int);
 
@@ -108,6 +109,13 @@ struct symbol *lookup_symbol_aux_nonlocal (int block_index,
                                           const namespace_enum namespace,
                                           struct symtab **symtab);
 
+static
+struct symbol *lookup_symbol_aux_file (const char *name,
+                                      const char *mangled_name,
+                                      const struct block *block,
+                                      const namespace_enum namespace,
+                                      struct symtab **symtab);
+
 static
 struct symbol *lookup_symbol_aux_symtabs (int block_index,
                                          const char *name,
@@ -132,11 +140,11 @@ struct symbol *lookup_symbol_aux_using (const char *name,
 static
 struct symbol *lookup_symbol_aux_using_loop (const char *name,
                                             const char *mangled_name,
+                                            const struct block *block,
                                             namespace_enum namespace,
                                             struct symtab **symtab,
                                             const char *scope,
-                                            int scope_len,
-                                            struct using_direct_node *using);
+                                            int scope_len);
 
 static
 struct symbol *lookup_symbol_aux_minsyms (int block_index,
@@ -353,9 +361,9 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
   char *mangled_name;
   struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id);
   struct fn_field *method = &f[signature_id];
-  char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
-  char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
-  char *newname = type_name_no_tag (type);
+  const char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
+  const char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
+  const char *newname = type_name_no_tag (type);
 
   /* Does the form of physname indicate that it is the full mangled name
      of a constructor (not just the args)?  */
@@ -470,7 +478,7 @@ void
 symbol_init_demangled_name (struct general_symbol_info *gsymbol,
                            struct obstack *obstack)
 {
-  char *mangled = gsymbol->name;
+  const char *mangled = gsymbol->name;
   char *demangled = NULL;
 
   if (gsymbol->language == language_unknown)
@@ -532,7 +540,7 @@ symbol_init_demangled_name (struct general_symbol_info *gsymbol,
 
 /* Return the demangled name for a symbol based on the language for
    that symbol.  If no demangled name exists, return NULL. */
-char *
+const char *
 symbol_demangled_name (const struct general_symbol_info *gsymbol)
 {
   if (gsymbol->language == language_cplus
@@ -897,47 +905,11 @@ lookup_symbol_aux (const char *name, const char *mangled_name,
        }
     }
 
-  /* If there's a static block to search, search it next.  */
-
-  /* NOTE: carlton/2002-11-06: There is a question as to whether or
-     not it would be appropriate to search the current global block
-     here as well.  On the one hand, it's redundant with the
-     lookup_symbol_aux_symtabs search that happens next.  On the other
-     hand, if decode_line_1 is passed an argument like filename:var,
-     then the user presumably wants 'var' to be searched for in
-     filename.  On the third hand, there shouldn't be multiple global
-     variables all of which are named 'var', and it's not like the
-     code has ever restricted its search to only global variables in a
-     single filename.  All in all, only searching the static block
-     seems best: it's cleanest, it's correct, and it might be useful
-     for handling namespace scope issues completely correctly.  */
-
-  static_block = block_static_block (block);
-
-  if (static_block != NULL)
-    {
-      sym = lookup_symbol_aux_block (name, mangled_name, static_block,
-                                    namespace, symtab);
-      if (sym != NULL)
-       return sym;
-    }
-
-  /* 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.
-
+  /* Now search this block's static block, and all the global blocks.
      We do this from within lookup_symbol_aux_using: that will apply
      appropriate using directives in the C++ case.  But it works fine
      in the non-C++ case, too.  */
 
-  /* 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 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)
@@ -946,11 +918,6 @@ lookup_symbol_aux (const char *name, const char *mangled_name,
   /* Now search all static file-level symbols.  Not strictly correct,
      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)
@@ -1113,6 +1080,31 @@ lookup_symbol_aux_nonlocal (int block_index,
   return NULL;
 }
 
+/* Look up NAME in BLOCK's static block and in global blocks.  */
+
+static struct symbol *
+lookup_symbol_aux_file (const char *name,
+                       const char *mangled_name,
+                       const struct block *block,
+                       const namespace_enum namespace,
+                       struct symtab **symtab)
+{
+  struct symbol *sym;
+  const struct block *static_block = block_static_block (block);
+
+  if (static_block != NULL)
+    {
+      sym = lookup_symbol_aux_block (name, mangled_name, static_block,
+                                    namespace, symtab);
+      if (sym != NULL)
+       return sym;
+    }
+
+  return lookup_symbol_aux_nonlocal (GLOBAL_BLOCK, name, mangled_name,
+                                    namespace, symtab);
+}
+
+
 /* Check to see if the symbol is defined in one of the symtabs.
    BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK,
    depending on whether or not we want to search global symbols or
@@ -1206,9 +1198,9 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name,
   return NULL;
 }
 
-/* This function gathers using directives from BLOCK and its
-   superblocks, and then searches for symbols in the global namespace
-   by trying to apply those various using directives.  */
+/* This function and lookup_symbol_aux_using_loop calculates the
+   appropriate namespaces scope for BLOCK, and searches for NAME in
+   each of the namespaces that are in scope.  */
 
 static struct symbol *lookup_symbol_aux_using (const char *name,
                                               const char *mangled_name,
@@ -1216,33 +1208,21 @@ static struct symbol *lookup_symbol_aux_using (const char *name,
                                               const namespace_enum namespace,
                                               struct symtab **symtab)
 {
-  struct using_direct_node *using;
-  const char *scope;
-  struct symbol *sym;
+  const char *scope = block_scope (block);
 
-  using = block_all_usings (block);
-  scope = block_scope (block);
-  
-  sym = lookup_symbol_aux_using_loop (name, mangled_name, namespace, symtab,
-                                     scope, 0, using);
-  cp_free_usings (using);
-  
-  return sym;
+  return lookup_symbol_aux_using_loop (name, mangled_name, block,
+                                      namespace, symtab,
+                                      scope, 0);
 }
 
-/* Look up NAME in the namespaces given by SCOPE and its initial
-   prefixes, applying using directives given by USING; only consider
-   prefixes that are at least as long as SCOPE_LEN, however.  Look up
-   longest prefixes first.  */
-
 static struct
 symbol *lookup_symbol_aux_using_loop (const char *name,
                                      const char *mangled_name,
+                                     const struct block *block,
                                      namespace_enum namespace,
                                      struct symtab **symtab,
                                      const char *scope,
-                                     int scope_len,
-                                     struct using_direct_node *using)
+                                     int scope_len)
 {
   if (scope[scope_len] != '\0')
     {
@@ -1257,19 +1237,19 @@ symbol *lookup_symbol_aux_using_loop (const char *name,
          new_scope_len += 2;
        }
       next_component = cp_find_first_component (scope + new_scope_len) - scope;
-      sym = lookup_symbol_aux_using_loop (name, mangled_name, namespace,
-                                         symtab, scope, next_component,
-                                         using);
+      sym = lookup_symbol_aux_using_loop (name, mangled_name, block, namespace,
+                                         symtab, scope, next_component);
       if (sym != NULL)
        return sym;
     }
 
-  return lookup_symbol_namespace (scope, scope_len, name, using,
-                                 mangled_name, namespace, symtab);
+  return lookup_symbol_namespace (scope, scope_len, name, mangled_name,
+                                 block, namespace, symtab);
 }
 
 /* This tries to look up NAME in the namespace given by the initial
-   substring of NAMESPACE of length NAMESPACE_LEN.
+   substring of NAMESPACE_NAME of length NAMESPACE_LEN.  It applies
+   the using directives that are active in BLOCK.
 
    For example, assume that we have using directives adding A to the
    global namespace, adding A::inner to namespace A, and adding B to
@@ -1283,45 +1263,42 @@ symbol *lookup_symbol_aux_using_loop (const char *name,
    stuff in A::A::foo, A::inner::A::foo, A::inner::foo, and
    B::A::foo).  */
 
-/* FIXME: carlton/2002-10-11: There are still some places where this
-   will return false positives.  For example, if you have namespaces
-   C, C::D, C::E, and C::D::E, then, from a function defined in C::D,
-   all references to variables E::var _should_ be treated as
-   C::D::E::var, but this function will also see variables in
-   C::E::var.  I don't think this can be fixed without making
-   namespaces first-class objects.  (Which is certainly a good idea
-   for other reasons, but it will take a little while.)  */
+/* FIXME: carlton/2002-11-27: Currently, there's no way to specify
+   that additional using directives are active.  When we get around to
+   implementing Koenig lookup, that will have to change.  */
 
-/* NOTE: carlton/2002-11-19: This is optimistically called
-   lookup_symbol_namespace instead of lookup_symbol_aux_namespace in
-   hopes that it or something like it might eventually be useful
-   outside of lookup_symbol.  */
+/* NOTE: carlton/2002-11-27: I'm calling the namespace_enum argument
+   NAME_SPACE instead of NAMESPACE because I'm being driven crazy by
+   the two different meanings of "namespace" in this function.  */
 
 struct symbol *
-lookup_symbol_namespace (const char *namespace,
+lookup_symbol_namespace (const char *namespace_name,
                         int namespace_len,
                         const char *name,
-                        struct using_direct_node *using,
                         const char *mangled_name,
+                        const struct block *block,
                         namespace_enum name_space,
                         struct symtab **symtab)
 {
-  struct using_direct_node *current;
+  struct block_using_iterator iter;
+  const struct using_direct *current;
   struct symbol *sym;
 
-  for (current = using; current; current = current->next)
+  for (current = block_using_iterator_first (block, &iter);
+       current != NULL;
+       current = block_using_iterator_next (&iter))
     {
       /* First, see if the namespace matches the start of this using
         directive.  */
-      if (namespace_len <= current->current->outer_length
-         && strncmp (namespace, current->current->name, namespace_len) == 0)
+      if (namespace_len <= current->outer_length
+         && strncmp (namespace_name, current->name, namespace_len) == 0)
        {
          /* Great, it matches: now does the rest of the using
             directive match the rest of the name?  */
          
-         const char *rest_of_outer = current->current->name + namespace_len;
+         const char *rest_of_outer = current->name + namespace_len;
          int rest_of_outer_len
-           = current->current->outer_length - namespace_len;
+           = current->outer_length - namespace_len;
          /* Should we skip some colons?  Should be true unless
             NAMESPACE_LEN is zero (and hence we're in the global
             namespace) or we've finished all of outer.  */
@@ -1338,11 +1315,11 @@ lookup_symbol_namespace (const char *namespace,
              if (*new_name == ':')
                new_name += 2;
 
-             sym = lookup_symbol_namespace (current->current->name,
-                                            current->current->inner_length,
+             sym = lookup_symbol_namespace (current->name,
+                                            current->inner_length,
                                             new_name,
-                                            using,
                                             mangled_name,
+                                            block,
                                             name_space,
                                             symtab);
              if (sym != NULL)
@@ -1357,18 +1334,18 @@ lookup_symbol_namespace (const char *namespace,
   
   if (namespace_len == 0)
     {
-      return lookup_symbol_aux_nonlocal (GLOBAL_BLOCK, name, mangled_name,
-                                        name_space, symtab);
+      return lookup_symbol_aux_file (name, mangled_name, block,
+                                    name_space, symtab);
     }
   else
     {
       char *concatenated_name
        = xmalloc (namespace_len + 2 + strlen (name) + 1);
-      strncpy (concatenated_name, namespace, namespace_len);
+      strncpy (concatenated_name, namespace_name, namespace_len);
       strcpy (concatenated_name + namespace_len, "::");
       strcpy (concatenated_name + namespace_len + 2, name);
-      sym = lookup_symbol_aux_nonlocal (GLOBAL_BLOCK, concatenated_name,
-                                       mangled_name, name_space, symtab);
+      sym = lookup_symbol_aux_file (concatenated_name, mangled_name,
+                                   block, name_space, symtab);
 
       xfree (concatenated_name);
       return sym;
@@ -3351,7 +3328,8 @@ static char **return_val;
    characters.  If so, add it to the current completion list. */
 
 static void
-completion_list_add_name (char *symname, char *sym_text, int sym_text_len,
+completion_list_add_name (const char *symname, char *sym_text,
+                         int sym_text_len,
                          char *text, char *word)
 {
   int newsize;
index 059732ce353a2e35772b893ee620a03541432e57..6d13cba8e56c96f33aa12b84a15962fad33bdc8d 100644 (file)
@@ -167,7 +167,8 @@ extern void symbol_init_demangled_name (struct general_symbol_info *symbol,
    that symbol.  If no demangled name exists, return NULL. */
 #define SYMBOL_DEMANGLED_NAME(symbol) \
   (symbol_demangled_name (&(symbol)->ginfo))
-extern char *symbol_demangled_name (const struct general_symbol_info *symbol);
+extern const char *symbol_demangled_name (const struct general_symbol_info
+                                         *symbol);
 
 /* Macro that returns the demangled name of the symbol if if possible
    and the symbol name if not possible.  This is like
@@ -944,11 +945,11 @@ extern struct symbol *lookup_symbol (const char *, const struct block *,
 
 /* Lookup a symbol within a namespace.  */
 
-extern struct symbol *lookup_symbol_namespace (const char *namespace,
+extern struct symbol *lookup_symbol_namespace (const char *namespace_name,
                                               int namespace_len,
                                               const char *name,
-                                              struct using_direct_node *using,
                                               const char *mangled_name,
+                                              const struct block *block,
                                               namespace_enum name_space,
                                               struct symtab **symtab);
 
@@ -984,7 +985,8 @@ find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *, CORE_ADDR *);
 extern void clear_pc_function_cache (void);
 
 extern int find_pc_sect_partial_function (CORE_ADDR, asection *,
-                                         char **, CORE_ADDR *, CORE_ADDR *);
+                                         char **, CORE_ADDR *,
+                                         CORE_ADDR *);
 
 /* from symtab.c: */
 
index 20ea0920900a086e1c78e110279e921ac2a3c60f..6fa5e95d9aa59f1e918adbae874805cb6408c881 100644 (file)
@@ -1,3 +1,18 @@
+2002-11-27  David Carlton  <carlton@math.stanford.edu>
+
+       * gdb.c++/m-data.cc (main): Add marker comment.
+       * gdb.c++/m-data.exp: Use marker comment instead of line numbers.
+       * gdb.c++/m-data.cc: Delete superfluous namespace.
+       * gdb.c++/m-static.cc: Ditto.
+       * gdb.c++/m-static1.cc: Ditto.
+       * carlton_runtest: Compare based on gdb.sum, not based on output.
+       * carlton_runnamespace: Ditto.
+
+2002-11-26  David Carlton  <carlton@math.stanford.edu>
+
+       * gdb.c++/namespace.exp: Put tests for CClass.
+       * gdb.c++/namespace.cc (C): Add CClass.
+
 2002-11-24  David Carlton  <carlton@bactrian.org>
 
        * gdb.c++/namespace.exp: Eliminate some of the single quotes, and
index 4ec2202d4702d5b4069cdedc87cc973e62234c07..e8ce420697c742341a790a847ed7ead72aeddae6 100755 (executable)
@@ -8,10 +8,12 @@
 EXTRADEBUGPATH=/usr/local/testbed/gcc3/bin
 
 echo "Running tests using regular compiler."
-runtest gdb.c++/namespace.exp 2>&1 | grep -v "^Test Run By" > /tmp/namespaceout
+runtest gdb.c++/namespace.exp > /dev/null 2>&1
+grep -v "^Test Run By" gdb.sum > /tmp/namespaceout
 diff -u {carlton_,/tmp/}namespaceout
 echo "Running tests using compiler with extra debug info."
-PATH=${EXTRADEBUGPATH}:${PATH} runtest gdb.c++/namespace.exp 2>&1 | grep -v "^Test Run By" > /tmp/namespacedebugout
+PATH=${EXTRADEBUGPATH}:${PATH} runtest gdb.c++/namespace.exp > /dev/null 2>&1
+grep -v "^Test Run By" gdb.sum > /tmp/namespacedebugout
 diff -u {carlton_,/tmp/}namespacedebugout
 
 echo "Done."
index fb982c2fd09e25f92a5da71dfa685d6286241c8e..806ea8cae39e0c701b5f3769900ba213e3a1b439 100755 (executable)
@@ -46,13 +46,16 @@ SLOWTESTS="gdb.base/callfuncs.exp \
   gdb.c++/demangle.exp"
 
 echo "Running fast tests."
-runtest ${FASTTESTS} 2>&1 | grep -v "^Test Run By" > /tmp/fastout
+runtest ${FASTTESTS} > /dev/null 2>&1
+grep -v "^Test Run By" gdb.sum > /tmp/fastout
 diff -u {carlton_,/tmp/}fastout
 echo "Running medium tests."
-runtest ${MEDTESTS} 2>&1 | grep -v "^Test Run By" > /tmp/medout
+runtest ${MEDTESTS} > /dev/null 2>&1
+grep -v "^Test Run By" gdb.sum > /tmp/medout
 diff -u {carlton_,/tmp/}medout
 echo "Running slow tests."
-runtest ${SLOWTESTS} 2>&1 | grep -v "^Test Run By" > /tmp/slowout
+runtest ${SLOWTESTS} > /dev/null 2>&1
+grep -v "^Test Run By" gdb.sum > /tmp/slowout
 diff -u {carlton_,/tmp/}slowout
 
 echo "Done."
index d9950274d7a76dcd3848234cc52bd66eae195560..f5afec0b74ad6755b524f4abcc51341e3e0fbe8f 100644 (file)
@@ -1,53 +1,50 @@
 // 2002-05-13
 
-namespace __gnu_test
+enum   region { oriental, egyptian, greek, etruscan, roman };
+
+// Test one.
+class gnu_obj_1
+{
+protected:
+  typedef region antiquities;
+  const bool           test;
+  const int            key1;
+  long                 key2;
+
+  antiquities  value;
+
+public:
+  gnu_obj_1(antiquities a, long l): test(true), key1(5), key2(l), value(a) {}
+};
+
+// Test two.
+template<typename T>
+class gnu_obj_2: public virtual gnu_obj_1
 {
-  enum         region { oriental, egyptian, greek, etruscan, roman };
-
-  // Test one.
-  class gnu_obj_1
-  {
-  protected:
-    typedef region antiquities;
-    const bool                 test;
-    const int          key1;
-    long                       key2;
-
-    antiquities        value;
-
-  public:
-    gnu_obj_1(antiquities a, long l): test(true), key1(5), key2(l), value(a) {}
-  };
-
-  // Test two.
-  template<typename T>
-    class gnu_obj_2: public virtual gnu_obj_1
-    {
-    protected:
-      antiquities      value_derived;
+protected:
+  antiquities  value_derived;
       
-    public:
-      gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7), value_derived(b) { }
-    }; 
-
-  // Test three.
-  template<typename T>
-    class gnu_obj_3
-    {
-    protected:
-      typedef region antiquities;
-      gnu_obj_2<int>           data;
+public:
+  gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7), value_derived(b) { }
+}; 
+
+// Test three.
+template<typename T>
+class gnu_obj_3
+{
+protected:
+  typedef region antiquities;
+  gnu_obj_2<int>       data;
       
-    public:
-      gnu_obj_3(antiquities b): data(etruscan) { }
-    }; 
-} 
+public:
+  gnu_obj_3(antiquities b): data(etruscan) { }
+}; 
 
 int main()
 {
-  using namespace __gnu_test;
   gnu_obj_1            test1(egyptian, 4589);
   gnu_obj_2<long>      test2(roman);
   gnu_obj_3<long>      test3(greek);
-  return 0;
+
+  return 0;                            // breakpoint: constructs-done
 }
index ac6825870da347a216867e6c8401780460660f8f..daee13805d4a2ca040c440fcc0f15ef310629140 100644 (file)
@@ -54,9 +54,12 @@ if ![runto_main] then {
     continue
 }
 
+# First, run to after we've constructed all the objects:
+
+gdb_breakpoint [gdb_get_line_number "constructs-done"]
+gdb_continue_to_breakpoint "end of constructors"
+
 # One.
-gdb_test "break 50" "Breakpoint \[0-9\]*.*line 50\\."
-gdb_test "continue" "Continuing\\.\r\n\r\nBreakpoint.*at.*m-data\\.cc:50\r\n.*" "continue to 50"
 
 # simple object, const bool
 gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, const bool"
@@ -71,8 +74,6 @@ gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long"
 gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum"
 
 # Two.
-gdb_test "break 51" "Breakpoint \[0-9\]*.*line 51\\."
-gdb_test "continue" "Continuing\\.\r\n\r\nBreakpoint.*at.*m-data\\.cc:51\r\n.*" "continue to 51"
 
 # derived template object, base const bool
 gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base const bool"
@@ -90,8 +91,6 @@ gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object,
 gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum"
 
 # Three.
-gdb_test "break 52" "Breakpoint \[0-9\]*.*line 52\\."
-gdb_test "continue" "Continuing\\.\r\n\r\nBreakpoint.*at.*m-data\\.cc:52\r\n.*" "continue to 52"
 
 # template object, derived template data member's base const bool
 gdb_test "print test3.data.test" "\\$\[0-9\]* = true" "template object, const bool"
index ae1484851b65b8bed7bc67cf2f87e338eaa76bac..e5b9cd1eecdb5240e0e31c633ac2eecc59173ad3 100644 (file)
@@ -1,73 +1,68 @@
 // 2002-05-13
 
-namespace __gnu_test
-{
-  enum         region { oriental, egyptian, greek, etruscan, roman };
+enum   region { oriental, egyptian, greek, etruscan, roman };
 
-  // Test one.
-  class gnu_obj_1
-  {
-  protected:
-    typedef region antiquities;
-    static const bool  test = true;
-    static const int   key1 = 5;
-    static long        key2;
+// Test one.
+class gnu_obj_1
+{
+protected:
+  typedef region antiquities;
+  static const bool    test = true;
+  static const int     key1 = 5;
+  static long          key2;
 
-    static antiquities         value;
+  static antiquities   value;
 
-  public:
-    gnu_obj_1(antiquities a, long l) {}
-  };
+public:
+  gnu_obj_1(antiquities a, long l) {}
+};
 
-  const bool gnu_obj_1::test;
-  const int gnu_obj_1::key1;
-  long gnu_obj_1::key2 = 77;
-  gnu_obj_1::antiquities gnu_obj_1::value = oriental;
+const bool gnu_obj_1::test;
+const int gnu_obj_1::key1;
+long gnu_obj_1::key2 = 77;
+gnu_obj_1::antiquities gnu_obj_1::value = oriental;
 
 
-  // Test two.
-  template<typename T>
-    class gnu_obj_2: public virtual gnu_obj_1
-    {
-    public:
-      static antiquities       value_derived;
+// Test two.
+template<typename T>
+class gnu_obj_2: public virtual gnu_obj_1
+{
+public:
+  static antiquities   value_derived;
       
-    public:
-      gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
-    }; 
+public:
+  gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
+}; 
 
-  template<typename T>
-    typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
+template<typename T>
+typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
 
-  // Test three.
-  template<typename T>
-    class gnu_obj_3
-    {
-    public:
-      typedef region antiquities;
-      static gnu_obj_2<int>    data;
-      
-    public:
-      gnu_obj_3(antiquities b) { }
-    }; 
+// Test three.
+template<typename T>
+class gnu_obj_3
+{
+public:
+  typedef region antiquities;
+  static gnu_obj_2<int>        data;
+  
+public:
+  gnu_obj_3(antiquities b) { }
+}; 
 
-  template<typename T>
-    gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
+template<typename T>
+gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
 
-  // 2002-08-16
-  // Test four.
+// 2002-08-16
+// Test four.
 #include "m-static.h"
-} 
 
 // instantiate templates explicitly so their static members will exist
-template class __gnu_test::gnu_obj_2<int>;
-template class __gnu_test::gnu_obj_2<long>;
-template class __gnu_test::gnu_obj_3<long>;
+template class gnu_obj_2<int>;
+template class gnu_obj_2<long>;
+template class gnu_obj_3<long>;
 
 int main()
 {
-  using namespace __gnu_test;
-
   gnu_obj_1            test1(egyptian, 4589);
   gnu_obj_2<long>      test2(roman);
   gnu_obj_3<long>      test3(greek);
index f88c9ce2522fe31826bf85178a7a271bba34a20c..302a5ada254c9db14804463db8221647e0924282 100644 (file)
@@ -1,9 +1,5 @@
 // 2002-08-16
 
-namespace __gnu_test {
 #include "m-static.h"
-}
-
-using namespace __gnu_test;
 
 const int gnu_obj_4::elsewhere = 221;
index 6298b91762d5f72d8e863cec34ce260cae858459..0a264ec403f43c2616017103fce70d9b4cef470c 100644 (file)
@@ -135,6 +135,15 @@ namespace C
   int c = 1;
   int shadow = 12;
 
+  class CClass {
+  public:
+    int x;
+    class NestedClass {
+    public:
+      int y;
+    };
+  };
+
   namespace
   {
     int cX = 6;
index 354668c5df8ae1c6dbae05b443ce083e23ecd99e..d8fa93839c3d23d91c4da425398ec2f93289fe7d 100644 (file)
@@ -248,6 +248,16 @@ gdb_test "print E::ce" "No symbol \"ce\" in namespace \"C::D::E\"." "print E::ce
 gdb_test "ptype C" "type = namespace C::C" "ptype C::C"
 gdb_test "ptype E" "type = namespace C::D::E" "ptype C::D::E"
 
+gdb_test "ptype CClass" "type = class C::CClass \{\r\n  public:\r\n    int x;\r\n\}" "ptype CClass"
+gdb_test "ptype CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n  public:\r\n    int y;\r\n\}" "ptype CClass::NestedClass"
+gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context." "ptype NestedClass"
+gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n  public:\r\n    inty;\r\n\}" "ptype ::C::CClass"
+gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n  public:\r\n    int y;\r\n\}" "ptype ::C::CClass::NestedClass"
+gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"." "ptype ::C::NestedClass"
+gdb_test "ptype C::CClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::CClass"
+gdb_test "ptype C::CClass::NestedClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::CClass::NestedClass"
+gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"." "ptype C::NestedClass"
+
 # Some anonymous namespace tests.
 
 gdb_test "print cX" "\\$\[0-9\].* = 6" "print cX"
index 787737cfe95fa3c62d5c30bf8ab2217faf696a5b..58c66412ab6646037993b66f679f144462ec3156 100644 (file)
@@ -113,7 +113,7 @@ typedef_print (struct type *type, struct symbol *new, struct ui_file *stream)
    If SHOW is negative, we never show the details of elements' types.  */
 
 void
-type_print (struct type *type, char *varstring, struct ui_file *stream,
+type_print (struct type *type, const char *varstring, struct ui_file *stream,
            int show)
 {
   LA_PRINT_TYPE (type, varstring, stream, show, 0);
index 06fb5938d5ba7e14547f238534cd3978ff270848..31c5f3d39730786ed65d3200e3a8fbe58c72cae9 100644 (file)
@@ -1274,7 +1274,7 @@ print_spaces (register int n, register struct ui_file *file)
 /* Print a host address.  */
 
 void
-gdb_print_host_address (void *addr, struct ui_file *stream)
+gdb_print_host_address (const void *addr, struct ui_file *stream)
 {
 
   /* We could use the %p conversion specifier to fprintf if we had any
@@ -2297,7 +2297,8 @@ print_spaces_filtered (int n, struct ui_file *stream)
    demangling is off, the name is printed in its "raw" form. */
 
 void
-fprintf_symbol_filtered (struct ui_file *stream, char *name, enum language lang,
+fprintf_symbol_filtered (struct ui_file *stream, const char *name,
+                        enum language lang,
                         int arg_mode)
 {
   char *demangled;
index 279528a15a71e31e084ab3744b704c324130f146..a793a93310c67879211c6f70518564b8de713d9c 100644 (file)
@@ -65,7 +65,7 @@ find_size_for_pointer_math (struct type *ptr_type)
        sz = 1;
       else
        {
-         char *name;
+         const char *name;
          
          name = TYPE_NAME (ptr_target);
          if (name == NULL)
index bddb999529fff2061e07a121eb26a80a04c92935..209e50423d2662fa8dde0b124b08c24bd6fc064b 100644 (file)
@@ -57,7 +57,7 @@ static struct value *value_arg_coerce (struct value *, struct type *, int);
 
 static CORE_ADDR value_push (CORE_ADDR, struct value *);
 
-static struct value *search_struct_field (char *, struct value *, int,
+static struct value *search_struct_field (const char *, struct value *, int,
                                      struct type *, int);
 
 static struct value *search_struct_method (char *, struct value **,
@@ -1750,7 +1750,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name);
     SAVE_DUMMY_FRAME_TOS (sp);
 
   {
-    char *name;
+    const char *name;
     struct symbol *symbol;
 
     name = NULL;
@@ -1772,10 +1772,12 @@ You must use a pointer to function type variable. Command ignored.", arg_name);
     if (name == NULL)
       {
        char format[80];
+       char *temp_name;
        sprintf (format, "at %s", local_hex_format ());
-       name = alloca (80);
+       temp_name = alloca (80);
        /* FIXME-32x64: assumes funaddr fits in a long.  */
-       sprintf (name, format, (unsigned long) funaddr);
+       sprintf (temp_name, format, (unsigned long) funaddr);
+       name = temp_name;
       }
 
     /* Execute the stack dummy routine, calling FUNCTION.
@@ -2132,7 +2134,7 @@ typecmp (int staticp, int varargs, int nargs,
    look for a baseclass named NAME.  */
 
 static struct value *
-search_struct_field (char *name, struct value *arg1, int offset,
+search_struct_field (const char *name, struct value *arg1, int offset,
                     register struct type *type, int looking_for_baseclass)
 {
   int i;
@@ -2382,7 +2384,7 @@ search_struct_method (char *name, struct value **arg1p,
   CHECK_TYPEDEF (type);
   for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--)
     {
-      char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
+      const char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
       /* FIXME!  May need to check for ARM demangling here */
       if (strncmp (t_field_name, "__", 2) == 0 ||
          strncmp (t_field_name, "op", 2) == 0 ||
@@ -2646,7 +2648,7 @@ find_method_list (struct value **argp, char *method, int offset,
   for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--)
     {
       /* pai: FIXME What about operators and type conversions? */
-      char *fn_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
+      const char *fn_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
       if (fn_field_name && (strcmp_iw (fn_field_name, method) == 0))
        {
          int len = TYPE_FN_FIELDLIST_LENGTH (type, i);
@@ -2803,7 +2805,7 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method,
   int static_offset;
   struct cleanup *cleanups = NULL;
 
-  char *obj_type_name = NULL;
+  const char *obj_type_name = NULL;
   char *func_name = NULL;
 
   /* Get the list of overloaded methods or functions */
@@ -3016,7 +3018,7 @@ destructor_name_p (const char *name, const struct type *type)
 
   if (name[0] == '~')
     {
-      char *dname = type_name_no_tag (type);
+      const char *dname = type_name_no_tag (type);
       char *cp = strchr (dname, '<');
       unsigned int len;
 
@@ -3185,7 +3187,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 
   for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
     {
-      char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i);
+      const char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i);
       char dem_opname[64];
 
       if (strncmp (t_field_name, "__", 2) == 0 ||
@@ -3276,13 +3278,10 @@ value_namespace_elt (const struct type *curtype,
                     const char *name)
 {
   const char *namespace_name = TYPE_TAG_NAME (curtype);
-  struct using_direct_node *usings = block_all_usings (block);
   const struct symbol *sym;
 
   sym = lookup_symbol_namespace (namespace_name, strlen (namespace_name),
-                                name, usings, NULL, VAR_NAMESPACE, NULL);
-
-  cp_free_usings (usings);
+                                name, NULL, block, VAR_NAMESPACE, NULL);
 
   /* FIXME: carlton/2002-11-24: Should this really be here, or should
      it be in c-exp.y like the other similar messages?  Hmm...  */
index 5c89817ec1ad22d5c09b4baf3bda26a8f9407247..178f653d8a1688611b51b7b0cd59d4d12b796379 100644 (file)
@@ -490,7 +490,7 @@ extern int record_latest_value (struct value *val);
 extern void
 modify_field (char *addr, LONGEST fieldval, int bitpos, int bitsize);
 
-extern void type_print (struct type * type, char *varstring,
+extern void type_print (struct type * type, const char *varstring,
                        struct ui_file * stream, int show);
 
 extern char *baseclass_addr (struct type *type, int index, char *valaddr,