I think gcc produce wrong location information of function argument.

/***** sample source sub.c ******/
int test(int first, int second)
{
        return second;
}
/********************************/
The sample source is compiled as follows.

======================================================
tan...@r48:/usr/local/te/bappl/test/$
/usr/local/te/tool/Linux-i686/bin/arm-unknown-elf-gcc -v -Wa,-v -g -c sub.c
Using built-in specs.
Target: arm-unknown-elf
Configured with:
/usr/local/te/tool/build/gnu/gcc-4.4.3-tkernel/gcc-4.4.3/configure
--prefix=/usr/local/te/tool/Linux-i686 --target=arm-unknown-elf --with-gnu-as
--with-gnu-ld --with-gmp-include=/usr/local/te/tool/Linux-i686/include-libs
--with-gmp-lib=/usr/local/te/tool/Linux-i686/lib
--with-mpfr-include=/usr/local/te/tool/Linux-i686/include-libs
--with-mpfr-lib=/usr/local/te/tool/Linux-i686/lib --enable-threads
--enable-languages=c,c++ --enable-version-specific-runtime-libs
--disable-libstdcxx-pch --disable-hosted-libstdcxx --disable-libada
Thread model: single
gcc version 4.4.3 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-g' '-c'
 /usr/local/te/tool/Linux-i686/libexec/gcc/arm-unknown-elf/4.4.3/cc1 -quiet -v
-D__USES_INITFINI__ sub.c -quiet -dumpbase sub.c -auxbase sub -g -version -o
/tmp/ccqF2DxV.s
ignoring nonexistent directory
"/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/../../../../arm-unknown-elf/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/include
 /usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/include-fixed

/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/../../../../arm-unknown-elf/sys-include
End of search list.
GNU C (GCC) version 4.4.3 (arm-unknown-elf)
        compiled by GNU C version 4.2.4 (Ubuntu 4.2.4-1ubuntu4), GMP version
4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64255
Compiler executable checksum: 20ebd17b34fa094008992b6e0117d9b5
COLLECT_GCC_OPTIONS='-v' '-g' '-c'

/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/../../../../arm-unknown-elf/bin/as
-v -v -o sub.o /tmp/ccqF2DxV.s
GNU assembler version 2.20.1 (arm-unknown-elf) using BFD version (GNU Binutils)
2.20.1.20100303
COMPILER_PATH=/usr/local/te/tool/Linux-i686/libexec/gcc/arm-unknown-elf/4.4.3/:/usr/local/te/tool/Linux-i686/libexec/gcc/arm-unknown-elf/4.4.3/:/usr/local/te/tool/Linux-i686/libexec/gcc/arm-unknown-elf/:/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/:/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/:/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/../../../../arm-unknown-elf/bin/
LIBRARY_PATH=/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/:/usr/local/te/tool/Linux-i686/lib/gcc/arm-unknown-elf/4.4.3/../../../../arm-unknown-elf/lib/
COLLECT_GCC_OPTIONS='-v' '-g' '-c'
tan...@r48:/usr/local/te/bappl/test/$ 
======================================================

The complied object file is disassembled as follows.

======================================================
/usr/local/te/tool/Linux-i686/bin/arm-unknown-elf-objdump -S sub.o

sub.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <test>:
int test(int first, int second)
{
   0:   e52db004        push    {fp}            ; (str fp, [sp, #-4]!)
   4:   e28db000        add     fp, sp, #0
   8:   e24dd008        sub     sp, sp, #8
   c:   e50b0004        str     r0, [fp, #-4]
  10:   e50b1008        str     r1, [fp, #-8]
        return second;
  14:   e51b3008        ldr     r3, [fp, #-8]
}
  18:   e1a00003        mov     r0, r3
  1c:   e28bd000        add     sp, fp, #0
  20:   e8bd0800        pop     {fp}
  24:   e12fff1e        bx      lr
======================================================

Next is .debug_info.
DW_AT_location of argument "second" is "(DW_OP_fbreg: -12)".
I think DW_OP_fbreg must be -8.
Gdb shows wrong value for the argument.
Is there a patch for this problem.
======================================================
/usr/local/te/tool/Linux-i686/bin/arm-unknown-elf-readelf --debug-dump=info
sub.o
Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x63 (32-bit)
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  4
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    < c>   DW_AT_producer    : (indirect string, offset: 0x26): GNU C 4.4.3     
    <10>   DW_AT_language    : 1        (ANSI C)
    <11>   DW_AT_name        : (indirect string, offset: 0x37): sub.c   
    <15>   DW_AT_comp_dir    : (indirect string, offset: 0xd):
/usr/local/te/bappl/test 
    <19>   DW_AT_low_pc      : 0x0      
    <1d>   DW_AT_high_pc     : 0x28     
    <21>   DW_AT_stmt_list   : 0x0      
 <1><25>: Abbrev Number: 2 (DW_TAG_subprogram)
    <26>   DW_AT_external    : 1        
    <27>   DW_AT_name        : (indirect string, offset: 0x32): test    
    <2b>   DW_AT_decl_file   : 1        
    <2c>   DW_AT_decl_line   : 1        
    <2d>   DW_AT_prototyped  : 1        
    <2e>   DW_AT_type        : <0x5f>   
    <32>   DW_AT_low_pc      : 0x0      
    <36>   DW_AT_high_pc     : 0x28     
    <3a>   DW_AT_frame_base  : 0x0      (location list)
    <3e>   DW_AT_sibling     : <0x5f>   
 <2><42>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <43>   DW_AT_name        : (indirect string, offset: 0x0): first    
    <47>   DW_AT_decl_file   : 1        
    <48>   DW_AT_decl_line   : 1        
    <49>   DW_AT_type        : <0x5f>   
    <4d>   DW_AT_location    : 2 byte block: 91 78      (DW_OP_fbreg: -8)
 <2><50>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <51>   DW_AT_name        : (indirect string, offset: 0x6): second   
    <55>   DW_AT_decl_file   : 1        
    <56>   DW_AT_decl_line   : 1        
    <57>   DW_AT_type        : <0x5f>   
    <5b>   DW_AT_location    : 2 byte block: 91 74      (DW_OP_fbreg: -12)
 <1><5f>: Abbrev Number: 4 (DW_TAG_base_type)
    <60>   DW_AT_byte_size   : 4        
    <61>   DW_AT_encoding    : 5        (signed)
    <62>   DW_AT_name        : int      
======================================================

best regards.


-- 
           Summary: Dwarf:Wrong location information of function argument
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tanaka at personal-media dot co dot jp
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf


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

Reply via email to