6 msgProblems with compiling svn trunk
1 msgsome errors while compiling gcc-4.2.1 on windows
8 msgtrimming excess errors from -Werror

Doubt regarding dwarf info generated for var_ar...
\ Rohit Arul Raj (16 May 2007)

2 msg4.2.0 build/test results
1 msgGCC 4.2 branch open for regression fixes
9 msgGCC's trunk, it is necessary to improve the tim...
2 msgis gcc 4.2.0 released?
2 msgCode Samples
2 msgStepping down as CLI back-end maintainer
2 msgdumping profiling info in gmon.out file format
2 msgc-common.c line 5179: isn't this a nop?
1 msgMainline doesn't bootstrap on i386-linux
2 msgRegressions on latest trunk
3 msgABOUT_NLS
1 msggcc-4.1-20070514 is now available
1 msgredundancy in gimplify_compound_lval?
30 msgA reload inheritance bug
2 msgFYI: gcc/print-rtl.c (print_rtx) does not build...
7 msgmainline fails to build?
Subject:Doubt regarding dwarf info generated for var_args function
Group:Gcc
From:Rohit Arul Raj
Date:16 May 2007


Hi all,

I need some clarification regarding the debug information generated
for var_args function. I am working with GCC 4.1.1. In my target,
var_args registers are saved in stack frame during function prologue
(similiar to fr30).

### sample program ###

#include <stdio.h>

int fun(const char *temp,...)
{
return 9;
}

int main()
{
fun("Hello World",1,2);
return 0;

}

##### objdump #######

SP - stack pointer
FP - Frame Pointer

00000294 <_fun>:
294: STR D3,-(SP)
296: STR D2,-(SP) // value '2'
298: STR D1,-(SP) // value '1'
29a: STR D0,-(SP) // value representing variable "temp",
address of Hello World
29c: STR FP,-(SP)
29e: MOV SP,FP
2a0: MOV 0x9,D0
2a2: LDR (SP)+,FP
2a4: ADD 0x10,SP
2a6: RTS

##### readelf output #######

<1><102>: Abbrev Number: 6 (DW_TAG_subprogram)
DW_AT_sibling : <130>
DW_AT_external : 1
DW_AT_name : fun
DW_AT_decl_file : 10
DW_AT_decl_line : 4
DW_AT_prototyped : 1
DW_AT_type : <52>
DW_AT_low_pc : 0x294
DW_AT_high_pc : 0x2a8
DW_AT_frame_base : 0 (location list)

<2><11f>: Abbrev Number: 7 (DW_TAG_formal_parameter)
DW_AT_name : temp
DW_AT_decl_file : 10
DW_AT_decl_line : 3
DW_AT_type : <b8>
DW_AT_location : 2 byte block: 91 0 (DW_OP_fbreg: 0)

Contents of the .debug_loc section:

Offset Begin End Expression
00000000 00000294 00000296 (DW_OP_regSP)
00000000 00000296 00000298 (DW_OP_bregSP: 4)
00000000 00000298 0000029a (DW_OP_bregSP: 8)
00000000 0000029a 0000029c (DW_OP_bregSP: 12)
00000000 0000029c 0000029e (DW_OP_bregSP: 16)
00000000 0000029e 000002a0 (DW_OP_bregSP: 20)
00000000 000002a0 000002a8 (DW_OP_bregFP: 20)
00000000 <End of list>

From the debug info generated, frame base for "fun" starts from 0x00.
The corresponding location expression for "temp" in address range
0x294 -0x296 is SP (Stack Pointer). But at that instant, it is not
correct.

The value of "temp" is in register D0 which gets stored in stack only
when instruction at 0x29a is executed. Until then this value is
undefined. Is it right?

Is this the right behavior or am i missing something?

Regards,
Rohit


© 2004-2008 readlist.com