diff options
author | David Carlton <carlton@bactrian.org> | 2004-01-23 22:41:28 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2004-01-23 22:41:28 +0000 |
commit | fdde2d8148be3b670c0cd48b52e1dedd3fcbecc9 (patch) | |
tree | 880aaf143a41114e5259cf28950cc31728342cca | |
parent | 5b828b6b4baa16fa2c3ca0ceb4708dcb9a142cc4 (diff) | |
download | gdb-fdde2d8148be3b670c0cd48b52e1dedd3fcbecc9.zip gdb-fdde2d8148be3b670c0cd48b52e1dedd3fcbecc9.tar.gz gdb-fdde2d8148be3b670c0cd48b52e1dedd3fcbecc9.tar.bz2 |
2004-01-23 David Carlton <carlton@kealia.com>
Patch for PR c++/1520:
* dwarf2read.c (read_func_scope): Set processing_current_prefix
properly if we have a specification die.
(determine_prefix_aux): Rename from determine_prefix.
(determine_prefix): Like the old determine_prefix, but never
returns NULL.
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 61 |
2 files changed, 68 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f3a468d..d6a8b62 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2004-01-23 David Carlton <carlton@kealia.com> + + Patch for PR c++/1520: + * dwarf2read.c (read_func_scope): Set processing_current_prefix + properly if we have a specification die. + (determine_prefix_aux): Rename from determine_prefix. + (determine_prefix): Like the old determine_prefix, but never + returns NULL. + 2004-01-23 Theodore A. Roth <troth@openavr.org> * avr-tdep.c: Update copyright. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index fa771ca..2276562 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -774,6 +774,8 @@ static void read_type_die (struct die_info *, struct dwarf2_cu *); 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); @@ -2145,6 +2147,8 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) 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); @@ -2153,6 +2157,40 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) 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; @@ -2203,6 +2241,10 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) 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 @@ -5969,12 +6011,27 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) 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; @@ -5989,7 +6046,7 @@ determine_prefix (struct die_info *die) } else { - char *parent_prefix = determine_prefix (parent); + char *parent_prefix = determine_prefix_aux (parent); char *retval; switch (parent->tag) { |