This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: syscall backtraces on arm-linux-gnu
- From: Baurzhan Ismagulov <ibr at radix50 dot net>
- To: gdb-patches at sourceware dot org
- Cc: gdb at sourceware dot org
- Date: Fri, 7 Aug 2009 17:49:49 +0200
- Subject: Re: syscall backtraces on arm-linux-gnu
- References: <20090805160852.GA25684@radix50.net>
Hello,
I'm taking this to gdb-patches.
On Wed, Aug 05, 2009 at 06:08:52PM +0200, Baurzhan Ismagulov wrote:
> I can't get gdb 6.8.50.20090804 to print complete backtraces on
> arm-linux-gnu.
...
> (gdb) bt
> #0 0x400e16c8 in select () from /lib/libc.so.6
> #1 0x00000000 in ?? ()
>
> I stopped on select and stepped through the instructions. The function
> starts like this:
>
insn mnemonic
> push {lr}
> ...
1a000007 bne 0x400e16dc
> push {r4}
> ...
> svc 0x0090008e
> pop {r4}
> ...
>
> I've seen that bt starts showing incorrect results after the second
> push
It turned out that select is implemented in assembly in glibc, so no CFI
is provided and gdb falls back to prologue analysis. The following hack
fixes the use case for me:
diff -Naurp -X /opt/ibr/bin/dontdiff.ibr -X dontdiff.prj gdb-6.8.50.20090804.orig/gdb/arm-tdep.c gdb-6.8.50.20090804/gdb/arm-tdep.c
--- gdb-6.8.50.20090804.orig/gdb/arm-tdep.c 2009-07-31 01:05:04.000000000 +0200
+++ gdb-6.8.50.20090804/gdb/arm-tdep.c 2009-08-07 17:26:10.000000000 +0200
@@ -891,12 +891,14 @@ arm_scan_prologue (struct frame_info *th
regs[ARM_IP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -imm);
continue;
}
- else if (insn == 0xe52de004) /* str lr, [sp, #-4]! */
+ else if ((insn & 0xffff0000) == 0xe52d0000) /* str rx, [sp, #-4]! */
{
+ unsigned reg = (insn & 0xf000) >> 12;
if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM]))
break;
regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -4);
- pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[ARM_LR_REGNUM]);
+ if (reg == ARM_LR_REGNUM)
+ pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[ARM_LR_REGNUM]);
continue;
}
else if ((insn & 0xffff0000) == 0xe92d0000)
@@ -988,8 +990,6 @@ arm_scan_prologue (struct frame_info *th
regs[fp_start_reg++]);
}
}
- else if ((insn & 0xf0000000) != 0xe0000000)
- break; /* Condition not true, exit early */
else if ((insn & 0xfe200000) == 0xe8200000) /* ldm? */
break; /* Don't scan past a block load */
else
The first hunk handles pushes of any register, not just lr; the second
one prevents early exit on a jump (see disassembly above).
What do you think?
Meanwhile, I will see whether I can get the testsuite to work on arm.
Thanks in advance,
--
Baurzhan Ismagulov
http://www.kz-easy.com/