public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/14261] New: Break point not set at the 1st executable instruction in case of code compiled with clang on ARM Architecture.
@ 2012-06-18 12:12 karthikthecool at gmail dot com
  2013-10-30 23:18 ` [Bug gdb/14261] " will.newton at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: karthikthecool at gmail dot com @ 2012-06-18 12:12 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14261

             Bug #: 14261
           Summary: Break point not set at the 1st executable instruction
                    in case of code compiled with clang on ARM
                    Architecture.
           Product: gdb
           Version: 7.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
        AssignedTo: unassigned@sourceware.org
        ReportedBy: karthikthecool@gmail.com
    Classification: Unclassified


Created attachment 6456
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6456
Assembly files with R(0123) which works fine and Assembly generated by clang
which uses R(4-12) as well.

Dear Developers,
We are using clang(LLVM) compiled binary on ARM and debugging the same using
GDB. When a break point is set at a function, it is set at the 1st line instead
of 1st executable instruction.
E.g.
For e.g. In the below function-

int main()          //line 1
{                   //line 2
                    //line 3
  int j =0;         //line 4
  return j;         //line 5
}                   //line 6


When we compile the above code and run gdb with the following commands-

gdb a.out
break main

The break point is set at line 2 instead of line 4.


Upon Debugging we found that in GDB Arm-tdep.c -

static CORE_ADDR
arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)


      if ((inst & 0xffffc000) == 0xe5cd0000    /* strb r(0123),[sp,#nn] */
      || (inst & 0xffffc0f0) == 0xe1cd00b0    /* strh r(0123),[sp,#nn] */
      || (inst & 0xffffc000) == 0xe58d0000)    /* str  r(0123),[sp,#nn] */
    continue;

We skip the prologue only in case strb uses registers r0,r1,r2 or r3 in
prologue code. 

clang (LLVM) generates strb instruction with r4,r5...etc not just r(0123) in
prologue code.

In clang case the usage of any other register other than r(0123) in
strb/strh/str instruction is resulting in generation of wrong prologue_end
resulting in break point not being set at 1st executable instruction.When we
modified the strb/strh/str instructions to use r(0123) gdb functionality of
break/list/watch functions correctly.

Attached is the assembly and source code of a function compiled using clang in
which r12/ r4 is used in strb/strh/str/ldr etc instructions used during
parameter assignment 
which results in failure of the above check in arm_skip_prologue resulting in
wrong prologue end info.



We would like to know if we are checking against r(0123) for some specific
purpose or because some specification mandates this usage ?

-- 
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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-12-12  2:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-18 12:12 [Bug gdb/14261] New: Break point not set at the 1st executable instruction in case of code compiled with clang on ARM Architecture karthikthecool at gmail dot com
2013-10-30 23:18 ` [Bug gdb/14261] " will.newton at gmail dot com
2014-10-30 14:53 ` chrbr at gcc dot gnu.org
2014-10-30 14:56 ` chrbr at gcc dot gnu.org
2014-12-12  0:42 ` [Bug tdep/14261] " qiyao at gcc dot gnu.org
2014-12-12  0:52 ` cvs-commit at gcc dot gnu.org
2014-12-12  2:14 ` qiyao at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).