This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
DWARF2 offset for local variables
- From: BELBACHIR Selim <selim dot belbachir at fr dot thalesgroup dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Fri, 3 May 2013 11:31:06 +0200
- Subject: DWARF2 offset for local variables
Hi,
I'm (still) working on a new gcc-4.5.2 backend for a private processor.
Today i'm concerned about the debug mode using DWARF2.
Here is my problem:
When I use GDB on a executable compiled with -g option I notice that the addresses of all my local variables are wrong.
I read gccint doc and tried to use DEBUGGER_AUTO_OFFSET(X) and DEBUGGER_ARG_OFFSET(OFFSET, X) but I noticed (thanks to printf) that they were never called for DWARF2. (I saw afterward that dwarf2out.c did not use these macros)
My stack frame is organized as follow :
Hi mem Address | |
+-------------------+ <= $SP before prologue
| |
| Reg save |
| |
+-------------------+
| |
| Locals / Temps |
| |
+-------------------+
| |
| Args Block |
| |
+-------------------+ <= $SP after prologue
Lo mem Address | |
With
#define STACK_GROWS_DOWNWARD 1
#define FRAME_POINTER_CFA_OFFSET(FNDECL) 0
#define STARTING_FRAME_OFFSET crtl->outgoing_args_size
#define FIRST_PARM_OFFSET(FUNDECL) 0
#define DWARF2_DEBUGGING_INFO
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
#define ELIMINABLE_REGS \
{{HARD_FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
{FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
{ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
}
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
(OFFSET) = my_initial_elimination_offset ((FROM), (TO))
HOST_WIDE_INT my_initial_elimination_offset (int from, int to ATTRIBUTE_UNUSED)
{
HOST_WIDE_INT offset;
switch (from)
{
case HARD_FRAME_POINTER_REGNUM:
offset = 0;
break;
case FRAME_POINTER_REGNUM:
offset = 0;
break;
case ARG_POINTER_REGNUM:
offset = my_stack_frame_size();
break;
default:
gcc_unreachable ();
}
return offset;
}
How can I express an offset for local variables in DWARF2 for GDB ?
Regards,
Selim Belbachir