Bug 38390 - Missing DW_TAG_imported_module
Summary: Missing DW_TAG_imported_module
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Dodji Seketeli
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-03 21:17 UTC by Jan Kratochvil
Modified: 2008-12-24 00:53 UTC (History)
4 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-12-05 16:17:53


Attachments
A candidate patch (254 bytes, patch)
2008-12-05 20:29 UTC, Dodji Seketeli
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2008-12-03 21:17:24 UTC
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)
Comment 1 Dodji Seketeli 2008-12-05 20:27:37 UTC
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.
Comment 2 Dodji Seketeli 2008-12-05 20:29:41 UTC
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.
Comment 3 Dodji Seketeli 2008-12-07 22:19:34 UTC
The patch passes regtests. I have posted it to http://gcc.gnu.org/ml/gcc-patches/2008-12/msg00442.html
Comment 4 Dodji Seketeli 2008-12-08 19:02:13 UTC
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

Comment 5 Dodji Seketeli 2008-12-08 19:25:55 UTC
Fixed in trunk.