static char *determine_prefix (struct die_info *die);
+static char *determine_prefix_aux (struct die_info *die);
+
static char *typename_concat (const char *prefix, const char *suffix);
static char *class_name (struct die_info *die);
struct die_info *child_die;
struct attribute *attr;
char *name;
+ const char *previous_prefix = processing_current_prefix;
+ struct cleanup *back_to = NULL;
name = dwarf2_linkage_name (die);
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
+ if (cu_language == language_cplus)
+ {
+ struct die_info *spec_die = die_specification (die);
+
+ /* NOTE: carlton/2004-01-23: We have to be careful in the
+ presence of DW_AT_specification. For example, with GCC
+ 3.4, given the code
+
+ namespace N {
+ void foo() {
+ // Definition of N::foo.
+ }
+ }
+
+ then we'll have a tree of DIEs like this:
+
+ 1: DW_TAG_compile_unit
+ 2: DW_TAG_namespace // N
+ 3: DW_TAG_subprogram // declaration of N::foo
+ 4: DW_TAG_subprogram // definition of N::foo
+ DW_AT_specification // refers to die #3
+
+ Thus, when processing die #4, we have to pretend that
+ we're in the context of its DW_AT_specification, namely
+ the contex of die #3. */
+
+ if (spec_die != NULL)
+ {
+ char *specification_prefix = determine_prefix (spec_die);
+ processing_current_prefix = specification_prefix;
+ back_to = make_cleanup (xfree, specification_prefix);
+ }
+ }
+
lowpc += baseaddr;
highpc += baseaddr;
symbols go in the file symbol list. */
if (outermost_context_p ())
list_in_scope = &file_symbols;
+
+ processing_current_prefix = previous_prefix;
+ if (back_to != NULL)
+ do_cleanups (back_to);
}
/* Process all the DIES contained within a lexical block scope. Start
do_cleanups (back_to);
}
+/* Return the name of the namespace/class that DIE is defined within,
+ or "" if we can't tell. The caller should xfree the result. */
+
+/* NOTE: carlton/2004-01-23: See read_func_scope (and the comment
+ therein) for an example of how to use this function to deal with
+ DW_AT_specification. */
+
+static char *
+determine_prefix (struct die_info *die)
+{
+ char *prefix = determine_prefix_aux (die);
+
+ return prefix ? prefix : xstrdup ("");
+}
+
/* 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. */
static char *
-determine_prefix (struct die_info *die)
+determine_prefix_aux (struct die_info *die)
{
struct die_info *parent;
}
else
{
- char *parent_prefix = determine_prefix (parent);
+ char *parent_prefix = determine_prefix_aux (parent);
char *retval;
switch (parent->tag) {