Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Baurzhan Ismagulov <ibr@radix50.net>
To: gdb-patches@sourceware.org
Cc: gdb@sourceware.org
Subject: Re: syscall backtraces on arm-linux-gnu
Date: Fri, 07 Aug 2009 16:07:00 -0000	[thread overview]
Message-ID: <20090807154949.GC28041@radix50.net> (raw)
In-Reply-To: <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/


       reply	other threads:[~2009-08-07 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090805160852.GA25684@radix50.net>
2009-08-07 16:07 ` Baurzhan Ismagulov [this message]
2009-08-07 17:22   ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090807154949.GC28041@radix50.net \
    --to=ibr@radix50.net \
    --cc=gdb-patches@sourceware.org \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox