Bug 172652

Summary: bad dwarf location info for multi-register variables
Product: [Fedora] Fedora Reporter: Roland McGrath <roland>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: fche
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: 4.0.2-4 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-11-10 07:37:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
C code for test case none

Description Roland McGrath 2005-11-07 22:13:02 UTC
Description of problem:

Looks like wrong register numbers in location expressions for long long variable
(parameter).  Looking at multiple_reg_loc_descriptor, it seems like maybe it
assumes that contiguous GCC register numbers corresponds to contiguous DWARF
register numbers, which is not always so.

Version-Release number of selected component (if applicable):

gcc-4.0.2-3 used for cited details in this case.
Note that FC4's gcc-4.0.1-4.fc4 has the same problems (and more).

How reproducible:
100%

Steps to Reproduce:
1. gcc -g -c -mregparm -O9 ll-debuginfo-loser.c
2. objdump -rd ll-debuginfo-loser.o; eu-readelf --debug-dump={info,loc}
ll-debug-loser.o
3. Compare.
  
Actual results:

Disassembly of section .text:

00000000 <seek>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   56                      push   %esi
   4:   53                      push   %ebx
   5:   89 d3                   mov    %edx,%ebx
   7:   89 ce                   mov    %ecx,%esi
   9:   a3 00 00 00 00          mov    %eax,0x0
                        a: R_386_32     to_ptr
   e:   89 15 00 00 00 00       mov    %edx,0x0
                        10: R_386_32    to_ll
  14:   89 0d 04 00 00 00       mov    %ecx,0x4
                        16: R_386_32    to_ll
  1a:   8b 45 08                mov    0x8(%ebp),%eax
  1d:   a3 00 00 00 00          mov    %eax,0x0
                        1e: R_386_32    to_x
  22:   50                      push   %eax
  23:   51                      push   %ecx
  24:   52                      push   %edx
  25:   68 00 00 00 00          push   $0x0
                        26: R_386_32    .rodata.str1.1
  2a:   e8 fc ff ff ff          call   2b <seek+0x2b>
                        2b: R_386_PC32  printf
  2f:   01 db                   add    %ebx,%ebx
  31:   11 f6                   adc    %esi,%esi
  33:   89 d8                   mov    %ebx,%eax
  35:   89 f2                   mov    %esi,%edx
  37:   8d 65 f8                lea    0xfffffff8(%ebp),%esp
  3a:   5b                      pop    %ebx
  3b:   5e                      pop    %esi
  3c:   c9                      leave
  3d:   c3                      ret

 [     b]  compile_unit
           stmt_list            0
           high_pc              0x0000003e
           low_pc               0000000000
           producer             "GNU C 4.0.2 20051007 (Red Hat 4.0.2-3)"
           language             ISO C89 (1)
           name                
"/net/ma/home/roland/redhat/tmp/ll-debuginfo-loser.c"
 [    21]    subprogram
             sibling              [    6e]
             external
             name                 "seek"
             decl_file            1
             decl_line            7
             prototyped
             type                 [    6e]
             low_pc               0000000000
             high_pc              0x0000003e
             frame_base           location list [     0]
 [    3e]      structure_type
               name                 "foo"
               declaration
 [    44]      formal_parameter
               name                 "ptr"
               decl_file            1
               decl_line            6
               type                 [    75]
               location             location list [    2c]
 [    53]      formal_parameter
               name                 "ll"
               decl_file            1
               decl_line            6
               type                 [    6e]
               location             location list [    3f]
 [    61]      formal_parameter
               name                 "x"
               decl_file            1
               decl_line            6
               type                 [    7b]
               location             2 byte block
                [   0] fbreg 0
 [    6e]    base_type
             name                 "long long int"
             byte_size            8
             encoding             signed (5)
 [    75]    pointer_type
             byte_size            4
             type                 [    3e]
 [    7b]    base_type
             name                 "int"
             byte_size            4
             encoding             signed (5)
 [    82]    variable
             name                 "to_ptr"
             decl_file            1
             decl_line            1
             type                 [    75]
             external
             declaration
 [    8f]    variable
             name                 "to_ll"
             decl_file            1
             decl_line            2
             type                 [    6e]
             external
             declaration
 [    9c]    variable
             name                 "to_x"
             decl_file            1
             decl_line            3
             type                 [    7b]
             external
             declaration

DWARF section '.debug_loc' at offset 0x240:
 [     0]  0000000000..0x00000001 [   0] breg4 4
           0x00000001..0x00000003 [   0] breg4 8
           0x00000003..0x0000003e [   0] breg5 8
 [    2c]  0000000000..0x0000001d [   0] reg0
 [    3f]  0000000000..0x00000007 [   0] reg2
                                  [   1] piece 4
                                  [   3] reg3
                                  [   4] piece 4
           0x00000007..0x0000002f [   0] reg3
                                  [   1] piece 4
                                  [   3] reg1
                                  [   4] piece 4
           0x0000002f..0x0000003b [   0] reg3
                                  [   1] piece 4
                                  [   3] reg4
                                  [   4] piece 4

Expected results:

From 0..7, {ecx,edx} reg1 reg2
From 7..2f, {ecx,ebx} reg1 reg3
From 2f..3b, {esi,ebx} reg6 reg3

or something like that.  Obviously reg4 (%esp) should never be involved.


Additional info:

Similar problems in 3.4.

Comment 1 Roland McGrath 2005-11-07 22:13:03 UTC
Created attachment 120795 [details]
C code for test case

Comment 3 Jakub Jelinek 2005-11-10 07:37:57 UTC
Should be fixed in gcc-4.0.2-4.