public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/19192] New: Current development gcc generates incorrect line info for example code
@ 2004-12-29 17:42 gcc-bugzilla at gcc dot gnu dot org
  2004-12-29 17:56 ` [Bug debug/19192] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-12-29 17:42 UTC (permalink / raw)
  To: gcc-bugs



For the supplied example, the current development gcc generates
incorrect line number information for one instruction from the inlined
subroutine.  The Fedora Core 3 gcc, which identifies itself as "gcc
version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)", generates correct line
information.

Environment:
System: Linux toadfish.ninemoons.com 2.6.9-1.681_FC3.stk16 #1 Mon Nov 22 16:44:32 EST 2004 i686 i686 i386 GNU/Linux
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /src/sourceware/gcc/gcc/configure -v --prefix=/opt/local/sourceware --with-gcc-version-trigger=/src/sourceware/gcc/gcc/gcc/version.c --enable-languages=c,c++

How-To-Repeat:

For the follow code:

  /*  1 */  int add2 (int a, int b)
  /*  2 */  {
  /*  3 */    return (a + b);
  /*  4 */  }
  /*  5 */  
  /*  6 */  inline int add3 (int a, int b, int c)
  /*  7 */  {
  /*  8 */    return (a + add2 (b , c));
  /*  9 */  }
  /* 10 */  
  /* 11 */  main ()
  /* 12 */  {
  /* 13 */    printf ("%d\n", add3 (2, 3, 4));
  /* 14 */  }

Run:

  gcc -g -O2 --save-temps -o t t.c
  readelf --debug-dump t >t.dwarf
  objdump --disassemble t >t.dis

There relevant line table entries from t.dwarf are:

  Special opcode 36: advance Address by 2 to 0x80483a0 and Line by 3 to 12
  Special opcode 15: advance Address by 1 to 0x80483a1 and Line by -4 to 8
  Special opcode 79: advance Address by 5 to 0x80483a6 and Line by 4 to 12
  Special opcode 75: advance Address by 5 to 0x80483ab and Line by 0 to 12
  Special opcode 85: advance Address by 6 to 0x80483b1 and Line by -4 to 8
  Special opcode 234: advance Address by 16 to 0x80483c1 and Line by 5 to 13
  Advance PC by constant 17 to 0x80483d2
  Special opcode 34: advance Address by 2 to 0x80483d4 and Line by 1 to 14
  Advance PC by 2 to 80483d6

I've annotated the disassembly of main() with the line numbers given by
the above entries:

    12      080483a0 <main>:
    12       80483a0:       55                      push   %ebp
     8       80483a1:       b8 04 00 00 00          mov    $0x4,%eax
    12       80483a6:       89 e5                   mov    %esp,%ebp
    12       80483a8:       83 ec 08                sub    $0x8,%esp
    12       80483ab:       83 e4 f0                and    $0xfffffff0,%esp
    12       80483ae:       83 ec 10                sub    $0x10,%esp
     8       80483b1:       89 44 24 04             mov    %eax,0x4(%esp)
     8       80483b5:       c7 04 24 03 00 00 00    movl   $0x3,(%esp)
     8       80483bc:       e8 af ff ff ff          call   8048370 <add2>
    13       80483c1:       c7 04 24 c8 84 04 08    movl   $0x80484c8,(%esp)
 ** 13       80483c8:       83 c0 02                add    $0x2,%eax
    13       80483cb:       89 44 24 04             mov    %eax,0x4(%esp)
    13       80483cf:       e8 dc fe ff ff          call   80482b0 <printf@plt>
    14       80483d4:       c9                      leave  
    14       80483d5:       c3                      ret    

The "add $0x2,%eax" instruction, marked with '**', is supposed to be at
line 8, not line 13.      

If you go through the same exercise with the Fedora Core 3 compiler, it does
correctly identify this instruction as being at line 8.

-- 
           Summary: Current development gcc generates incorrect line info
                    for example code
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fnf at specifixinc dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/19192] [4.0 Regression] Current development gcc generates incorrect line info for example code
  2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
@ 2004-12-29 17:56 ` pinskia at gcc dot gnu dot org
  2005-01-02  6:08 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-29 17:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-29 17:56 -------
This is caused by ter.

Confirmed, easier way to find this out is to look at the tree dump with -lineno as an option.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |wrong-debug
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-29 17:56:33
               date|                            |
            Summary|Current development gcc     |[4.0 Regression] Current
                   |generates incorrect line    |development gcc generates
                   |info for example code       |incorrect line info for
                   |                            |example code
   Target Milestone|---                         |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/19192] [4.0 Regression] Current development gcc generates incorrect line info for example code
  2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
  2004-12-29 17:56 ` [Bug debug/19192] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-01-02  6:08 ` pinskia at gcc dot gnu dot org
  2005-01-12 17:47 ` amacleod at redhat dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-02  6:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-02 06:08 -------
With TER:
  [t.c : 8] D.1144 = [t.c : 8] add2 (3, 4);
  [t.c : 13] printf (&"%d\n"[0], D.1144 + 2) [tail call];
  [t.c : 14] return;
Without:
  [t.c : 8] D.1144 = [t.c : 8] add2 (3, 4);
  [t.c : 8] D.1124 = D.1144 + 2;
  [t.c : 13] printf (&"%d\n"[0], D.1124) [tail call];
  [t.c : 14] return;

In a way we cannot say the addition is on line 8 because we already optimizated before.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/19192] [4.0 Regression] Current development gcc generates incorrect line info for example code
  2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
  2004-12-29 17:56 ` [Bug debug/19192] [4.0 Regression] " pinskia at gcc dot gnu dot org
  2005-01-02  6:08 ` pinskia at gcc dot gnu dot org
@ 2005-01-12 17:47 ` amacleod at redhat dot com
  2005-01-13 20:56 ` fnf at specifixinc dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2005-01-12 17:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amacleod at redhat dot com  2005-01-12 17:46 -------
Created an attachment (id=7940)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7940&action=view)
proposed patch

Give this a try. I havent checked it in, Im running it through the testsuites.
I'm unlikely to be able to check it in until next week. This is likely to
change the debug info quite a bit, but it should be more detailed. Let me know
if you think it is OK, and if not, what it is doing wrong.

for the specified testcase I get:
  [a.c : 8] D.1150 = [a.c : 8] add2 (3, 4);
  [a.c : 13] printf (&"%d\n"[0], [a.c : 8] D.1150 + 2) [tail call];
  [a.c : 14] return;

so that looks reasonable. something artificial and slightly more complex gives
me:
    x = a + b;
    y = x * 3;
    z = y << 2 + x;
    x = z * 10;
    printf ("%d\n", x * 44);
  [d.c : 6] x = a + b;
  [d.c : 10] printf (&"%d\n"[0], ([d.c : 8] [d.c : 7] x * 3 << x + 2) * 440)
[tail call];
  [d.c : 13] return;

which looks like it ought to be about right, but is a little tricky to read :-)


anyway, give it a shot and let me know if you think this is better.

Andrew

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |amacleod at redhat dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/19192] [4.0 Regression] Current development gcc generates incorrect line info for example code
  2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-01-12 17:47 ` amacleod at redhat dot com
@ 2005-01-13 20:56 ` fnf at specifixinc dot com
  2005-04-21  4:58 ` [Bug debug/19192] [4.0/4.1 Regression] Current development gcc generates inaccurate " mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fnf at specifixinc dot com @ 2005-01-13 20:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fnf at specifixinc dot com  2005-01-13 20:56 -------
Subject: Re:  [4.0 Regression] Current development gcc generates incorrect line info for example code

On Wednesday 12 January 2005 11:46, amacleod at redhat dot com wrote:
> Give this a try.

Unfortunately, for my original example, this seems to have made things worse.
The differences are:

  $ diff -w ../old/z.m ../new/z.m
  6,8c6,7
  <   Special opcode 234: advance Address by 16 to 0x80483c1 and Line by 5 to 13
  <   Advance PC by constant 17 to 0x80483d2
  <   Special opcode 34: advance Address by 2 to 0x80483d4 and Line by 1 to 14
  ---
  >   Advance PC by 35 to 80483d4
  >   Special opcode 11: advance Address by 0 to 0x80483d4 and Line by 6 to 14
  20,23c19,22
  < 13     80483c1: c7 04 24 c8 84 04 08    movl   $0x80484c8,(%esp)
  < 13     80483c8: 83 c0 02                add    $0x2,%eax
  < 13     80483cb: 89 44 24 04             mov    %eax,0x4(%esp)
  < 13     80483cf: e8 dc fe ff ff          call   80482b0 <printf@plt>
  ---
  >  8     80483c1:  c7 04 24 c8 84 04 08    movl   $0x80484c8,(%esp)
  >  8     80483c8:  83 c0 02                add    $0x2,%eax
  >  8     80483cb:  89 44 24 04             mov    %eax,0x4(%esp)
  >  8     80483cf:  e8 dc fe ff ff          call   80482b0 <printf@plt>
  
I.E. gcc now associates the code to print the results with line 8 instead
of line 13.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/19192] [4.0/4.1 Regression] Current development gcc generates inaccurate line info for example code
  2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-01-13 20:56 ` fnf at specifixinc dot com
@ 2005-04-21  4:58 ` mmitchel at gcc dot gnu dot org
  2005-07-08  1:35 ` mmitchel at gcc dot gnu dot org
  2005-09-27 16:19 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-04-21  4:58 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.0                       |4.0.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/19192] [4.0/4.1 Regression] Current development gcc generates inaccurate line info for example code
  2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-04-21  4:58 ` [Bug debug/19192] [4.0/4.1 Regression] Current development gcc generates inaccurate " mmitchel at gcc dot gnu dot org
@ 2005-07-08  1:35 ` mmitchel at gcc dot gnu dot org
  2005-09-27 16:19 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-07-08  1:35 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.1                       |4.0.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/19192] [4.0/4.1 Regression] Current development gcc generates inaccurate line info for example code
  2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-07-08  1:35 ` mmitchel at gcc dot gnu dot org
@ 2005-09-27 16:19 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:19 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19192


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-27 16:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-29 17:42 [Bug debug/19192] New: Current development gcc generates incorrect line info for example code gcc-bugzilla at gcc dot gnu dot org
2004-12-29 17:56 ` [Bug debug/19192] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-01-02  6:08 ` pinskia at gcc dot gnu dot org
2005-01-12 17:47 ` amacleod at redhat dot com
2005-01-13 20:56 ` fnf at specifixinc dot com
2005-04-21  4:58 ` [Bug debug/19192] [4.0/4.1 Regression] Current development gcc generates inaccurate " mmitchel at gcc dot gnu dot org
2005-07-08  1:35 ` mmitchel at gcc dot gnu dot org
2005-09-27 16:19 ` mmitchel at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).