When viewing the values of the parameters s1, s2, c1, c2 in the following
program with gdb or trace32 debugger a value of zero is displayed. Looking at
the dwarf info it seems that DW_AT_location is wrong. On m68k short and char
parameters are pushed as 32 bit integers on the stack. The location of the
debug symbol points to the LSB of the integer. This is correct for little
endian but for big endian the location must be adjusted to point to the MSB or
MSW. The generated code works correctly.

The configuration was:
../gcc-4.3.2/configure --target=m68k-elf --prefix=/opt/gcc-4.3.2 --with-newlib
--disable-shared --with-gnu-as --with-gnu-ld --enable-languages=c,c++
--with-headers=/src/gcc-4.3.2/build-gcc/../newlib-1.16.0/newlib/libc/include
--with-arch=cf

and the command line:
m68k-elf-gcc -m528x -Wall -g -O2 -c main/chpar.c -oDebug/chpar.o 


__attribute__((noinline)) void charpar(int i1, int i2, int i3, short s1, short
s2, char c1, char c2, int i4)
{
    volatile int _i1 = i1;
    volatile int _i2 = i2;
    volatile int _i3 = i3;
    volatile short _s1 = s1;
    volatile short _s2 = s2;
    volatile char _c1 = c1;
    volatile char _c2 = c2;
    volatile int _i4 = i4;
}


int main()
{
    charpar(1,2,3,4,5,6,7,8);
}



  Compilation Unit @ offset 0x0:
   Length:        0x150 (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: 0xa): GNU C 4.3.2      
    <10>   DW_AT_language    : 1        (ANSI C)
    <11>   DW_AT_name        : (indirect string, offset: 0x30): main/chpar.c    
    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x20): /c/A/P4 
    <19>   DW_AT_low_pc      : 0x0      
    <1d>   DW_AT_high_pc     : 0x6a     
    <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: 0x28): charpar 
    <2b>   DW_AT_decl_file   : 1        
    <2c>   DW_AT_decl_line   : 3        
    <2d>   DW_AT_prototyped  : 1        
    <2e>   DW_AT_low_pc      : 0x0      
    <32>   DW_AT_high_pc     : 0x38     
    <36>   DW_AT_frame_base  : 0x0      (location list)
    <3a>   DW_AT_sibling     : <0x117>  
 <2><3e>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <3f>   DW_AT_name        : i1       
    <42>   DW_AT_decl_file   : 1        
    <43>   DW_AT_decl_line   : 2        
    <44>   DW_AT_type        : <0x117>  
    <48>   DW_AT_location    : 2 byte block: 91 0       (DW_OP_fbreg: 0)
 <2><4b>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <4c>   DW_AT_name        : i2       
    <4f>   DW_AT_decl_file   : 1        
    <50>   DW_AT_decl_line   : 2        
    <51>   DW_AT_type        : <0x117>  
    <55>   DW_AT_location    : 2 byte block: 91 4       (DW_OP_fbreg: 4)
 <2><58>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <59>   DW_AT_name        : i3       
    <5c>   DW_AT_decl_file   : 1        
    <5d>   DW_AT_decl_line   : 2        
    <5e>   DW_AT_type        : <0x117>  
    <62>   DW_AT_location    : 2 byte block: 91 8       (DW_OP_fbreg: 8)
 <2><65>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <66>   DW_AT_name        : s1       
    <69>   DW_AT_decl_file   : 1        
    <6a>   DW_AT_decl_line   : 2        
    <6b>   DW_AT_type        : <0x11e>  
    <6f>   DW_AT_location    : 2 byte block: 91 c       (DW_OP_fbreg: 12)
 <2><72>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <73>   DW_AT_name        : s2       
    <76>   DW_AT_decl_file   : 1        
    <77>   DW_AT_decl_line   : 2        
    <78>   DW_AT_type        : <0x11e>  
    <7c>   DW_AT_location    : 2 byte block: 91 10      (DW_OP_fbreg: 16)
 <2><7f>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <80>   DW_AT_name        : c1       
    <83>   DW_AT_decl_file   : 1        
    <84>   DW_AT_decl_line   : 2        
    <85>   DW_AT_type        : <0x125>  
    <89>   DW_AT_location    : 2 byte block: 91 14      (DW_OP_fbreg: 20)
 <2><8c>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <8d>   DW_AT_name        : c2       
    <90>   DW_AT_decl_file   : 1        
    <91>   DW_AT_decl_line   : 2        
    <92>   DW_AT_type        : <0x125>  
    <96>   DW_AT_location    : 2 byte block: 91 18      (DW_OP_fbreg: 24)
 <2><99>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <9a>   DW_AT_name        : i4       
    <9d>   DW_AT_decl_file   : 1        
    <9e>   DW_AT_decl_line   : 2        
    <9f>   DW_AT_type        : <0x117>  
    <a3>   DW_AT_location    : 2 byte block: 91 1c      (DW_OP_fbreg: 28)
 <2><a6>: Abbrev Number: 4 (DW_TAG_variable)
    <a7>   DW_AT_name        : _i1      
    <ab>   DW_AT_decl_file   : 1        
    <ac>   DW_AT_decl_line   : 4        
    <ad>   DW_AT_type        : <0x12c>  
    <b1>   DW_AT_location    : 2 byte block: 7e 76      (DW_OP_breg14: -10)
 <2><b4>: Abbrev Number: 4 (DW_TAG_variable)
    <b5>   DW_AT_name        : _i2      
    <b9>   DW_AT_decl_file   : 1        
    <ba>   DW_AT_decl_line   : 5        
    <bb>   DW_AT_type        : <0x12c>  
    <bf>   DW_AT_location    : 2 byte block: 7e 72      (DW_OP_breg14: -14)
 <2><c2>: Abbrev Number: 4 (DW_TAG_variable)
    <c3>   DW_AT_name        : _i3      
    <c7>   DW_AT_decl_file   : 1        
    <c8>   DW_AT_decl_line   : 6        
    <c9>   DW_AT_type        : <0x12c>  
    <cd>   DW_AT_location    : 2 byte block: 7e 6e      (DW_OP_breg14: -18)
 <2><d0>: Abbrev Number: 4 (DW_TAG_variable)
    <d1>   DW_AT_name        : _s1      
    <d5>   DW_AT_decl_file   : 1        
    <d6>   DW_AT_decl_line   : 7        
    <d7>   DW_AT_type        : <0x131>  
    <db>   DW_AT_location    : 2 byte block: 7e 7c      (DW_OP_breg14: -4)
 <2><de>: Abbrev Number: 4 (DW_TAG_variable)
    <df>   DW_AT_name        : _s2      
    <e3>   DW_AT_decl_file   : 1        
    <e4>   DW_AT_decl_line   : 8        
    <e5>   DW_AT_type        : <0x131>  
    <e9>   DW_AT_location    : 2 byte block: 7e 7a      (DW_OP_breg14: -6)
 <2><ec>: Abbrev Number: 4 (DW_TAG_variable)
    <ed>   DW_AT_name        : _c1      
    <f1>   DW_AT_decl_file   : 1        
    <f2>   DW_AT_decl_line   : 9        
    <f3>   DW_AT_type        : <0x136>  
    <f7>   DW_AT_location    : 2 byte block: 7e 7f      (DW_OP_breg14: -1)
 <2><fa>: Abbrev Number: 4 (DW_TAG_variable)
    <fb>   DW_AT_name        : _c2      
    <ff>   DW_AT_decl_file   : 1        
    <100>   DW_AT_decl_line   : 10      
    <101>   DW_AT_type        : <0x136> 
    <105>   DW_AT_location    : 2 byte block: 7e 7e     (DW_OP_breg14: -2)
 <2><108>: Abbrev Number: 4 (DW_TAG_variable)
    <109>   DW_AT_name        : _i4     
    <10d>   DW_AT_decl_file   : 1       
    <10e>   DW_AT_decl_line   : 11      
    <10f>   DW_AT_type        : <0x12c> 
    <113>   DW_AT_location    : 2 byte block: 7e 6a     (DW_OP_breg14: -22)
 <1><117>: Abbrev Number: 5 (DW_TAG_base_type)
    <118>   DW_AT_byte_size   : 4       
    <119>   DW_AT_encoding    : 5       (signed)
    <11a>   DW_AT_name        : int     
 <1><11e>: Abbrev Number: 6 (DW_TAG_base_type)
    <11f>   DW_AT_byte_size   : 2       
    <120>   DW_AT_encoding    : 5       (signed)
    <121>   DW_AT_name        : (indirect string, offset: 0x0): short int       
 <1><125>: Abbrev Number: 6 (DW_TAG_base_type)
    <126>   DW_AT_byte_size   : 1       
    <127>   DW_AT_encoding    : 6       (signed char)
    <128>   DW_AT_name        : (indirect string, offset: 0x1b): char   
 <1><12c>: Abbrev Number: 7 (DW_TAG_volatile_type)
    <12d>   DW_AT_type        : <0x117> 
 <1><131>: Abbrev Number: 7 (DW_TAG_volatile_type)
    <132>   DW_AT_type        : <0x11e> 
 <1><136>: Abbrev Number: 7 (DW_TAG_volatile_type)
    <137>   DW_AT_type        : <0x125> 
 <1><13b>: Abbrev Number: 8 (DW_TAG_subprogram)
    <13c>   DW_AT_external    : 1       
    <13d>   DW_AT_name        : (indirect string, offset: 0x16): test   
    <141>   DW_AT_decl_file   : 1       
    <142>   DW_AT_decl_line   : 16      
    <143>   DW_AT_type        : <0x117> 
    <147>   DW_AT_low_pc      : 0x38    
    <14b>   DW_AT_high_pc     : 0x6a    
    <14f>   DW_AT_frame_base  : 0x20    (location list)


-- 
           Summary: Wrong debug information for big endian function
                    parameters
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pint at tlink dot de
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: m68k-unknown-elf


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

Reply via email to