From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116819 invoked by alias); 15 Apr 2016 16:24:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 116809 invoked by uid 89); 15 Apr 2016 16:24:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=fffe, 0x4, 0x6 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 15 Apr 2016 16:24:38 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83115C04B313; Fri, 15 Apr 2016 16:24:36 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3FGOZ5u014582; Fri, 15 Apr 2016 12:24:35 -0400 Subject: Re: [PATCH] [ARM] minor opt in thumb_stack_frame_destroyed_p To: Yao Qi , gdb-patches@sourceware.org References: <1460730578-28723-1-git-send-email-yao.qi@linaro.org> From: Pedro Alves Message-ID: <571115C3.8010500@redhat.com> Date: Fri, 15 Apr 2016 16:24:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1460730578-28723-1-git-send-email-yao.qi@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-04/txt/msg00361.txt.bz2 On 04/15/2016 03:29 PM, Yao Qi wrote: > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -3135,6 +3135,14 @@ thumb_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc) > if (!find_pc_partial_function (pc, NULL, &func_start, &func_end)) > return 0; > > + if (func_end - pc > 4 * 4) > + { > + /* There shouldn't be more than four instructions in epilogue. > + If PC is still 16 bytes away from FUNC_END, it isn't in > + epilogue. */ This assumes epilogue sequences are always at the end of the function. I suspected this isn't a safe assumption, and I asked gcc folks. The answer I got was that gcc can and does emit epilogues in the middle of functions. Below's an example I was given, and the corresponding x86-64 and ARM disassembly. Note the 'retq' / 'bx lr' in the middle. #include void f (int x) { if (x == 0) abort(); } Compile with -O2. x86-64: 0000000000000000 : 0: 85 ff test %edi,%edi 2: 74 02 je 6 4: f3 c3 repz retq 6: 50 push %rax 7: e8 00 00 00 00 callq c ARM: 00000000 : 0: b100 cbz r0, 4 2: 4770 bx lr 4: b508 push {r3, lr} 6: f7ff fffe bl 0 a: bf00 nop Thanks, Pedro Alves