From patchwork Tue Feb 15 19:03:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 83282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 2F116B70CB for ; Wed, 16 Feb 2011 06:03:27 +1100 (EST) Received: (qmail 17445 invoked by alias); 15 Feb 2011 19:03:26 -0000 Received: (qmail 17436 invoked by uid 22791); 15 Feb 2011 19:03:25 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, FSL_RU_URL, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Feb 2011 19:03:20 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1FJ3GvK029990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Feb 2011 14:03:16 -0500 Received: from anchor.twiddle.home (ovpn-113-82.phx2.redhat.com [10.3.113.82]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p1FJ3FHU030400; Tue, 15 Feb 2011 14:03:15 -0500 Message-ID: <4D5ACDF2.20904@redhat.com> Date: Tue, 15 Feb 2011 11:03:14 -0800 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 MIME-Version: 1.0 To: =?UTF-8?B?UGV0ciBIbHV6w61u?= CC: Anitha Boyapati , binutils@sourceware.org, gdb@sourceware.org, GCC Patches , chertykov@gmail.com, aesok@post.ru, eric.weddington@atmel.com Subject: [avr] gas support for cfi info References: <4D5ABAB2.2000405@redhat.com> In-Reply-To: <4D5ABAB2.2000405@redhat.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 02/15/2011 09:41 AM, Richard Henderson wrote: > On 02/13/2011 07:10 AM, Petr HluzĂ­n wrote: >> http://xfree86.cygwin.ru/ml/binutils/2010-08/msg00109.html > > I'll agree that a better error message would be helpful. > > To answer a question within that message: > >> By the way: Why AVR target does not understand CFI? What needs to be >> done in binutils? And in GDB? > > TARGET_USE_CFIPOP > DWARF2_DEFAULT_RETURN_COLUMN > DWARF2_CIE_DATA_ALIGNMENT > DWARF2_LINE_MIN_INSN_LENGTH > > are the macros that need to be defined, > > tc_cfi_frame_initial_instructions > > may be required depending on what the state of the unwind > info incoming to a function. Have a look at tc-i386.c, > tc_x86_frame_initial_instructions for a typical stack-based > call mechanism. > > For the nearly related task of dwarf2 line numbers, you need > a call to dwarf2_emit_insn emitted immediately before each > insn is added to the frags. Again, see tc-i386.c for ideas. To follow up on myself, it appears as if avr already has dwarf2 line number support, and only needs a few things in order to enable cfi support. CC'd to gcc and gdb because the dwarf2 register numbers for SP and the return address column need to be coordinated. This is part of the target's ABI. I've left a ??? marker for when AVR_3_BYTE_PC would be true in gcc; I haven't tracked down how that maps into the assembler, or even if there is a simple mapping. r~ Index: config/tc-avr.c =================================================================== RCS file: /cvs/src/src/gas/config/tc-avr.c,v retrieving revision 1.74 diff -u -p -r1.74 tc-avr.c --- config/tc-avr.c 28 Jun 2010 14:06:57 -0000 1.74 +++ config/tc-avr.c 15 Feb 2011 18:52:05 -0000 @@ -24,6 +24,8 @@ #include "as.h" #include "safe-ctype.h" #include "subsegs.h" +#include "dw2gencfi.h" + struct avr_opcodes_s { @@ -1488,3 +1490,12 @@ avr_cons_fix_new (fragS *frag, exp_mod_pm = 0; } } + +void +tc_cfi_frame_initial_instructions (void) +{ + /* ??? How do we tell if we're in 3-byte pc mode? */ + /* The CFA is immediately above the return address, which is on the stack. */ + cfi_add_CFA_def_cfa (32, 2); + cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN, -2); +} Index: config/tc-avr.h =================================================================== RCS file: /cvs/src/src/gas/config/tc-avr.h,v retrieving revision 1.17 diff -u -p -r1.17 tc-avr.h --- config/tc-avr.h 27 Oct 2009 15:39:27 -0000 1.17 +++ config/tc-avr.h 15 Feb 2011 18:52:05 -0000 @@ -153,3 +153,17 @@ extern long md_pcrel_from_section (struc /* 32 bits pseudo-addresses are used on AVR. */ #define DWARF2_ADDR_SIZE(bfd) 4 + +/* Enable cfi directives. */ +#define TARGET_USE_CFIPOP 1 + +/* The stack grows down, and is only byte aligned. */ +#define DWARF2_CIE_DATA_ALIGNMENT -1 + +/* Define the column that represents the PC. */ +/* ??? This is an abi thing; coordinate with other projects. */ +#define DWARF2_DEFAULT_RETURN_COLUMN 36 + +/* Define a hook to setup initial CFI state. */ +extern void tc_cfi_frame_initial_instructions (void); +#define tc_cfi_frame_initial_instructions tc_cfi_frame_initial_instructions