* 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.
+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.
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;
+ }
+}
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);
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);
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)
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)
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
{
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. */
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,
/* 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;
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++)
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;
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++)
{
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));
}
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))
}
if (i < len)
{
- char *name;
+ const char *name;
fprintf_filtered (stream, prefix);
name = type_name_no_tag (domain);
if (name)
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
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;
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,
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 *);
/* 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,
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)
{
{
*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;
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
}
}
- /* 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);
}
}
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);
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);
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);
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);
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);
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);
}
}
+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. */
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. */
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);
struct type *type;
struct attribute *attr;
char *name;
+ const char *previous_prefix = processing_current_prefix;
type = alloc_type (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)
/* 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
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);
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;
/* 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)
}
}
- processing_current_namespace = previous_namespace;
+ processing_current_prefix = previous_prefix;
}
/* Extract all information from a DW_TAG_pointer_type DIE and add to
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
}
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)
{
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,
/* 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;
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);
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;
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;
}
struct type *
-lookup_unsigned_typename (char *name)
+lookup_unsigned_typename (const char *name)
{
char *uns = alloca (strlen (name) + 10);
}
struct type *
-lookup_signed_typename (char *name)
+lookup_signed_typename (const char *name)
{
struct type *t;
char *uns = alloca (strlen (name) + 8);
{
if (!TYPE_TARGET_TYPE (type))
{
- char *name;
+ const char *name;
struct symbol *sym;
/* It is dangerous to call lookup_symbol if we are currently
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)
{
/* 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
#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;
{
enum type_code tcode;
int tlen, tflags;
- char *tname;
+ const char *tname;
tcode = TYPE_CODE (t);
tlen = TYPE_LENGTH (t);
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 */
/* 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 *);
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 *);
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);
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)
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])
{
signature string SIGNATURE. */
static int
-java_demangled_signature_length (char *signature)
+java_demangled_signature_length (const char *signature)
{
int array = 0;
for (; *signature == '['; 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;
}
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)
{
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);
{
int pc = *pos;
int i;
- char *name;
+ const char *name;
enum exp_opcode op = exp->elts[*pos].opcode;
struct value *arg1;
struct value *arg2;
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);
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
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;
struct fn_field *f;
int j;
char *method_name;
- char *name;
+ const char *name;
int is_constructor;
int n_overloads;
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;
struct type *type;
CORE_ADDR address;
int i;
- char *name;
+ const char *name;
type = VALUE_TYPE (val);
address = VALUE_ADDRESS (val) + VALUE_OFFSET (val);
{
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))
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,
}
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.");
/* 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. */
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);
{
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
{
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)
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)
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,
#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 */
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: */
/* 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;
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++)
/* 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);
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;
{
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 */
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)));
{
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))
}
if (i < len)
{
- char *name;
+ const char *name;
fprintf_filtered (stream, prefix);
name = type_name_no_tag (domain);
if (name)
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;
struct objfile *objfile)
{
register char *p;
- char *name;
+ const char *name;
char cpp_abbrev;
struct type *context;
static void
complain_about_struct_wipeout (struct type *type)
{
- char *name = "";
+ const char *name = "";
char *kind = "";
if (TYPE_TAG_NAME (type))
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)
{
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;
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)
{
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)
{
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;
/* 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);
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,
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,
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)? */
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)
/* 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
}
}
- /* 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)
/* 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)
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
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,
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')
{
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
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. */
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)
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;
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;
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
/* 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);
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: */
+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
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."
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."
// 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
}
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"
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"
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"
// 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);
// 2002-08-16
-namespace __gnu_test {
#include "m-static.h"
-}
-
-using namespace __gnu_test;
const int gnu_obj_4::elsewhere = 221;
int c = 1;
int shadow = 12;
+ class CClass {
+ public:
+ int x;
+ class NestedClass {
+ public:
+ int y;
+ };
+ };
+
namespace
{
int cX = 6;
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"
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);
/* 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
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;
sz = 1;
else
{
- char *name;
+ const char *name;
name = TYPE_NAME (ptr_target);
if (name == NULL)
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 **,
SAVE_DUMMY_FRAME_TOS (sp);
{
- char *name;
+ const char *name;
struct symbol *symbol;
name = NULL;
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.
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;
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 ||
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);
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 */
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;
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 ||
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... */
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,