From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22353 invoked by alias); 30 Jul 2012 10:35:06 -0000 Received: (qmail 22308 invoked by uid 22791); 30 Jul 2012 10:35:05 -0000 X-SWARE-Spam-Status: No, hits=-3.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Jul 2012 10:34:51 +0000 From: "kv.bhat at samsung dot com" To: gdb-prs@sourceware.org Subject: [Bug breakpoints/14419] New: Prologue not set properly for Non-Gcc compilers Date: Mon, 30 Jul 2012 10:35:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: breakpoints X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: kv.bhat at samsung dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org X-SW-Source: 2012-q3/txt/msg00118.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=14419 Bug #: 14419 Summary: Prologue not set properly for Non-Gcc compilers Product: gdb Version: HEAD Status: NEW Severity: critical Priority: P2 Component: breakpoints AssignedTo: unassigned@sourceware.org ReportedBy: kv.bhat@samsung.com Classification: Unclassified Created attachment 6561 --> http://sourceware.org/bugzilla/attachment.cgi?id=6561 Sample Code and Logs Dear All, I'm are trying to use GDB with binary generated from non-Gcc compiler. I'm using clang 3.1 generated compiling the code from LLVM site (http://www.llvm.org/) In this case when we try to set a breakpoint in a function with float/double arguments GDB is unable to detect the prologue end properly. Please find the example below- int floater(float a1) { int a = a1; return a; } int main() { int a = floater(1); return 0; } The assembly for this code is attached. When we call -- break floater in GDB the breakpoint is getting set at the start of function instead of 1st executable instruction. [OUR ANALYSIS] Upon analysing we found that for non-gcc compilers GDB specifically checks for prologue sequence with few pre recognized instruction set. File: arm-tdep.c Function: arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) In the function arm_skip_prologue GDB calls arm_analyze_prologue which checks for the prologue sequence with predefined register sets. It seems like not all instructions possible in prologue is covered by GDB in this function as several possible prologues can be written, resulting in slightly different stack configuration. In the example above we added few logs and extracted the object dump- GDB Logs- (gdb) b floater post_prologue_pc is 83c4 analyzed_limit is 83bc post_prologue_pc is 83c4 analyzed_limit is 83bc Object Dump - 000083b8 : 83b8: e24dd008 sub sp, sp, #8 83bc: ee000a10 vmov s0, r0 83c0: e58d0004 str r0, [sp, #4] 83c4: eebd0ac0 vcvt.s32.f32 s0, s0 83c8: ed8d0a00 vstr s0, [sp] 83cc: ee100a10 vmov r0, s0 83d0: e28dd008 add sp, sp, #8 83d4: e12fff1e bx lr As shown in the snippet above GDB is unable to recognize vmov as a valid instruction in Prologue and hence the check if (analyzed_limit != post_prologue_pc) in function arm_skip_prologue succeeds and func_addr is returned instead of post_prologue_pc resulting in breakpoint set at the start of function instead of 1st executable instruction. [FIX AND Query] I had a query as to if the call to arm_analyze_prologue is required for non-GCC compilers. We already have the prologue end location in post_prologue_pc. Is it not possible to return the same directly? We modified the code to emit post_prologue_pc irrespective of the return value of arm_analyze_prologue as we have already determined the prologue end properly in post_prologue_pc. After the fix GDB sets breakpoint properly for non-GCC compilers as well. Modiffied code - if (post_prologue_pc != 0) { return post_prologue_pc; // Just return post_prologue_pc . } I would like to get few inputs form you all if we can push this fix into GDB trunk. Files and analysis are attached. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.