Prologue not set properly for Non-Gcc compilers
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Linaro GDB |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Dear All,
I'm are trying to use GDB Linaro (7.2) with binary generated from non-Gcc compiler. I'm using clang 3.1 generated compiling the code from LLVM site (http://
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.
The same is reproducible with latest GDB as well.
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_
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 <floater>:
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_
We modified the code to emit post_prologue_pc irrespective of the return value of arm_analyze_
Modified 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.
Thanks and Regrds
Karthik V Bhat
Changed in gdb-linaro: | |
status: | New → Fix Committed |
Changed in gdb-linaro: | |
status: | Fix Committed → Fix Released |
Hi Karthik. My understanding is that GDB only falls back to prologue parsing if there's no debug information present. As it's a fallback, it doesn't handle every situation and has been tested against GDB best.
Out of interest, could you try it with the latest GDB 7.5 and debug info on?