[PATCH V2] gdb/arm-tdep: the "strd rd, [sp, #-imm]!" is the part of function prologue
Joel Brobecker
brobecker@adacore.com
Sat Feb 1 13:17:00 GMT 2020
Hello,
On Tue, Jan 14, 2020 at 09:57:35AM +0800, chenzefeng wrote:
> Compiled the follow test case code with "-mtune=cortex-a15 -O2",
> The function test1 dump core:
> (gdb) disassemble test1
> Dump of assembler code for function test1:
> 0x0040062c <+0>: strd r4, [sp, #-16]!
> => 0x00400630 <+4>: add r4, r0, r1
> 0x00400634 <+8>: ldr r0, [pc, #80] ; 0x40068c <test1+96>
> 0x00400638 <+12>: mov r1, r4
> 0x0040063c <+16>: str r6, [sp, #8]
> 0x00400640 <+20>: add r5, r2, r3
>
> When make a breakpoint at test1 + <+4>, we can not get a full backtrace:
> (gdb) bt
> #0 0x00400630 in test1 ()
> #1 0x004006e8 in show_info ()
> #2 0x00000000 in ?? ()
>
> For the arm_analyze_prologue can't deal with the insn
> "strd r4, [sp, #-16]!",
> which should change the sp register.
>
> The test case code as follow:
> void test1(int a, int b, int c, int d)
> {
> int e = a + b;
> int f = c + d;
> int g = e / f;
> printf("a + b = %d\n", e);
> printf("c + d = %d\n", f);
> printf("e / f = %d\n", g);
> }
>
> int show_info(int a, int b, int c)
> {
> int d;
>
> d = a + c;
> printf("%d, %d %ld %c\n",a , d , c , b);
>
> test1(a, b, c, d);
>
> return d;
> }
>
> int main(int argc, char *argv[])
> {
> return show_info(1, 2, 3);
> }
> ---
> gdb/ChangeLog | 4 ++++
> gdb/arm-tdep.c | 9 +++++++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 731449b6ef..179630b70f 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-01-14 Chenzefeng <chenzefeng2@huawei.com>
> + * arm-tdep.c (arm_analyze_prologue): Add a new insn for function
> + prologue.
The change looks reasonable, but please resubmit following the same
recommendations as the one I proposed in my previous message to you
(https://www.sourceware.org/ml/gdb-patches/2020-02/msg00018.html)
Let's also take this opportunity for being a little more specific
in the ChangeLog:
* arm-tdep.c (arm_analyze_prologue): Add handling of
"strd rd [sp, #imm]!" instructions.
(do you mind doing the same for the other patch as well?)
Thank you!
> +
> 2020-01-13 Chenzefeng <chenzefeng2@huawei.com>
>
> * arm-tdep.c (arm_analyze_prologue): Fix to adapt insn
> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
> index 8a9f878b69..060acbf285 100644
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -1550,6 +1550,15 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
> regs[bits (insn, 12, 15)]);
> continue;
> }
> + else if ((insn & 0xffff00f0) == 0xe16d00f0) /* strd rd, [sp, #imm]! */
> + {
> + unsigned imm = ((insn & 0xf00) >> 4) + (insn & 0xf);
> + if (stack.store_would_trash (regs[ARM_SP_REGNUM]))
> + break;
> + regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -imm);
> + stack.store (regs[ARM_SP_REGNUM], 4, regs[bits (insn, 12, 15)]);
> + continue;
> + }
> else if ((insn & 0xffff0000) == 0xe92d0000)
> /* stmfd sp!, {..., fp, ip, lr, pc}
> or
> --
> 2.12.3
--
Joel
More information about the Gdb-patches
mailing list