[dictionary] tweak comments, etc.
David Carlton
carlton@kealia.com
Wed Nov 12 00:22:00 GMT 2003
I've committed the following patch to my branch, so it will match up
better with the patch I'll soon submit for mainline.
David Carlton
carlton@kealia.com
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>
* gdb.cp/namespace.exp: Remove doubled comment.
Index: cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 cp-namespace.c
--- cp-namespace.c 30 Sep 2003 18:16:06 -0000 1.1.2.10
+++ cp-namespace.c 12 Nov 2003 00:05:40 -0000
@@ -33,18 +33,29 @@
#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;
@@ -219,12 +230,6 @@ cp_set_block_scope (const struct symbol
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
@@ -234,7 +239,6 @@ cp_set_block_scope (const struct symbol
obstack);
}
else
-#endif
{
/* Try to figure out the appropriate namespace from the
demangled name. */
@@ -503,13 +507,6 @@ lookup_symbol_file (const char *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);
@@ -522,7 +519,7 @@ lookup_symbol_file (const char *name,
/* 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,
@@ -560,8 +557,8 @@ cp_lookup_nested_type (struct type *pare
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.");
}
}
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.66.4.37
diff -u -p -r1.66.4.37 dwarf2read.c
--- dwarf2read.c 11 Nov 2003 23:50:42 -0000 1.66.4.37
+++ dwarf2read.c 12 Nov 2003 00:05:42 -0000
@@ -1680,6 +1680,10 @@ add_partial_symbol (struct partial_die_i
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)
{
@@ -3146,7 +3150,11 @@ read_structure_scope (struct die_info *d
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));
@@ -5017,8 +5025,8 @@ die_is_declaration (struct die_info *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)
@@ -5686,13 +5694,13 @@ new_symbol (struct die_info *die, struct
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);
}
}
@@ -5725,8 +5733,8 @@ new_symbol (struct die_info *die, struct
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);
}
@@ -5736,10 +5744,10 @@ new_symbol (struct die_info *die, struct
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;
@@ -5754,10 +5762,10 @@ new_symbol (struct die_info *die, struct
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)
@@ -6068,7 +6076,7 @@ read_type_die (struct die_info *die, str
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. */
@@ -6172,7 +6180,6 @@ class_name (struct die_info *die)
else
return xstrdup ("");
}
-
static struct type *
dwarf_base_type (int encoding, int size, struct objfile *objfile)
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.75.2.26
diff -u -p -r1.75.2.26 valops.c
--- valops.c 11 Nov 2003 23:50:58 -0000 1.75.2.26
+++ valops.c 12 Nov 2003 00:05:44 -0000
@@ -2473,7 +2473,8 @@ value_aggregate_elt (struct type *curtyp
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");
}
}
@@ -2613,8 +2614,9 @@ value_struct_elt_for_reference (struct t
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);
}
@@ -2638,7 +2640,10 @@ value_namespace_elt (const struct type *
}
/* 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,
Index: testsuite/gdb.cp/namespace.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace.exp,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 namespace.exp
--- testsuite/gdb.cp/namespace.exp 11 Nov 2003 23:51:11 -0000 1.1.4.2
+++ testsuite/gdb.cp/namespace.exp 12 Nov 2003 00:05:45 -0000
@@ -84,11 +84,6 @@ gdb_test "up" ".*main.*" "up from marker
# 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
More information about the Gdb-patches
mailing list