diff options
author | Devang Patel <dpatel@apple.com> | 2004-01-27 12:36:02 -0800 |
---|---|---|
committer | Devang Patel <dpatel@gcc.gnu.org> | 2004-01-27 12:36:02 -0800 |
commit | 6097b0c31bc284cd0d68c67807e587596a0fb11d (patch) | |
tree | 22e0a88b1266b9aebde90de60d7105699f1310df | |
parent | e6aecf8efdef48bbf70b2712d742ac4a2cb16e02 (diff) | |
download | gcc-6097b0c31bc284cd0d68c67807e587596a0fb11d.zip gcc-6097b0c31bc284cd0d68c67807e587596a0fb11d.tar.gz gcc-6097b0c31bc284cd0d68c67807e587596a0fb11d.tar.bz2 |
Makefile.in (dwarf2out.o): Depend on input.h
2004-01-27 Devang Patel <dpatel@apple.com>
* Makefile.in (dwarf2out.o): Depend on input.h
* dbxout.c (dbx_debug_hooks): Add new empty hook for
imported_module_or_decl.
(xcoff_debug_hooks): Same.
* sdbout.c (sdb_debug_hooks): Same.
* vmsdbgout.c (vmsdbg_debug_hooks): Same.
* debug.c (do_nothing_debug_hooks): Same.
(debug_nothing_tree_tree): New function.
* debug.h (gcc_debug_hooks): New hook, imported_module_or_decl.
* dwarf2out.c: Include input.h.
(dwarf2_debug_hooks): Add new hook for imported_module_or_decl.
(remove_child_TAG): New function.
(dwarf_tag_name): Handle DW_TAG_imported_module.
(gen_subprogram_die): Equate decl number to declaration die. Do not
remove all children dies while reusing declaration die for definition.
Instead, selectively remove only formal parameters.
(gen_variable_die): Equate variable decl to declaration die.
(gen_field_die): Equate field decl to line number.
(force_namespace_die): Replace it with ...
(force_decl_die): ... this.
(force_type_die): New function.
(setup_namespace_context): Replace use of force_namespace_die() with
force_decl_die().
(gen_namespace_die): Same.
(dwarf2out_imported_module_or_decl): New function.
testsuite:
* g++.dg/debug/namespace1.C: New test.
cp:
* name-lookup.c: Include "debug.h"
(do_namespace_alias): Invoke debug_hooks to emit debug info
for namespace alias.
(do_local_using_decl): Invoke debug_hooks to emit debug info
for using decl.
(do_class_using_decl): Same.
(do_toplevel_using_decl): Same.
(do_using_directive): Same.
(cp_emit_debug_info_for_using): New function.
* Make-lang.in (cp/parser.o): Depend on debug.h
(cp/name-lookup.o): Same.
From-SVN: r76746
-rw-r--r-- | gcc/ChangeLog | 28 | ||||
-rw-r--r-- | gcc/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/cp/Make-lang.in | 5 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 72 | ||||
-rw-r--r-- | gcc/dbxout.c | 47 | ||||
-rw-r--r-- | gcc/debug.c | 37 | ||||
-rw-r--r-- | gcc/debug.h | 4 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 200 | ||||
-rw-r--r-- | gcc/sdbout.c | 47 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/namespace1.C | 258 | ||||
-rw-r--r-- | gcc/vmsdbgout.c | 7 |
13 files changed, 636 insertions, 89 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2bd5d7d..dce9a7c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,31 @@ +2004-01-27 Devang Patel <dpatel@apple.com> + + * Makefile.in (dwarf2out.o): Depend on input.h + * dbxout.c (dbx_debug_hooks): Add new empty hook for + imported_module_or_decl. + (xcoff_debug_hooks): Same. + * sdbout.c (sdb_debug_hooks): Same. + * vmsdbgout.c (vmsdbg_debug_hooks): Same. + * debug.c (do_nothing_debug_hooks): Same. + (debug_nothing_tree_tree): New function. + * debug.h (gcc_debug_hooks): New hook, imported_module_or_decl. + * dwarf2out.c: Include input.h. + (dwarf2_debug_hooks): Add new hook for imported_module_or_decl. + (remove_child_TAG): New function. + (dwarf_tag_name): Handle DW_TAG_imported_module. + (gen_subprogram_die): Equate decl number to declaration die. Do not + remove all children dies while reusing declaration die for definition. + Instead, selectively remove only formal parameters. + (gen_variable_die): Equate variable decl to declaration die. + (gen_field_die): Equate field decl to line number. + (force_namespace_die): Replace it with ... + (force_decl_die): ... this. + (force_type_die): New function. + (setup_namespace_context): Replace use of force_namespace_die() with + force_decl_die(). + (gen_namespace_die): Same. + (dwarf2out_imported_module_or_decl): New function. + 2004-01-27 Bob Wilson <bob.wilson@acm.org> * config/xtensa/xtensa.c (xtensa_copy_incoming_a7): Remove SUBREG diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 98c07f2..ff2878c 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1599,7 +1599,7 @@ dwarf2out.o : dwarf2out.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ output.h $(DIAGNOSTIC_H) real.h hard-reg-set.h $(REGS_H) $(EXPR_H) \ libfuncs.h toplev.h dwarf2out.h varray.h $(GGC_H) except.h dwarf2asm.h \ $(TM_P_H) langhooks.h $(HASHTAB_H) gt-dwarf2out.h $(TARGET_H) cgraph.h \ - $(MD5_H) + $(MD5_H) input.h dwarf2asm.o : dwarf2asm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) flags.h $(RTL_H) \ $(TREE_H) output.h dwarf2asm.h $(TM_P_H) $(GGC_H) gt-dwarf2asm.h vmsdbgout.o : vmsdbgout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 001c992..2bd3883 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2004-01-27 Devang Patel <dpatel@apple.com> + + * name-lookup.c: Include "debug.h" + (do_namespace_alias): Invoke debug_hooks to emit debug info + for namespace alias. + (do_local_using_decl): Invoke debug_hooks to emit debug info + for using decl. + (do_class_using_decl): Same. + (do_toplevel_using_decl): Same. + (do_using_directive): Same. + (cp_emit_debug_info_for_using): New function. + * Make-lang.in (cp/parser.o): Depend on debug.h + (cp/name-lookup.o): Same. + 2004-01-26 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * cp-tree.h (language_function, lang_type_header): Use diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index f4e58d5..3723a9f 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -262,11 +262,12 @@ cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) rtl.h integrate.h insn-config input.h $(PARAMS_H) debug.h tree-inline.h cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) toplev.h real.h gt-cp-mangle.h $(TM_P_H) -cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) diagnostic.h gt-cp-parser.h output.h +cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) diagnostic.h gt-cp-parser.h \ + output.h cp/name-lookup.o: cp/name-lookup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(CXX_TREE_H) timevar.h gt-cp-name-lookup.h toplev.h \ - $(DIAGNOSTIC_H) flags.h + $(DIAGNOSTIC_H) flags.h debug.h cp/cxx-pretty-print.o: cp/cxx-pretty-print.c $(CXX_PRETTY_PRINT_H) \ $(CONFIG_H) $(SYSTEM_H) $(TM_H) coretypes.h $(CXX_TREE_H) diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 14f7b76..30ff8e5 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -30,6 +30,7 @@ Boston, MA 02111-1307, USA. */ #include "timevar.h" #include "toplev.h" #include "diagnostic.h" +#include "debug.h" static cxx_scope *innermost_nonclass_level (void); static tree select_decl (cxx_binding *, int); @@ -42,7 +43,7 @@ static bool lookup_using_namespace (tree, cxx_binding *, tree, static bool qualified_lookup_using_namespace (tree, tree, cxx_binding *, int); static tree lookup_type_current_level (tree); static tree push_using_directive (tree); - +static void cp_emit_debug_info_for_using (tree, tree); /* The :: namespace. */ @@ -2226,6 +2227,7 @@ void do_local_using_decl (tree decl, tree scope, tree name) { tree oldval, oldtype, newval, newtype; + tree orig_decl = decl; decl = validate_nonmember_using_decl (decl, scope, name); if (decl == NULL_TREE) @@ -2264,6 +2266,10 @@ do_local_using_decl (tree decl, tree scope, tree name) } if (newtype) set_identifier_type_value (name, newtype); + + /* Emit debug info. */ + if (!processing_template_decl) + cp_emit_debug_info_for_using (orig_decl, current_scope()); } /* Return the type that should be used when TYPE's name is preceded @@ -2829,6 +2835,15 @@ do_class_using_decl (tree decl) type = dependent_type_p (scope) ? NULL_TREE : void_type_node; value = build_lang_decl (USING_DECL, name, type); DECL_INITIAL (value) = scope; + + if (scope && !processing_template_decl) + { + tree r; + + r = lookup_qualified_name (scope, name, false, false); + if (r && TREE_CODE (r) != ERROR_MARK) + cp_emit_debug_info_for_using (r, scope); + } return value; } @@ -3135,6 +3150,9 @@ do_namespace_alias (tree alias, tree namespace) DECL_NAMESPACE_ALIAS (alias) = namespace; DECL_EXTERNAL (alias) = 1; pushdecl (alias); + + /* Emit debug info for namespace alias. */ + (*debug_hooks->global_decl) (alias); } /* Like pushdecl, only it places X in the current namespace, @@ -3238,6 +3256,7 @@ void do_toplevel_using_decl (tree decl, tree scope, tree name) { tree oldval, oldtype, newval, newtype; + tree orig_decl = decl; cxx_binding *binding; decl = validate_nonmember_using_decl (decl, scope, name); @@ -3251,6 +3270,10 @@ do_toplevel_using_decl (tree decl, tree scope, tree name) do_nonmember_using_decl (scope, name, oldval, oldtype, &newval, &newtype); + /* Emit debug info. */ + if (!processing_template_decl) + cp_emit_debug_info_for_using (orig_decl, current_namespace); + /* Copy declarations found. */ if (newval) binding->value = newval; @@ -3264,6 +3287,8 @@ do_toplevel_using_decl (tree decl, tree scope, tree name) void do_using_directive (tree namespace) { + tree context = NULL_TREE; + if (building_stmt_tree ()) add_stmt (build_stmt (USING_STMT, namespace)); @@ -3285,10 +3310,21 @@ do_using_directive (tree namespace) } namespace = ORIGINAL_NAMESPACE (namespace); if (!toplevel_bindings_p ()) - push_using_directive (namespace); + { + push_using_directive (namespace); + context = current_scope (); + } else - /* direct usage */ - add_using_namespace (current_namespace, namespace, 0); + { + /* direct usage */ + add_using_namespace (current_namespace, namespace, 0); + if (current_namespace != global_namespace) + context = current_namespace; + } + + /* Emit debugging info. */ + if (!processing_template_decl) + (*debug_hooks->imported_module_or_decl) (namespace, context); } /* Deal with a using-directive seen by the parser. Currently we only @@ -4803,4 +4839,32 @@ pop_everything (void) verbatim ("XXX leaving pop_everything ()\n"); } +/* Emit debugging information for using declarations and directives. + If input tree is overloaded fn then emit debug info for all + candidates. */ + +static void +cp_emit_debug_info_for_using (tree t, tree context) +{ + /* Ignore this FUNCTION_DECL if it refers to a builtin declaration + of a builtin function. */ + if (TREE_CODE (t) == FUNCTION_DECL + && DECL_EXTERNAL (t) + && DECL_BUILT_IN (t)) + return; + + /* Do not supply context to imported_module_or_decl, if + it is a global namespace. */ + if (context == global_namespace) + context = NULL_TREE; + + if (BASELINK_P (t)) + t = BASELINK_FUNCTIONS (t); + + /* FIXME: Handle TEMPLATE_DECLs. */ + for (t = OVL_CURRENT (t); t; t = OVL_NEXT (t)) + if (TREE_CODE (t) != TEMPLATE_DECL) + (*debug_hooks->imported_module_or_decl) (t, context); + } + #include "gt-cp-name-lookup.h" diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 46fc026..3561f43 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -382,23 +382,25 @@ const struct gcc_debug_hooks dbx_debug_hooks = dbxout_end_source_file, dbxout_begin_block, dbxout_end_block, - debug_true_tree, /* ignore_block */ - dbxout_source_line, /* source_line */ - dbxout_source_line, /* begin_prologue: just output line info */ - debug_nothing_int_charstar, /* end_prologue */ - debug_nothing_int_charstar, /* end_epilogue */ + debug_true_tree, /* ignore_block */ + dbxout_source_line, /* source_line */ + dbxout_source_line, /* begin_prologue: just output + line info */ + debug_nothing_int_charstar, /* end_prologue */ + debug_nothing_int_charstar, /* end_epilogue */ #ifdef DBX_FUNCTION_FIRST dbxout_begin_function, #else - debug_nothing_tree, /* begin_function */ + debug_nothing_tree, /* begin_function */ #endif - debug_nothing_int, /* end_function */ + debug_nothing_int, /* end_function */ dbxout_function_decl, - dbxout_global_decl, /* global_decl */ - debug_nothing_tree, /* deferred_inline_function */ - debug_nothing_tree, /* outlining_inline_function */ - debug_nothing_rtx, /* label */ - dbxout_handle_pch /* handle_pch */ + dbxout_global_decl, /* global_decl */ + debug_nothing_tree_tree, /* imported_module_or_decl */ + debug_nothing_tree, /* deferred_inline_function */ + debug_nothing_tree, /* outlining_inline_function */ + debug_nothing_rtx, /* label */ + dbxout_handle_pch /* handle_pch */ }; #endif /* DBX_DEBUGGING_INFO */ @@ -413,19 +415,20 @@ const struct gcc_debug_hooks xcoff_debug_hooks = dbxout_end_source_file, xcoffout_begin_block, xcoffout_end_block, - debug_true_tree, /* ignore_block */ + debug_true_tree, /* ignore_block */ xcoffout_source_line, - xcoffout_begin_prologue, /* begin_prologue */ - debug_nothing_int_charstar, /* end_prologue */ + xcoffout_begin_prologue, /* begin_prologue */ + debug_nothing_int_charstar, /* end_prologue */ xcoffout_end_epilogue, - debug_nothing_tree, /* begin_function */ + debug_nothing_tree, /* begin_function */ xcoffout_end_function, - debug_nothing_tree, /* function_decl */ - dbxout_global_decl, /* global_decl */ - debug_nothing_tree, /* deferred_inline_function */ - debug_nothing_tree, /* outlining_inline_function */ - debug_nothing_rtx, /* label */ - dbxout_handle_pch /* handle_pch */ + debug_nothing_tree, /* function_decl */ + dbxout_global_decl, /* global_decl */ + debug_nothing_tree_tree, /* imported_module_or_decl */ + debug_nothing_tree, /* deferred_inline_function */ + debug_nothing_tree, /* outlining_inline_function */ + debug_nothing_rtx, /* label */ + dbxout_handle_pch /* handle_pch */ }; #endif /* XCOFF_DEBUGGING_INFO */ diff --git a/gcc/debug.c b/gcc/debug.c index e18ce55..03b0acc 100644 --- a/gcc/debug.c +++ b/gcc/debug.c @@ -30,21 +30,22 @@ const struct gcc_debug_hooks do_nothing_debug_hooks = debug_nothing_int_charstar, debug_nothing_int_charstar, debug_nothing_int, - debug_nothing_int_int, /* begin_block */ - debug_nothing_int_int, /* end_block */ - debug_true_tree, /* ignore_block */ - debug_nothing_int_charstar, /* source_line */ - debug_nothing_int_charstar, /* begin_prologue */ - debug_nothing_int_charstar, /* end_prologue */ - debug_nothing_int_charstar, /* end_epilogue */ - debug_nothing_tree, /* begin_function */ - debug_nothing_int, /* end_function */ - debug_nothing_tree, /* function_decl */ - debug_nothing_tree, /* global_decl */ - debug_nothing_tree, /* deferred_inline_function */ - debug_nothing_tree, /* outlining_inline_function */ - debug_nothing_rtx, /* label */ - debug_nothing_int /* handle_pch */ + debug_nothing_int_int, /* begin_block */ + debug_nothing_int_int, /* end_block */ + debug_true_tree, /* ignore_block */ + debug_nothing_int_charstar, /* source_line */ + debug_nothing_int_charstar, /* begin_prologue */ + debug_nothing_int_charstar, /* end_prologue */ + debug_nothing_int_charstar, /* end_epilogue */ + debug_nothing_tree, /* begin_function */ + debug_nothing_int, /* end_function */ + debug_nothing_tree, /* function_decl */ + debug_nothing_tree, /* global_decl */ + debug_nothing_tree_tree, /* imported_module_or_decl */ + debug_nothing_tree, /* deferred_inline_function */ + debug_nothing_tree, /* outlining_inline_function */ + debug_nothing_rtx, /* label */ + debug_nothing_int /* handle_pch */ }; /* This file contains implementations of each debug hook that do @@ -60,6 +61,12 @@ debug_nothing_tree (tree decl ATTRIBUTE_UNUSED) { } +void +debug_nothing_tree_tree (tree t1 ATTRIBUTE_UNUSED, + tree t2 ATTRIBUTE_UNUSED) +{ +} + bool debug_true_tree (tree block ATTRIBUTE_UNUSED) { diff --git a/gcc/debug.h b/gcc/debug.h index 22d8378..fee3bc6 100644 --- a/gcc/debug.h +++ b/gcc/debug.h @@ -89,6 +89,9 @@ struct gcc_debug_hooks compilation proper has finished. */ void (* global_decl) (tree decl); + /* Debug information for imported modules and declarations. */ + void (* imported_module_or_decl) (tree decl, tree context); + /* DECL is an inline function, whose body is present, but which is not being output at this point. */ void (* deferred_inline_function) (tree decl); @@ -116,6 +119,7 @@ extern void debug_nothing_int_charstar (unsigned int, const char *); extern void debug_nothing_int (unsigned int); extern void debug_nothing_int_int (unsigned int, unsigned int); extern void debug_nothing_tree (tree); +extern void debug_nothing_tree_tree (tree, tree); extern bool debug_true_tree (tree); extern void debug_nothing_rtx (rtx); diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 7dca634..f9d86b5 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -65,6 +65,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "langhooks.h" #include "hashtab.h" #include "cgraph.h" +#include "input.h" #ifdef DWARF2_DEBUGGING_INFO static void dwarf2out_source_line (unsigned int, const char *); @@ -3248,6 +3249,7 @@ static void dwarf2out_begin_block (unsigned, unsigned); static void dwarf2out_end_block (unsigned, unsigned); static bool dwarf2out_ignore_block (tree); static void dwarf2out_global_decl (tree); +static void dwarf2out_imported_module_or_decl (tree, tree); static void dwarf2out_abstract_function (tree); /* The debug hooks structure. */ @@ -3271,6 +3273,7 @@ const struct gcc_debug_hooks dwarf2_debug_hooks = debug_nothing_int, /* end_function */ dwarf2out_decl, /* function_decl */ dwarf2out_global_decl, + dwarf2out_imported_module_or_decl, debug_nothing_tree, /* deferred_inline_function */ /* The DWARF 2 backend tries to reduce debugging bloat by not emitting the abstract description of inline functions until @@ -3647,6 +3650,7 @@ static bool is_java (void); static bool is_fortran (void); static bool is_ada (void); static void remove_AT (dw_die_ref, enum dwarf_attribute); +static void remove_child_TAG (dw_die_ref, enum dwarf_tag); static inline void free_die (dw_die_ref); static void remove_children (dw_die_ref); static void add_child_die (dw_die_ref, dw_die_ref); @@ -3795,7 +3799,8 @@ static void decls_for_scope (tree, dw_die_ref, int); static int is_redundant_typedef (tree); static void gen_namespace_die (tree); static void gen_decl_die (tree, dw_die_ref); -static dw_die_ref force_namespace_die (tree); +static dw_die_ref force_decl_die (tree); +static dw_die_ref force_type_die (tree); static dw_die_ref setup_namespace_context (tree, dw_die_ref); static void declare_in_namespace (tree, dw_die_ref); static unsigned lookup_filename (const char *); @@ -4073,6 +4078,8 @@ dwarf_tag_name (unsigned int tag) return "DW_TAG_variable"; case DW_TAG_volatile_type: return "DW_TAG_volatile_type"; + case DW_TAG_imported_module: + return "DW_TAG_imported_module"; case DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop"; case DW_TAG_format_label: @@ -5049,6 +5056,34 @@ remove_AT (dw_die_ref die, enum dwarf_attribute attr_kind) } } +/* Remove child die whose die_tag is specified tag. */ + +static void +remove_child_TAG (dw_die_ref die, enum dwarf_tag tag) +{ + dw_die_ref current, prev, next; + current = die->die_child; + prev = NULL; + while (current != NULL) + { + if (current->die_tag == tag) + { + next = current->die_sib; + if (prev == NULL) + die->die_child = next; + else + prev->die_sib = next; + free_die (current); + current = next; + } + else + { + prev = current; + current = current->die_sib; + } + } +} + /* Free up the memory used by DIE. */ static inline void @@ -10712,9 +10747,13 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) { subr_die = old_die; - /* Clear out the declaration attribute and the parm types. */ + /* Clear out the declaration attribute and the formal parameters. + Do not remove all children, because it is possible that this + declaration die was forced using force_decl_die(). In such + cases die that forced declaration die (e.g. TAG_imported_module) + is one of the children that we do not want to remove. */ remove_AT (subr_die, DW_AT_declaration); - remove_children (subr_die); + remove_child_TAG (subr_die, DW_TAG_formal_parameter); } else { @@ -10762,8 +10801,10 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) /* The first time we see a member function, it is in the context of the class to which it belongs. We make sure of this by emitting the class first. The next time is the definition, which is - handled above. The two may come from the same source text. */ - if (DECL_CONTEXT (decl) || DECL_ABSTRACT (decl)) + handled above. The two may come from the same source text. + + Note that force_decl_die() forces function declaration die. It is + later reused to represent definition. */ equate_decl_number_to_die (decl, subr_die); } } @@ -10975,7 +11016,7 @@ gen_variable_die (tree decl, dw_die_ref context_die) if (declaration) add_AT_flag (var_die, DW_AT_declaration, 1); - if (class_or_namespace_scope_p (context_die) || DECL_ABSTRACT (decl)) + if (DECL_ABSTRACT (decl) || declaration) equate_decl_number_to_die (decl, var_die); if (! declaration && ! DECL_ABSTRACT (decl)) @@ -11147,6 +11188,9 @@ gen_field_die (tree decl, dw_die_ref context_die) add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_protected); else if (TREE_PRIVATE (decl)) add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_private); + + /* Equate decl number to die, so that we can look up this decl later on. */ + equate_decl_number_to_die (decl, decl_die); } #if 0 @@ -11857,23 +11901,95 @@ is_redundant_typedef (tree decl) return 0; } -/* Returns the DIE for namespace NS or aborts. +/* Returns the DIE for decl or aborts. */ - Note that namespaces don't really have a lexical context, so there's no - need to pass in a context_die. They always go inside their containing - namespace, or comp_unit_die if none. */ +static dw_die_ref +force_decl_die (tree decl) +{ + dw_die_ref decl_die; + unsigned saved_external_flag; + tree save_fn = NULL_TREE; + decl_die = lookup_decl_die (decl); + if (!decl_die) + { + dw_die_ref context_die; + tree decl_context = DECL_CONTEXT (decl); + if (decl_context) + { + /* Find die that represents this context. */ + if (TYPE_P (decl_context)) + context_die = force_type_die (decl_context); + else + context_die = force_decl_die (decl_context); + } + else + context_die = comp_unit_die; + + switch (TREE_CODE (decl)) + { + case FUNCTION_DECL: + /* Clear current_function_decl, so that gen_subprogram_die thinks + that this is a declaration. At this point, we just want to force + declaration die. */ + save_fn = current_function_decl; + current_function_decl = NULL_TREE; + gen_subprogram_die (decl, context_die); + current_function_decl = save_fn; + break; + + case VAR_DECL: + /* Set external flag to force declaration die. Restore it after + gen_decl_die() call. */ + saved_external_flag = DECL_EXTERNAL (decl); + DECL_EXTERNAL (decl) = 1; + gen_decl_die (decl, context_die); + DECL_EXTERNAL (decl) = saved_external_flag; + break; + + case NAMESPACE_DECL: + dwarf2out_decl (decl); + break; + + default: + abort (); + } + + /* See if we can find the die for this deci now. + If not then abort. */ + if (!decl_die) + decl_die = lookup_decl_die (decl); + if (!decl_die) + abort (); + } + + return decl_die; +} + +/* Returns the DIE for decl or aborts. */ static dw_die_ref -force_namespace_die (tree ns) +force_type_die (tree type) { - dw_die_ref ns_die; + dw_die_ref type_die; - dwarf2out_decl (ns); - ns_die = lookup_decl_die (ns); - if (!ns_die) - abort(); + type_die = lookup_type_die (root_type (type)); + if (!type_die) + { + dw_die_ref context_die; + if (TYPE_CONTEXT (type)) + if (TYPE_P (TYPE_CONTEXT (type))) + context_die = force_type_die (TYPE_CONTEXT (type)); + else + context_die = force_decl_die (TYPE_CONTEXT (type)); + else + context_die = comp_unit_die; - return ns_die; + gen_type_die (type, context_die); + type_die = lookup_type_die (root_type (type)); + if (!type_die) + abort(); + } + return type_die; } /* Force out any required namespaces to be able to output DECL, @@ -11885,7 +12001,7 @@ setup_namespace_context (tree thing, dw_die_ref context_die) tree context = DECL_P (thing) ? DECL_CONTEXT (thing) : TYPE_CONTEXT (thing); if (context && TREE_CODE (context) == NAMESPACE_DECL) /* Force out the namespace. */ - context_die = force_namespace_die (context); + context_die = force_decl_die (context); return context_die; } @@ -11938,7 +12054,7 @@ gen_namespace_die (tree decl) /* Force out the namespace we are an alias of, if necessary. */ dw_die_ref origin_die - = force_namespace_die (DECL_ABSTRACT_ORIGIN (decl)); + = force_decl_die (DECL_ABSTRACT_ORIGIN (decl)); /* Now create the namespace alias DIE. */ dw_die_ref namespace_die @@ -12141,6 +12257,52 @@ dwarf2out_global_decl (tree decl) dwarf2out_decl (decl); } +/* Output debug information for imported module or decl. */ + +static void +dwarf2out_imported_module_or_decl (tree decl, tree context) +{ + dw_die_ref imported_die, at_import_die; + dw_die_ref scope_die; + unsigned file_index; + + if (debug_info_level <= DINFO_LEVEL_TERSE) + return; + + if (!decl) + abort (); + + /* To emit DW_TAG_imported_module or DW_TAG_imported_decl, we need two DIEs. + We need decl DIE for reference and scope die. First, get DIE for the decl + itself. */ + + /* Get the scope die for decl context. Use comp_unit_die for global module + or decl. If die is not found for non globals, force new die. */ + if (!context) + scope_die = comp_unit_die; + else if (TYPE_P (context)) + scope_die = force_type_die (context); + else + scope_die = force_decl_die (context); + + /* For TYPE_DECL, lookup TREE_TYPE. */ + if (TREE_CODE (decl) == TYPE_DECL) + at_import_die = force_type_die (TREE_TYPE (decl)); + else + at_import_die = force_decl_die (decl); + + /* OK, now we have DIEs for decl as well as scope. Emit imported die. */ + if (TREE_CODE (decl) == NAMESPACE_DECL) + imported_die = new_die (DW_TAG_imported_module, scope_die, context); + else + imported_die = new_die (DW_TAG_imported_declaration, scope_die, context); + + file_index = lookup_filename (input_filename); + add_AT_unsigned (imported_die, DW_AT_decl_file, file_index); + add_AT_unsigned (imported_die, DW_AT_decl_line, input_line); + add_AT_die_ref (imported_die, DW_AT_import, at_import_die); +} + /* Write the debugging output for DECL. */ void diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 3d62047..d33b5c1 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -307,34 +307,35 @@ static struct sdb_file *current_file; /* The debug hooks structure. */ const struct gcc_debug_hooks sdb_debug_hooks = { - sdbout_init, /* init */ - sdbout_finish, /* finish */ - debug_nothing_int_charstar, /* define */ - debug_nothing_int_charstar, /* undef */ - sdbout_start_source_file, /* start_source_file */ - sdbout_end_source_file, /* end_source_file */ - sdbout_begin_block, /* begin_block */ - sdbout_end_block, /* end_block */ - debug_true_tree, /* ignore_block */ - sdbout_source_line, /* source_line */ + sdbout_init, /* init */ + sdbout_finish, /* finish */ + debug_nothing_int_charstar, /* define */ + debug_nothing_int_charstar, /* undef */ + sdbout_start_source_file, /* start_source_file */ + sdbout_end_source_file, /* end_source_file */ + sdbout_begin_block, /* begin_block */ + sdbout_end_block, /* end_block */ + debug_true_tree, /* ignore_block */ + sdbout_source_line, /* source_line */ #ifdef MIPS_DEBUGGING_INFO /* Defer on MIPS systems so that parameter descriptions follow function entry. */ - debug_nothing_int_charstar, /* begin_prologue */ - sdbout_end_prologue, /* end_prologue */ + debug_nothing_int_charstar, /* begin_prologue */ + sdbout_end_prologue, /* end_prologue */ #else - sdbout_begin_prologue, /* begin_prologue */ - debug_nothing_int_charstar, /* end_prologue */ + sdbout_begin_prologue, /* begin_prologue */ + debug_nothing_int_charstar, /* end_prologue */ #endif - sdbout_end_epilogue, /* end_epilogue */ - sdbout_begin_function, /* begin_function */ - sdbout_end_function, /* end_function */ - debug_nothing_tree, /* function_decl */ - sdbout_global_decl, /* global_decl */ - debug_nothing_tree, /* deferred_inline_function */ - debug_nothing_tree, /* outlining_inline_function */ - sdbout_label, /* label */ - debug_nothing_int /* handle_pch */ + sdbout_end_epilogue, /* end_epilogue */ + sdbout_begin_function, /* begin_function */ + sdbout_end_function, /* end_function */ + debug_nothing_tree, /* function_decl */ + sdbout_global_decl, /* global_decl */ + debug_nothing_tree_tree, /* imported_module_or_decl */ + debug_nothing_tree, /* deferred_inline_function */ + debug_nothing_tree, /* outlining_inline_function */ + sdbout_label, /* label */ + debug_nothing_int /* handle_pch */ }; /* Return a unique string to name an anonymous type. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2649274..53070cc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-01-27 Devang Patel <dpatel@apple.com> + + * g++.dg/debug/namespace1.C: New test. + 2004-01-27 Ian Lance Taylor <ian@wasabisystems.com> * gcc.dg/const-elim-1.c: Add xfail for strongarm-*-* and diff --git a/gcc/testsuite/g++.dg/debug/namespace1.C b/gcc/testsuite/g++.dg/debug/namespace1.C new file mode 100644 index 0000000..c1954d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/namespace1.C @@ -0,0 +1,258 @@ +/* Test DWARF namespace support. + This test case is based on GDB testsuite test case. */ +/* { dg-do compile } */ + +namespace AAA { + char c; + int i; + int A_xyzq (int); + char xyzq (char); + class inA { + public: + int xx; + int fum (int); + }; +}; + +int AAA::inA::fum (int i) +{ + return 10 + i; +} + +namespace BBB { + char c; + int i; + int B_xyzq (int); + char xyzq (char); + + namespace CCC { + char xyzq (char); + }; + + class Class { + public: + char xyzq (char); + int dummy; + }; +}; + +int AAA::A_xyzq (int x) +{ + return 2 * x; +} + +char AAA::xyzq (char c) +{ + return 'a'; +} + + +int BBB::B_xyzq (int x) +{ + return 3 * x; +} + +char BBB::xyzq (char c) +{ + return 'b'; +} + +char BBB::CCC::xyzq (char c) +{ + return 'z'; +} + +char BBB::Class::xyzq (char c) +{ + return 'o'; +} + +void marker1(void) +{ + return; +} + +namespace +{ + int X = 9; + + namespace G + { + int Xg = 10; + + namespace + { + int XgX = 11; + } + } +} + +namespace H +{ + int h = 14; +} + +namespace I = H; + +namespace J +{ + int j = 15; +} + +using namespace J; + +namespace K +{ + int k = 16; +} + +namespace L +{ + using namespace K; +} + +namespace O +{ + int o = 18; +} + +namespace P +{ + using namespace O; +} + +namespace Q +{ + using namespace P; +} + +namespace R +{ + int r1 = 19; + int r2 = 20; +} + +using R::r1; + +namespace C +{ + int c = 1; + int shadow = 12; + + class CClass { + public: + int x; + class NestedClass { + public: + int y; + }; + }; + + namespace + { + int cX = 6; + + namespace F + { + int cXf = 7; + + namespace + { + int cXfX = 8; + } + } + } + + namespace C + { + int cc = 2; + } + + namespace E + { + int ce = 4; + } + + namespace D + { + int cd = 3; + int shadow = 13; + + namespace E + { + int cde = 5; + } + + namespace M + { + int cdm = 17; + } + + using namespace M; + + void marker2 (void) + { + // NOTE: carlton/2003-04-23: I'm listing the expressions that I + // plan to have GDB try to print out, just to make sure that the + // compiler and I agree which ones should be legal! It's easy + // to screw up when testing the boundaries of namespace stuff. + c; + //cc; + C::cc; + cd; + //C::D::cd; + E::cde; + shadow; + //E::ce; + cX; + F::cXf; + F::cXfX; + X; + G::Xg; + //cXOtherFile; + //XOtherFile; + G::XgX; + I::h; + j; + L::k; + //k; + cdm; + Q::o; + //o; + r1; + //r2; + + return; + } + + } +} + +int main () +{ + using AAA::inA; + char c1; + + using namespace BBB; + + c1 = xyzq ('x'); + c1 = AAA::xyzq ('x'); + c1 = BBB::CCC::xyzq ('m'); + + inA ina; + + ina.xx = 33; + + int y; + + y = AAA::A_xyzq (33); + y += B_xyzq (44); + + BBB::Class cl; + + c1 = cl.xyzq('e'); + + marker1(); + + C::D::marker2 (); +} diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c index 4f7f62d..0a9062a 100644 --- a/gcc/vmsdbgout.c +++ b/gcc/vmsdbgout.c @@ -186,10 +186,11 @@ const struct gcc_debug_hooks vmsdbg_debug_hooks vmsdbgout_end_function, vmsdbgout_decl, vmsdbgout_global_decl, - debug_nothing_tree, /* deferred_inline_function */ + debug_nothing_tree_tree, /* imported_module_or_decl */ + debug_nothing_tree, /* deferred_inline_function */ vmsdbgout_abstract_function, - debug_nothing_rtx, /* label */ - debug_nothing_int /* handle_pch */ + debug_nothing_rtx, /* label */ + debug_nothing_int /* handle_pch */ }; /* Definitions of defaults for assembler-dependent names of various |