This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/14261] New: Break point not set at the 1st executableinstruction in case of code compiled with clang on ARM Architecture.
- From: "karthikthecool at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Mon, 18 Jun 2012 12:12:33 +0000
- Subject: [Bug gdb/14261] New: Break point not set at the 1st executableinstruction in case of code compiled with clang on ARM Architecture.
- Auto-submitted: auto-generated
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.