summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2003-03-11 01:01:10 +0000
committerDavid Carlton <carlton@bactrian.org>2003-03-11 01:01:10 +0000
commit799450fe159a482ebf6ece58c3358feff85cedf6 (patch)
tree908a940e4546e1a2e3b3ff926e7dcd44458c1ca9
parent5d9e7ca5ff4ac2686e115a010c5bb93ea0b9060d (diff)
downloadgdb-799450fe159a482ebf6ece58c3358feff85cedf6.tar.gz
2003-03-10 David Carlton <carlton@math.stanford.edu>
* buildsym.c (scan_for_anonymous_namespaces): Allow "{anonymous}". * cp-support.c (cp_is_anonymous): Scan for "{anonymous}".
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/buildsym.c38
-rw-r--r--gdb/cp-support.c11
3 files changed, 40 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 86bd57cb8df..605f7be249b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2003-03-10 David Carlton <carlton@math.stanford.edu>
+
+ * buildsym.c (scan_for_anonymous_namespaces): Allow
+ "{anonymous}".
+ * cp-support.c (cp_is_anonymous): Scan for "{anonymous}".
+
2003-03-07 David Carlton <carlton@math.stanford.edu>
* symtab.c (lookup_partial_symbol): Replace uses of
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index a6cbf7738b0..494da483062 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -148,10 +148,6 @@ add_symbol_to_list (struct symbol *symbol, struct pending **listhead)
/* Check to see if a symbol is contained within an anonymous
namespace; if so, add an appropriate using directive. */
-/* Optimize away strlen ("(anonymous namespace)"). */
-
-#define ANONYMOUS_NAMESPACE_LEN 21
-
static void
scan_for_anonymous_namespaces (struct symbol *symbol)
{
@@ -159,22 +155,40 @@ scan_for_anonymous_namespaces (struct symbol *symbol)
unsigned int previous_component;
unsigned int next_component;
const char *len;
+ const char *anonymous_name;
+ int anonymous_len;
- /* Start with a quick-and-dirty check for mention of "(anonymous
- namespace)". */
+ /* Start with a quick-and-dirty check for mentions of anonymous
+ namespaces. */
- if (!cp_is_anonymous (name))
- return;
+ switch (cp_is_anonymous (name))
+ {
+ case 1:
+ anonymous_name = "(anonymous namespace)";
+ break;
+ case 2:
+ /* FIXME: carlton/2003-03-10: This corresponds to GCCv2, and
+ urrently, the demangler actually can't demangle all anonymous
+ namespace mentions correctly. (See PR gdb/1134.) Given
+ GCCv2's lack of namespace support, I'm tempted to skip this
+ case entirely. */
+ anonymous_name = "{anonymous}";
+ break;
+ default:
+ return;
+ }
+
+ anonymous_len = strlen (anonymous_name);
previous_component = 0;
next_component = cp_find_first_component (name + previous_component);
while (name[next_component] == ':')
{
- if ((next_component - previous_component) == ANONYMOUS_NAMESPACE_LEN
- && strncmp (name + previous_component,
- "(anonymous namespace)",
- ANONYMOUS_NAMESPACE_LEN) == 0)
+ if ((next_component - previous_component) == anonymous_len
+ && (strncmp (name + previous_component, anonymous_name,
+ anonymous_len)
+ == 0))
{
/* We've found a component of the name that's an anonymous
namespace. So add symbols in it to the namespace given
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 9e55ab98af8..07c1928a680 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -647,13 +647,18 @@ maintenance_print_namespace (char *args, int from_tty)
}
/* Test whether or not NAMESPACE looks like it mentions an anonymous
- namespace; return nonzero if so. */
+ namespace; return 1 if it mentions "(anonymous namespace)", 2 if it
+ mentions "{anonymous}", and 0 otherwise. */
int
cp_is_anonymous (const char *namespace)
{
- return (strstr (namespace, "(anonymous namespace)")
- != NULL);
+ if (strstr (namespace, "(anonymous namespace)") != NULL)
+ return 1;
+ else if (strstr (namespace, "{anonymous}") != NULL)
+ return 2;
+ else
+ return 0;
}
/* Create a copy of the initial substring of STRING of length LEN.