It works on Fedora gcc-c++-4.3.2-7.x86_64 but on 4.4-HEAD DIEs for DW_TAG_imported_module are just missing. import.C ------------------------------------------------------------------------------ namespace A { int v; } int f () { using namespace A; return v; } ------------------------------------------------------------------------------ g++ -c -o import.o import.C -Wall -g From gcc-c++-4.3.2-7.x86_64: <1><2d>: Abbrev Number: 2 (DW_TAG_subprogram) <2e> DW_AT_external : 1 <2f> DW_AT_name : f <31> DW_AT_decl_file : 1 <32> DW_AT_decl_line : 7 <33> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x37): _Z1fv <37> DW_AT_type : <0x5b> <3b> DW_AT_low_pc : 0x0 <43> DW_AT_high_pc : 0xc <4b> DW_AT_frame_base : 0x0 (location list) <4f> DW_AT_sibling : <0x5b> <2><53>: Abbrev Number: 3 (DW_TAG_imported_module) <54> DW_AT_decl_file : 1 <55> DW_AT_decl_line : 9 <56> DW_AT_import : <0x62> [Abbrev Number: 5 (DW_TAG_namespace)] From GNU C++ (GCC) version 4.4.0 20081202 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.4.0 20081202 (experimental), GMP version 4.2.2, MPFR version 2.3.2. GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 <1><2d>: Abbrev Number: 2 (DW_TAG_subprogram) <2e> DW_AT_external : 1 <2f> DW_AT_name : f <31> DW_AT_decl_file : 1 <32> DW_AT_decl_line : 7 <33> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2b): _Z1fv <37> DW_AT_type : <0x4f> <3b> DW_AT_low_pc : 0x0 <43> DW_AT_high_pc : 0xc <4b> DW_AT_frame_base : 0x0 (location list) (other DIEs exactly the same, DW_TAG_imported_module is missing here)
It looks like this is due to the fact that f contains no statement considered "meaningful" by the front end. So, no BIND_EXPR node is being generated for its body, so no debug info is being generated for its body either. For instance, in the example below: namespace A { int v; } int f () { int i = 0; using namespace A; return v; } the DW_AT_imported_module is being generated correctly.
Created attachment 16834 [details] A candidate patch This patch seems to fix the problem. I haven't tried to make it pass regtests yet though.
The patch passes regtests. I have posted it to http://gcc.gnu.org/ml/gcc-patches/2008-12/msg00442.html
Subject: Bug 38390 Author: dodji Date: Mon Dec 8 19:00:46 2008 New Revision: 142562 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142562 Log: gcc/cp/ChangeLog: 2008-12-07 Dodji Seketeli <dodji@redhat.com> PR debug/38390 * name-lookup.c (kept_level_p): Don't forget the case of levels having using directives. gcc/testsuite/ChangeLog: 2008-12-07 Dodji Seketeli <dodji@redhat.com> PR debug/38390 * g++.dg/debug/dwarf2/imported-module-2.C: New test. Added: trunk/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/name-lookup.c trunk/gcc/testsuite/ChangeLog
Fixed in trunk.