Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 14048
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Richard Henderson <rth@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
class2.cc C++ source file application/octet-stream 2004-02-06 14:45 766 bytes Edit
class2.HEAD.dwarf-2.s Generated code with gcc HEAD, good application/octet-stream 2004-02-06 14:45 3.30 KB Edit
class2.tree-ssa.dwarf-2.s Generated code with gcc tree-ssa, bad application/octet-stream 2004-02-06 14:46 3.22 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

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

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2004-02-27 11:58 Opened: 2004-02-06 14:44
I have a simple C++ program with some instance variables:

  int main (void)
  {
    A alpha, *aap, *abp;
    B beta, *bbp;

    ...
    return 0;
  }

The command line is: gcc -S -gdwarf-2

The "return 0" line is on line 65.

With gcc HEAD 2004-02-01 15:37:18 UTC, the generated code for "return 0" looks
like this:

  .LBB10:
    .loc 1 65 0
    leal -56(%ebp), %eax
    movl %eax, (%esp)
    call B::~B [in-charge]()
    leal -24(%ebp), %eax
    movl %eax, (%esp)
    call A::~A [in-charge]()
  .LBE10:
    movl $0, %eax

Simple and good.  I can set a breakpoint on line 65, the "return 0" line, and
look at the values of A and B before they are destroyed.

With gcc tree-ssa-20020619-branch 2004-02-05 12:45:13 UTC, the generated code
looks like this:

    movl $0, %ebx
    .loc 1 56 0
    leal -56(%ebp), %eax
    movl %eax, (%esp)
    call B::~B [in-charge]()
    .loc 1 55 0
    leal -24(%ebp), %eax
    movl %eax, (%esp)
    call A::~A [in-charge]()
    movl %ebx, %eax
  .LBE2:
    .loc 1 66 0
    movl -4(%ebp), %ebx
    leave
    ret

The "return 0" line has had its code split up into two pieces, "movl 0, %ebx"
and "movl %ebx, %eax", which are separated.

There is no more .loc 1 65 at all.  Instead, there are some .loc lines for the
destructor calls which reference the lines that *declared* A and B.

When I try to break on line 65 and print "A" and "B", gdb selects the .loc for
line 66, which comes after the destructors, so the local instance variables have
been destroyed.

This happens with both dwarf-2 and stabs+.

There needs to be a ".loc 1 65" for the "return 0;" line, and it needs to occur
before the destructors.

------- Comment #1 From Michael Elizabeth Chastain 2004-02-06 14:45 -------
Created an attachment (id=5691) [edit]
C++ source file

------- Comment #2 From Michael Elizabeth Chastain 2004-02-06 14:45 -------
Created an attachment (id=5692) [edit]
Generated code with gcc HEAD, good

------- Comment #3 From Michael Elizabeth Chastain 2004-02-06 14:46 -------
Created an attachment (id=5693) [edit]
Generated code with gcc tree-ssa, bad

------- Comment #4 From Richard Henderson 2004-02-27 11:58 -------
I can fix this for some, but not all, instances.  For

   A a;
   if (p)
      return 0;
   if (q)
      return 1;

there are two return statements.  At -O0, there will only be one instance of the
destructor for "a".  What line should it be indicated for?  It can't have line
numbers for both return statements.  Seems to me that the declaration line for "a"
is as good as any...

At -O2 we will ususally copy the destructor calls.  However, if the destructor
gets inlined, and is large enough, then we won't duplicate it there either.

------- Comment #5 From Richard Henderson 2004-06-11 21:39 -------
Fixed with recent return statement changes.

------- Comment #6 From Michael Elizabeth Chastain 2004-06-14 18:49 -------
Subject: Re:  [3.5 regression] bad debug line numbers near "return" statement,
c++

It works for me.  Thanks!

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug