cp_scan_for_anonymous_namespaces here.
(finish_block): Do not call cp_set_block_scope here.
* cp-namespace.c (processing_has_namespace_info)
(processing_current_prefix): Delete.
(cp_initialize_namespace): Do not initialize
processing_has_namespace_info.
(cp_scan_for_anonymous_namespaces): Use SYMBOL_DEMANGLED_NAME. Do
not check processing_has_namespace_info.
(cp_set_block_scope): Take prefix and namespace info flag as
arguments. Honor namespaces regardless of a demangled name.
* cp-support.h (processing_has_namespace_info)
(processing_current_prefix): Delete declarations.
(cp_set_block_scope): Update prototype.
* dwarf2read.c (processing_has_namespace_info)
(processing_current_prefix): New static variables.
(read_file_scope): Initialize processing_has_namespace_info.
(read_func_scope): Call cp_set_block_scope for C++.
(new_symbol): Call cp_scan_for_anonymous_namespaces for C++.
* symtab.c (symbol_demangled_name): Accept a const argument.
* symtab.h (symbol_demangled_name): Update prototype.
+2008-08-21 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * buildsym.c (add_symbol_to_list): Do not call
+ cp_scan_for_anonymous_namespaces here.
+ (finish_block): Do not call cp_set_block_scope here.
+ * cp-namespace.c (processing_has_namespace_info)
+ (processing_current_prefix): Delete.
+ (cp_initialize_namespace): Do not initialize
+ processing_has_namespace_info.
+ (cp_scan_for_anonymous_namespaces): Use SYMBOL_DEMANGLED_NAME. Do
+ not check processing_has_namespace_info.
+ (cp_set_block_scope): Take prefix and namespace info flag as
+ arguments. Honor namespaces regardless of a demangled name.
+ * cp-support.h (processing_has_namespace_info)
+ (processing_current_prefix): Delete declarations.
+ (cp_set_block_scope): Update prototype.
+ * dwarf2read.c (processing_has_namespace_info)
+ (processing_current_prefix): New static variables.
+ (read_file_scope): Initialize processing_has_namespace_info.
+ (read_func_scope): Call cp_set_block_scope for C++.
+ (new_symbol): Call cp_scan_for_anonymous_namespaces for C++.
+ * symtab.c (symbol_demangled_name): Accept a const argument.
+ * symtab.h (symbol_demangled_name): Update prototype.
+
2008-08-21 Daniel Jacobowitz <dan@codesourcery.com>
* ax-gdb.c (gen_var_ref): Use SYMBOL_LINKAGE_NAME.
}
(*listhead)->symbol[(*listhead)->nsyms++] = symbol;
-
- /* Check to see if we might need to look for a mention of anonymous
- namespaces. */
-
- if (SYMBOL_LANGUAGE (symbol) == language_cplus)
- cp_scan_for_anonymous_namespaces (symbol);
}
/* Find a symbol named NAME on a LIST. NAME need not be
}
}
}
-
- /* If we're in the C++ case, set the block's scope. */
- if (SYMBOL_LANGUAGE (symbol) == language_cplus)
- {
- cp_set_block_scope (symbol, block, &objfile->objfile_obstack);
- }
}
else
{
#include "command.h"
#include "frame.h"
-/* When set, the file that we're processing is known to have debugging
- info for C++ namespaces. */
-
-/* NOTE: carlton/2004-01-13: No currently released version of GCC (the
- latest of which is 3.3.x at the time of this writing) produces this
- debug info. GCC 3.4 should, however. */
-
-unsigned char processing_has_namespace_info;
-
-/* 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 () {
- }
- };
- }
-
- 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;
-
/* List of using directives that are active in the current file. */
static struct using_direct *using_list;
void cp_initialize_namespace ()
{
- processing_has_namespace_info = 0;
using_list = NULL;
}
void
cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
{
- if (!processing_has_namespace_info
- && SYMBOL_CPLUS_DEMANGLED_NAME (symbol) != NULL)
+ if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
{
- const char *name = SYMBOL_CPLUS_DEMANGLED_NAME (symbol);
+ const char *name = SYMBOL_DEMANGLED_NAME (symbol);
unsigned int previous_component;
unsigned int next_component;
const char *len;
void
cp_set_block_scope (const struct symbol *symbol,
struct block *block,
- struct obstack *obstack)
+ struct obstack *obstack,
+ const char *processing_current_prefix,
+ int processing_has_namespace_info)
{
- /* Make sure that the name was originally mangled: if not, there
- certainly isn't any namespace information to worry about! */
-
- if (SYMBOL_CPLUS_DEMANGLED_NAME (symbol) != NULL)
+ if (processing_has_namespace_info)
{
- if (processing_has_namespace_info)
- {
- block_set_scope
- (block, obsavestring (processing_current_prefix,
- strlen (processing_current_prefix),
- obstack),
- obstack);
- }
- else
- {
- /* Try to figure out the appropriate namespace from the
- demangled name. */
+ block_set_scope
+ (block, obsavestring (processing_current_prefix,
+ strlen (processing_current_prefix),
+ obstack),
+ obstack);
+ }
+ else if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
+ {
+ /* Try to figure out the appropriate namespace from the
+ demangled name. */
- /* FIXME: carlton/2003-04-15: If the function in question is
- a method of a class, the name will actually include the
- name of the class as well. This should be harmless, but
- is a little unfortunate. */
+ /* FIXME: carlton/2003-04-15: If the function in question is
+ a method of a class, the name will actually include the
+ name of the class as well. This should be harmless, but
+ is a little unfortunate. */
- const char *name = SYMBOL_CPLUS_DEMANGLED_NAME (symbol);
- unsigned int prefix_len = cp_entire_prefix_len (name);
+ const char *name = SYMBOL_DEMANGLED_NAME (symbol);
+ unsigned int prefix_len = cp_entire_prefix_len (name);
- block_set_scope (block,
- obsavestring (name, prefix_len, obstack),
- obstack);
- }
+ block_set_scope (block,
+ obsavestring (name, prefix_len, obstack),
+ obstack);
}
}
/* Functions/variables from cp-namespace.c. */
-extern unsigned char processing_has_namespace_info;
-
-extern const char *processing_current_prefix;
-
extern int cp_is_anonymous (const char *namespace);
extern void cp_add_using_directive (const char *name,
extern void cp_set_block_scope (const struct symbol *symbol,
struct block *block,
- struct obstack *obstack);
+ struct obstack *obstack,
+ const char *processing_current_prefix,
+ int processing_has_namespace_info);
extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
#include "demangle.h"
#include "complaints.h"
#include "cp-abi.h"
+#include "cp-support.h"
#include "gdb_assert.h"
#include "gdb_string.h"
{
/* This N_FUN marks the end of a function. This closes off
the current block. */
+ struct block *block;
if (context_stack_depth <= 0)
{
new = pop_context ();
/* Make a block for the local symbols within. */
- finish_block (new->name, &local_symbols, new->old_blocks,
- new->start_addr, new->start_addr + valu,
- objfile);
+ block = finish_block (new->name, &local_symbols, new->old_blocks,
+ new->start_addr, new->start_addr + valu,
+ objfile);
+
+ /* For C++, set the block's scope. */
+ if (SYMBOL_LANGUAGE (new->name) == language_cplus)
+ cp_set_block_scope (new->name, block, &objfile->objfile_obstack,
+ "", 0);
/* May be switching to an assembler file which may not be using
block relative stabs, so reset the offset. */
if (context_stack_depth > 0)
{
+ struct block *block;
+
new = pop_context ();
/* Make a block for the local symbols within. */
- finish_block (new->name, &local_symbols, new->old_blocks,
- new->start_addr, valu, objfile);
+ block = finish_block (new->name, &local_symbols,
+ new->old_blocks, new->start_addr,
+ valu, objfile);
+
+ /* For C++, set the block's scope. */
+ if (SYMBOL_LANGUAGE (new->name) == language_cplus)
+ cp_set_block_scope (new->name, block,
+ &objfile->objfile_obstack,
+ "", 0);
}
new = push_context (0, valu);
}
_STATEMENT_PROLOGUE;
+/* When set, the file that we're processing is known to have debugging
+ info for C++ namespaces. GCC 3.3.x did not produce this information,
+ but later versions do. */
+
+static int processing_has_namespace_info;
+
+/* 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 () {
+ }
+ };
+ }
+
+ then processing_current_prefix should be set to "N::C". If
+ processing_has_namespace_info is false, then this variable might
+ not be reliable. */
+
+static const char *processing_current_prefix;
+
static const struct objfile_data *dwarf2_objfile_data_key;
struct dwarf2_per_objfile
/* We assume that we're processing GCC output. */
processing_gcc_compilation = 2;
+ processing_has_namespace_info = 0;
+
start_symtab (name, comp_dir, lowpc);
record_debugformat ("DWARF 2");
record_producer (cu->producer);
block = finish_block (new->name, &local_symbols, new->old_blocks,
lowpc, highpc, objfile);
+ /* For C++, set the block's scope. */
+ if (cu->language == language_cplus)
+ cp_set_block_scope (new->name, block, &objfile->objfile_obstack,
+ processing_current_prefix,
+ processing_has_namespace_info);
+
/* If we have address ranges, record them. */
dwarf2_record_block_ranges (die, block, baseaddr, cu);
dwarf_tag_name (die->tag));
break;
}
+
+ /* For the benefit of old versions of GCC, check for anonymous
+ namespaces based on the demangled name. */
+ if (!processing_has_namespace_info
+ && cu->language == language_cplus
+ && dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu) != NULL)
+ cp_scan_for_anonymous_namespaces (sym);
}
return (sym);
}
normal:
SYMBOL_LANGUAGE (sym) = current_subfile->language;
SYMBOL_SET_NAMES (sym, string, p - string, objfile);
+ if (SYMBOL_LANGUAGE (sym) == language_cplus)
+ cp_scan_for_anonymous_namespaces (sym);
}
p++;
/* Return the demangled name for a symbol based on the language for
that symbol. If no demangled name exists, return NULL. */
char *
-symbol_demangled_name (struct general_symbol_info *gsymbol)
+symbol_demangled_name (const struct general_symbol_info *gsymbol)
{
switch (gsymbol->language)
{
that symbol. If no demangled name exists, return NULL. */
#define SYMBOL_DEMANGLED_NAME(symbol) \
(symbol_demangled_name (&(symbol)->ginfo))
-extern char *symbol_demangled_name (struct general_symbol_info *symbol);
+extern char *symbol_demangled_name (const struct general_symbol_info *symbol);
/* Macro that returns a version of the name of a symbol that is
suitable for output. In C++ this is the "demangled" form of the