From patchwork Tue Sep 9 01:25:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 2697 Received: (qmail 18265 invoked by alias); 9 Sep 2014 01:29:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 18247 invoked by uid 89); 9 Sep 2014 01:29:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Sep 2014 01:29:55 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XRAFk-0002Qv-Ab from Yao_Qi@mentor.com ; Mon, 08 Sep 2014 18:29:52 -0700 Received: from GreenOnly (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Mon, 8 Sep 2014 18:27:08 -0700 From: Yao Qi To: Doug Evans CC: , , Subject: Re: [PATCH] Remove some obfuscation from ${arch}_skip_prologue functions References: <87ha0ndaub.fsf@codesourcery.com> <21512.42127.940240.832062@ruffy2.mtv.corp.google.com> Date: Tue, 9 Sep 2014 09:25:51 +0800 In-Reply-To: <21512.42127.940240.832062@ruffy2.mtv.corp.google.com> (Doug Evans's message of "Thu, 4 Sep 2014 10:42:39 -0700") Message-ID: <87r3zlbn4w.fsf@codesourcery.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Doug Evans writes: > I have found two cases where, I think, ${arch}_skip_prologue can > be called with pc != func_addr: vax and ppc. > I'd be happy with simplifying the target API so that > we could have such an assert, though I'd rather not put it > in ${arch}_skip_prologue. I currently have the problem that > the treatment of gcc vs clang is not as consistent as it could be > across all ${arch}_skip_prologue functions, so I'm on a path of keeping > as much code that should be common out of target-specific routines: > cleaning it up later is not always fun or easy. Agreed. > > > Note that this assert is triggered on arm in > > gdb.cp/re-set-overloaded.exp, that is PC is [1] but FUNC_ADDR is [2]. > > > > (gdb) disassemble _ZN1CC1Ei > > Dump of assembler code for function _ZN1CC1Ev: > > 0x0000090c <+0>: ldr r12, [pc, #4] ; 0x918 <_ZN1CC1Ev+12> <- [2] > > 0x00000910 <+4>: add r12, r12, pc > > 0x00000914 <+8>: bx r12 > > 0x00000918 <+12>: ; instruction: 0xffffffc5 > > 0x0000091c <+0>: ldr r12, [pc, #4] ; 0x928 <_ZN1CC1Ei+12> <- [1] > > 0x00000920 <+4>: add r12, r12, pc > > > > AFAICS, PC is still the function address but find_pc_partial_function > > computes the FUNC_ADDR incorrectly and it is nothing wrong about your > > patch. > > Thanks, this is good data. > > I did a similar experiment on amd64-linux after writing > https://sourceware.org/ml/gdb-patches/2014-08/msg00539.html > and got no hits. > > I'd be curious to see how arm_skip_prologue handles this. I hacked arm_skip_prologue as the patch below shows. > What flavor of arm and what version of gcc? The test case is compiled with "-mthumb -march=armv4t", and gcc is 4.9.1 based sourcery lite gcc for arm-none-linux-gnueabi. > I can't recreate that example with arm-linux-gnueabi-g++-4.7. > Also, can you send me gdb.log plus re-set-overloaded{,.so} ? > [don't cc the list :-)] Yes, they are sent to you. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index f9feb52..d2f2d52 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1396,6 +1396,8 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) = skip_prologue_using_sal (gdbarch, func_addr); struct symtab *s = find_pc_symtab (func_addr); + gdb_assert (pc == func_addr); + if (post_prologue_pc) post_prologue_pc = arm_skip_stack_protector (post_prologue_pc, gdbarch);