* valops.c: Tweak comments to match proposed patch.
(value_aggregate_elt): Use internal_error instead of error.
* dwarf2read.c: Tweak comments to match proposed patch.
(new_symbol): Use SYMBOL_LINKAGE_NAME or SYMBOL_NATURAL_NAME
instead of DEPRECATED_SYMBOL_NAME.
* cp-namespace.c: Tweak comments to match proposed patch.
(cp_set_block_scope): Remove #if 0.
(cp_lookup_nested_type): Use internal_error instead of error.
2003-11-11 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Remove doubled comment.
+2003-11-11 David Carlton <carlton@kealia.com>
+
+ * valops.c: Tweak comments to match proposed patch.
+ (value_aggregate_elt): Use internal_error instead of error.
+ * dwarf2read.c: Tweak comments to match proposed patch.
+ (new_symbol): Use SYMBOL_LINKAGE_NAME or SYMBOL_NATURAL_NAME
+ instead of DEPRECATED_SYMBOL_NAME.
+ * cp-namespace.c: Tweak comments to match proposed patch.
+ (cp_set_block_scope): Remove #if 0.
+ (cp_lookup_nested_type): Use internal_error instead of error.
+
2003-11-11 David Carlton <carlton@kealia.com>
* Merge with mainline; tag is carlton-dictionary-20031111-merge.
#include "command.h"
#include "frame.h"
-/* When set, the file that we're processing seems to have debugging
- info for C++ namespaces, so cp-namespace.c shouldn't try to guess
- namespace info itself. */
+/* When set, the file that we're processing is known to have debugging
+ info for C++ namespaces. */
+
+/* NOTE: carlton/2003-11-10: No currently released version of GCC (the
+ latest of which is 3.3.x at the time of this writing) produces this
+ debug info. */
unsigned char processing_has_namespace_info;
-/* If processing_has_namespace_info is nonzero, this string should
- contain the name of the current namespace. The string is
- temporary; copy it if you need it. */
+/* This contains our best guess as to the name of the current
+ enclosing namespace(s)/class(es), if any. For example, if we're
+ within the method foo() in the following code:
+
+ namespace N {
+ class C {
+ void foo () {
+ }
+ };
+ }
-/* FIXME: carlton/2003-06-12: This isn't entirely reliable: currently,
- we get mislead by DW_AT_specification. */
+ then processing_current_prefix should be set to "N::C". If
+ processing_has_namespace_info is false, then this variable might
+ not be reliable. */
const char *processing_current_prefix;
if (SYMBOL_CPLUS_DEMANGLED_NAME (symbol) != NULL)
{
-#if 0
- /* FIXME: carlton/2003-06-12: As mentioned above,
- 'processing_has_namespace_info' currently isn't entirely
- reliable, so let's always use demangled names to get this
- information for now. */
-
if (processing_has_namespace_info)
{
block_set_scope
obstack);
}
else
-#endif
{
/* Try to figure out the appropriate namespace from the
demangled name. */
/* FIXME: carlton/2003-06-12: This is a hack and should eventually
be deleted: see comments below. */
- /* FIXME: carlton/2003-01-06: Searching this seems a bit fishy if
- anonymous_namespace is nonzero, since we might return a namespace
- that's really a class that doesn't happen to be mentioned in the
- current file. Sigh. Still, I don't think anything catastrophic
- should happen in that case. Probably the right thing to do is to
- move anonymous namespace symbols to files' static blocks. */
-
if (domain == VAR_DOMAIN)
{
sym = lookup_possible_namespace_symbol (name, symtab);
/* Look up a type named NESTED_NAME that is nested inside the C++
class or namespace given by PARENT_TYPE, from within the context
- given by BLOCK. */
+ given by BLOCK. Return NULL if there is no such nested type. */
struct type *
cp_lookup_nested_type (struct type *parent_type,
return SYMBOL_TYPE (sym);
}
default:
- error ("\"%s\" is not defined as a compound type.",
- TYPE_NAME (parent_type));
+ internal_error (__FILE__, __LINE__,
+ "cp_lookup_nested_type called on a non-aggregate type.");
}
}
objfile);
}
+/* Determine whether a die of type TAG living in the C++ namespace
+ NAMESPACE needs to have the name of the namespace prepended to the
+ name listed in the die. */
+
static int
pdi_needs_namespace (enum dwarf_tag tag, const char *namespace)
{
debug info. We could solve this by using the
demangled name to get the prefix; if doing so,
however, we'd need to be careful when reading a
- class that's nested inside a template class. */
+ class that's nested inside a template class.
+ That would also cause problems when trying to
+ determine RTTI information, since we use the
+ demangler to determine the appropriate class
+ name. */
char *actual_class_name
= class_name_from_physname (dwarf2_linkage_name
(child_die));
&& ! dwarf_attr (die, DW_AT_specification));
}
-/* Returns the die giving the specification for this one, or NULL if
- none. */
+/* Return the die giving the specification for DIE, if there is
+ one. */
static struct die_info *
die_specification (struct die_info *die)
if (TYPE_TAG_NAME (type) != NULL)
{
- /* FIXME: carlton/2003-01-10: We're being a bit
- profligate with memory names here. */
- DEPRECATED_SYMBOL_NAME (sym)
+ /* FIXME: carlton/2003-11-10: Should this use
+ SYMBOL_SET_NAMES instead? (The same problem also
+ arises a further down in the function.) */
+ SYMBOL_LINKAGE_NAME (sym)
= obsavestring (TYPE_TAG_NAME (type),
strlen (TYPE_TAG_NAME (type)),
&objfile->symbol_obstack);
- gdb_assert (SYMBOL_DEMANGLED_NAME (sym) == NULL);
}
}
SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
TYPE_NAME (SYMBOL_TYPE (sym)) =
- obsavestring (DEPRECATED_SYMBOL_NAME (sym),
- strlen (DEPRECATED_SYMBOL_NAME (sym)),
+ obsavestring (SYMBOL_NATURAL_NAME (sym),
+ strlen (SYMBOL_NATURAL_NAME (sym)),
&objfile->type_obstack);
add_symbol_to_list (typedef_sym, list_to_add);
}
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- DEPRECATED_SYMBOL_NAME (sym) = obconcat (&objfile->symbol_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->symbol_obstack,
+ processing_current_prefix,
+ "::",
+ name);
}
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- DEPRECATED_SYMBOL_NAME (sym) = obconcat (&objfile->symbol_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->symbol_obstack,
+ processing_current_prefix,
+ "::",
+ name);
}
attr = dwarf_attr (die, DW_AT_const_value);
if (attr)
do_cleanups (back_to);
}
-/* Determine the name of the namespace/class that DIE is defined
+/* Return the name of the namespace/class that DIE is defined
within, or NULL if we can't tell. The caller should xfree the
result. */
return xstrdup ("");
}
-
static struct type *
dwarf_base_type (int encoding, int size, struct objfile *objfile)
{
+2003-11-11 David Carlton <carlton@kealia.com>
+
+ * gdb.cp/namespace.exp: Remove doubled comment.
+
2003-11-11 Nick Clifton <nickc@redhat.com>
* gdb.base/shreloc.exp: Do not run for targets which do not
# Access a data item inside a namespace using colons and
# single quotes. :-(
-# NOTE: carlton/2002-11-24: the quotes are becoming less necessary (or
-# even desirable.) For tests where it should still work with quotes,
-# I'm including versions both with and without quotes; for tests that
-# shouldn't work with quotes, I'm only including one version.
-
# NOTE: carlton/2003-09-24: the quotes are becoming less necessary (or
# even desirable.) For tests where it should still work with quotes,
# I'm including versions both with and without quotes; for tests that
case TYPE_CODE_NAMESPACE:
return value_namespace_elt (curtype, name, noside);
default:
- error ("Internal error: non-aggregate type to value_aggregate_elt");
+ internal_error (__FILE__, __LINE__,
+ "non-aggregate type in value_aggregate_elt");
}
}
return v;
}
- /* As a last chance, look it up using lookup_symbol_namespace: this
- works for types. */
+ /* As a last chance, pretend that CURTYPE is a namespace, and look
+ it up that way; this (frequently) works for types nested inside
+ classes. */
return value_maybe_namespace_elt (curtype, name, noside);
}
}
/* A helper function used by value_namespace_elt and
- value_struct_elt_for_reference. */
+ value_struct_elt_for_reference. It looks up NAME inside the
+ context CURTYPE; this works if CURTYPE is a namespace or if CURTYPE
+ is a class and NAME refers to a type in CURTYPE itself (as opposed
+ to, say, some base class of CURTYPE). */
static struct value *
value_maybe_namespace_elt (const struct type *curtype,