Bug 488547 - Missing namespace import debug information
Missing namespace import debug information
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-04 14:12 EST by Sami Wagiaalla
Modified: 2016-06-07 18:46 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-03-05 16:29:37 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 39379 None None None Never

  None (edit)
Description Sami Wagiaalla 2009-03-04 14:12:37 EST
The following program compiled with gcc 4.4.0:

namespace A{
  int x;
}

int main(){
  using namespace A;
  x;
  return x;
}

produces the following debug information:

...
 <1><25>: Abbrev Number: 2 (DW_TAG_subprogram)
    <26>   DW_AT_external    : 1        
    <27>   DW_AT_name        : (indirect string, offset: 0x2e): main    
    <2b>   DW_AT_decl_file   : 1        
    <2c>   DW_AT_decl_line   : 5        
    <2d>   DW_AT_type        : <0x3d>   
    <31>   DW_AT_low_pc      : 0x8048444        
    <35>   DW_AT_high_pc     : 0x804844e        
    <39>   DW_AT_frame_base  : 0x0      (location list)
 <1><3d>: Abbrev Number: 3 (DW_TAG_base_type)
    <3e>   DW_AT_byte_size   : 4        
    <3f>   DW_AT_encoding    : 5        (signed)
    <40>   DW_AT_name        : int      
...

As you can see die <25> is missing a child die indication the import of the namespace as was done in gcc 4.3.2:

...
 <1><2d>: Abbrev Number: 2 (DW_TAG_subprogram)
    <2e>   DW_AT_external    : 1        
    <2f>   DW_AT_name        : (indirect string, offset: 0x56): main    
    <33>   DW_AT_decl_file   : 1        
    <34>   DW_AT_decl_line   : 5        
    <35>   DW_AT_type        : <0x59>   
    <39>   DW_AT_low_pc      : 0x40055c 
    <41>   DW_AT_high_pc     : 0x400568 
    <49>   DW_AT_frame_base  : 0x0      (location list)
    <4d>   DW_AT_sibling     : <0x59>   
 <2><51>: Abbrev Number: 3 (DW_TAG_imported_module)
    <52>   DW_AT_decl_file   : 1        
    <53>   DW_AT_decl_line   : 6        
    <54>   DW_AT_import      : <0x60>   [Abbrev Number: 5 (DW_TAG_namespace)]
 <1><59>: Abbrev Number: 4 (DW_TAG_base_type)
    <5a>   DW_AT_byte_size   : 4        
    <5b>   DW_AT_encoding    : 5        (signed)
    <5c>   DW_AT_name        : int      
...
Comment 1 Jan Kratochvil 2009-03-04 15:21:09 EST
Confirming I see it also as Sami as a regression.  Verified on:
  g++ (GCC) 4.4.0 20090303 (experimental)
  gcc-c++-4.4.0-0.21.1.x86_64

But it can be workarounded by using a different function name than `main'
- `main' is in many cases somehow special for GCC.

It looks like http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38390 fixed/CLOSED by Dodji but it is a different import-inhibitor here.

Maybe could you Sami just repost it to the upstream BZ?
Comment 2 Jakub Jelinek 2009-03-04 15:29:21 EST
I'll fix this myself, no need to report to upstream.
Comment 3 Jakub Jelinek 2009-03-04 17:02:10 EST
Even:

namespace A
{
  int x;
}

int
foo ()
{
  { 
    using namespace A;
    x;
    return x;
  }
}

doesn't contain any DW_TAG_import*.
The problem is in remove_useless_stmts_bind, which removes GIMPLE_BIND stmts that have no gimple_bind_vars (stmt), aren't the function topmost stmt (in the main case that's because of the added return 0; in C++).
Something like:

--- tree-cfg.c.xx	2009-03-02 09:45:47.000000000 +0100
+++ tree-cfg.c	2009-03-04 22:59:56.000000000 +0100
@@ -1796,6 +1796,16 @@ remove_useless_stmts_bind (gimple_stmt_i
 	  || (TREE_CODE (BLOCK_ABSTRACT_ORIGIN (block))
 	      != FUNCTION_DECL)))
     {
+      if (block)
+	{
+	  tree var;
+	  for (var = BLOCK_VARS (block); var; var = TREE_CHAIN (var))
+	    if (TREE_CODE (var) == IMPORTED_DECL)
+	      {
+		gsi_next (gsi);
+		return;
+	      }
+	}
       gsi_insert_seq_before (gsi, body_seq, GSI_SAME_STMT);
       gsi_remove (gsi, false);
       data->repeat = true;

fixes it, but I'll play with it more tomorrow.

Note You need to log in before you can comment on or make changes to this bug.