First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 14049
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Michael Elizabeth Chastain <mec.gnu@mindspring.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
block.cc Source code text/plain 2004-02-06 16:53 119 bytes Edit
block.HEAD.dwarf-2.s Good assembly code, gcc HEAD text/plain 2004-02-06 16:53 1.16 KB Edit
block.tree-ssa.dwarf-2.s Bad assembly code, gcc tree-ssa text/plain 2004-02-06 16:53 1.17 KB Edit
scope.c Source code for a test case text/plain 2004-02-06 17:49 130 bytes Edit
scope.HEAD.dwarf-2.s Good assembly code, gcc HEAD application/octet-stream 2004-02-06 17:50 1.00 KB Edit
scope.tree-ssa.dwarf-2.s Bad assembly code, gcc tree-ssa application/octet-stream 2004-02-06 17:50 1.01 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 14049 depends on: Show dependency tree
Show dependency graph
Bug 14049 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2004-04-18 13:46 Opened: 2004-02-06 16:38
Here is a small C++ function.

  int foobar (int x_1)
  {
    static int i_1;
    char c_1;

    marker1 ();
    c_1 = x_1;
    i_1++;

    return 0;
  }

I compile with gcc -S -gdwarf-2.

With gcc HEAD2 2004-02-01 15:37:18 UTC, the block info is fine:

  .LBB2:
  .LBB3:
    .loc 1 10 0
    call _Z7marker1v
    .loc 1 11 0
    movl 8(%ebp), %eax
    movb %al, -1(%ebp)
    .loc 1 12 0
    incl _ZZ6foobariE3i_1
    .loc 1 14 0
     movl $0, %eax
  .LBE3:
  .LBE2:
    .loc 1 15 0
    leave
    ret

With gcc tree-ssa-200206190-branch 2004-02-05 12:45:13 UTC, the call to marker1
is outside the block for the function:

    .loc 1 10 0
    call _Z7marker1v
  .LBB2:
  .LBB3:
    .loc 1 11 0
    movl 8(%ebp), %eax
    movb %al, -1(%ebp)
    .loc 1 12 0
    movl __ZZ6foobariE3i_1, %eax
    incl %eax
    movl %eax, __ZZ6foobariE3i_1
    .loc 1 14 0
    movl $0, %eax
  .LBE3:
  .LBE2:
    .loc 1 15 0
    leave
    ret

Later on, gcc emits a DW_TAG_lexical_block for LBB3/LBE3.  With gcc
tree-ssa-branch, this does not cover the call to marker1.  Here is what "readelf
-w" says:

  # gcc HEAD
  DW_TAG_subprogram foobar
  DW_TAG_formal_parameter x_1
  DW_TAG_lexical_block 0x8048340 0x8048356
  DW_TAG_variable i_1
  DW_TAG_variable c_1

  # gcc tree-ssa
  DW_TAG_subprogram foobar
  DW_TAG_formal_paramater x_1
  DW_TAG_lexical_block 0x8048345 0x804835b
  DW_TAG_variable i_1
  DW_TAG_variable c_1

So the local variables i_1 and c_1 are inside the lexical block, and the lexical
block does not cover the first statement of foobar.

So if I do this:

  (gdb) break foobar
  (gdb) run
  (gdb) info locals

Or this:

  (gdb) break marker1
  (gdb) run
  (gdb) up
  (gdb) info locals

... then gdb cannot find the locals.

------- Comment #1 From Michael Elizabeth Chastain 2004-02-06 16:53 -------
Created an attachment (id=5694) [edit]
Source code

------- Comment #2 From Michael Elizabeth Chastain 2004-02-06 16:53 -------
Created an attachment (id=5695) [edit]
Good assembly code, gcc HEAD

------- Comment #3 From Michael Elizabeth Chastain 2004-02-06 16:53 -------
Created an attachment (id=5696) [edit]
Bad assembly code, gcc tree-ssa

------- Comment #4 From Michael Elizabeth Chastain 2004-02-06 17:49 -------
Created an attachment (id=5697) [edit]
Source code for a test case

Here is another test program for the same bug (I think it's the same bug).

The guts of the test case are:

  void
  do_block_tests ()
  {
    int cb = 12;

    {
      int foo;
      foo = 123;
      {
	int foo2;
	foo2 = 123;
	{
	  int foo;
	  foo = 321;
	}
	foo2 = 0;
      }
      foo = 0;
    }

    cb = 21;
  }

With both gcc HEAD and gcc tree-ssa, the dwarf-2 info looks like:

  DW_TAG_subprogram do_block_tests
  DW_TAG_variable cb
  DW_TAG_lexical_block .LBB2 .LBE2
  DW_TAG_variable foo
  DW_TAG_lexical_block .LBB3 .LBE3
  DW_TAG_variable foo2
  DW_TAG_lexical_block .LBB4 .LBE4
  DW_TAG_variable foo

The problem is that gcc tree-ssa generates bad LBB/LBE pairs that do not
include the first assignment to the local variable.

------- Comment #5 From Michael Elizabeth Chastain 2004-02-06 17:50 -------
Created an attachment (id=5698) [edit]
Good assembly code, gcc HEAD

------- Comment #6 From Michael Elizabeth Chastain 2004-02-06 17:50 -------
Created an attachment (id=5699) [edit]
Bad assembly code, gcc tree-ssa

------- Comment #7 From Andrew Pinski 2004-04-18 13:46 -------
I can confirm this.

------- Comment #8 From Michael Elizabeth Chastain 2004-07-14 04:55 -------
This PR describes two distinct bugs.  I thought they were two manifestations of
the same bug, but I guess they are not.

The bug with block.cc has been fixed in gcc HEAD 2004-07-06 12:02:23 UTC.
The last time I noticed it was broken was with gcc HEAD 2004-06-19 07:27:UTC.

The bug with scope.c still happens with gcc HEAD 2004-07-06 12:02:23 UTC.

------- Comment #9 From Andrew Pinski 2004-07-14 04:59 -------
scope.c I think has to do with scope is removed by the time we get to RTL but I
could be wrong.

------- Comment #10 From Michael Elizabeth Chastain 2004-07-14 05:14 -------
Subject: Re:  [3.5 regression] bad debug block info, dwarf-2, c++

Would it help if I narrowed the problem with scope.c down to a
single patch?  I could do that if you need it.

------- Comment #11 From Giovanni Bajo 2004-08-27 14:48 -------
MEC, yes, if you could narrow down the problem to a single patch, we would know 
who to bug about this.

------- Comment #12 From Michael Elizabeth Chastain 2004-08-28 00:20 -------
Subject: Re:  [3.5 regression] bad debug block info, 
 dwarf-2, c++

I checked again with gcc HEAD 20040824 and the bug in scope.c has
been fixed.  The bug in block.cc is also still fixed.

The gdb test suite is happy too.  This was manifesting as regressions
in gdb.mi/mi-var-block.exp and gdb.mi/mi2-var-block.exp.

I couldn't see the fixed results in my test bed because the gdb.mi/*.exp
tests got blinded by the new warning for "incompatible implicit
declaration of built-in function".  The tests themselves just got
fixed a few days ago.

So I think this PR can go to RESOLVED/FIXED now.

I don't think it would be worth my time to chase down the patch that
caused the bug or the patch that fixed it.

------- Comment #13 From Andrew Pinski 2004-08-28 00:23 -------
so closing as fixed.

First Last Prev Next    No search results available      Search page      Enter new bug