From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24338 invoked by alias); 25 Jan 2010 09:33:48 -0000 Received: (qmail 24328 invoked by uid 22791); 25 Jan 2010 09:33:48 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.152) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 25 Jan 2010 09:33:43 +0000 Received: by fg-out-1718.google.com with SMTP id 22so248592fge.12 for ; Mon, 25 Jan 2010 01:33:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.239.185.204 with SMTP id d12mr717197hbh.83.1264412020246; Mon, 25 Jan 2010 01:33:40 -0800 (PST) In-Reply-To: References: Date: Mon, 25 Jan 2010 09:33:00 -0000 Message-ID: Subject: Re: Custom call frame description From: Mitar To: tromey@redhat.com Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00188.txt.bz2 Hi! On Fri, Jan 22, 2010 at 5:42 PM, Tom Tromey wrote: > One thing you can do is run gcc -S on simple programs and look at the > resulting assembly. =C2=A0Adding -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 =3D 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 =3D 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