From a1534bcecbddfd708c28b31bf9640d8442040bda Mon Sep 17 00:00:00 2001 From: David Carlton Date: Tue, 11 Mar 2003 01:01:10 +0000 Subject: 2003-03-10 David Carlton * buildsym.c (scan_for_anonymous_namespaces): Allow "{anonymous}". * cp-support.c (cp_is_anonymous): Scan for "{anonymous}". --- gdb/ChangeLog | 6 ++++++ gdb/buildsym.c | 38 ++++++++++++++++++++++++++------------ gdb/cp-support.c | 11 ++++++++--- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 86bd57c..605f7be 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2003-03-10 David Carlton + + * buildsym.c (scan_for_anonymous_namespaces): Allow + "{anonymous}". + * cp-support.c (cp_is_anonymous): Scan for "{anonymous}". + 2003-03-07 David Carlton * symtab.c (lookup_partial_symbol): Replace uses of diff --git a/gdb/buildsym.c b/gdb/buildsym.c index a6cbf77..494da48 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 9e55ab9..07c1928 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. -- cgit v1.1