Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mitar <mmitar@gmail.com>
To: tromey@redhat.com
Cc: gdb@sourceware.org
Subject: Re: Custom call frame description
Date: Mon, 25 Jan 2010 09:33:00 -0000	[thread overview]
Message-ID: <f63c4b2d1001250133u2b4f8b3fn608ebaf8a95daf07@mail.gmail.com> (raw)
In-Reply-To: <m3fx5yt7kc.fsf@fleche.redhat.com>

Hi!

On Fri, Jan 22, 2010 at 5:42 PM, Tom Tromey <tromey@redhat.com> wrote:
> One thing you can do is run gcc -S on simple programs and look at the
> resulting assembly.  Adding -dA can help clarify things, too.

Oh, thanks. I was looking at -S but it was cryptic without -dA. And I
have some success now.

But I am not sure to what I have to set canonical frame address? To
top address of the call frame or to the bottom? Because otherwise I
use top of the frame (where fp register is pointing) in my compiler
from which I calculate access to different elements of the frame.
While my sp is pointing at the bottom of the frame and I do not really
use it (except in the next function call). Somehow I got a feeling
that I should follow sp with canonical frame address but this is
somehow strange as I am using fp for my frame access. Also I
incrementally lower sp in my function prelude - should I change
canonical frame address for every instruction then? Or should I
immediately offset it for complete frame size?

Stack level 0, frame at 0xbef66c34: << should this point to top or
bottom of the frame?
 pc = 0x876c in _insert (prg.s:74); saved pc 0x8a48
 called by frame at 0xbef66c84 << same here, should this be top or
bottom of the frame?
 source language asm.
 Arglist at 0xbef66c34, args:
 Locals at 0xbef66c34, Previous frame's sp is 0xbef66c34 << this is
not really in sync with called frame address?

Currently I set CFA to sp register in initial commands and then when
in prolog, when I store current sp to fp, I switch CFA to fp register.
But at that moment things break and I get:

Stack level 0, frame at 0xbef66c34:
 pc = 0x8774 in _insert (prg.s:77); saved pc 0x8a48
 called by frame at 0xbef66c34
 source language asm.
 Arglist at 0xbef66c34, args:
 Locals at 0xbef66c34, Previous frame's sp is 0xbef66c34

My prolog looks like:

_insert:
    str fp, [sp, #-8]
    mov fp, sp
.L_insert_fp_defined:
    sub sp, sp, #12
    stmdb sp!, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r12}
    sub sp, sp, #12
    str lr, [fp, #-12]
.L_insert_lr_stored:

My epilog:

    str r12, [fp]
    add sp, sp, #60
    ldmdb sp, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r12}
    mov sp, fp
.L_insert_sp_defined:
    ldr fp, [sp, #-8]
    ldr pc, [sp, #-12]
.L_insert_end:

And I have:

.text
.section .debug_frame,"",%progbits
.align 2
.Lframe:
    .4byte .LECIE-.LSCIE @ Length of Common Information Entry
.LSCIE:
    .4byte 0xffffffff @ CIE Identifier Tag
    .byte 0x1 @ CIE Version
    .ascii "^@" @ CIE Augmentation
    .uleb128 0x1 @ CIE Code Alignment Factor
    .sleb128 -1 @ CIE Data Alignment Factor
    .byte 0x10 @ CIE RA Column
    .byte 0x9 @ DW_CFA_register
    .uleb128 0x10
    .uleb128 0xe
    .byte 0xc @ DW_CFA_def_cfa
    .uleb128 0xd
    .uleb128 0x0
.align 2
.LECIE:
.LSFDE_insert:
    .4byte .LEFDE_insert-.LASFDE_insert @ FDE Length
.LASFDE_insert:
    .4byte .Lframe @ FDE CIE offset
    .4byte _insert @ FDE initial location
    .4byte .L_insert_end-_insert @ FDE address range
    .byte 0x4 @ DW_CFA_advance_loc4
    .4byte .L_insert_fp_defined-_insert
    .byte 0xd @ DW_CFA_def_cfa_register
    .uleb128 0xb
    .byte 0x4 @ DW_CFA_advance_loc4
    .4byte .L_insert_lr_stored-.L_insert_fp_defined
    .byte 0x5 @ DW_CFA_offset_extended
    .uleb128 0x10
    .uleb128 12
    .byte 0x4 @ DW_CFA_advance_loc4
    .4byte .L_insert_sp_defined-.L_insert_lr_stored
    .byte 0xd @ DW_CFA_def_cfa_register
    .uleb128 0xd
.align 2
.LEFDE_insert:

How can I specify where are function arguments? And locals?


Mitar


  reply	other threads:[~2010-01-25  9:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20 20:49 Mitar
2010-01-22 16:42 ` Tom Tromey
2010-01-25  9:33   ` Mitar [this message]
2010-01-26  8:31     ` Mitar
2010-01-27 15:23       ` Mitar
2010-01-27 15:58         ` Tom Tromey
2010-01-27 19:33           ` Mitar
2010-01-27 19:39             ` Tom Tromey
2010-01-27 19:39             ` Daniel Jacobowitz
2010-01-27 21:07               ` Mitar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f63c4b2d1001250133u2b4f8b3fn608ebaf8a95daf07@mail.gmail.com \
    --to=mmitar@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox