public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: matthew.gretton-dann@arm.com (Matthew Gretton-Dann)
Cc: gdb@sourceware.org, rearnsha@arm.com (Richard Earnshaw),
	       dan@codesourcery.com
Subject: Re: ARM prologue parsing support for Thumb-2 instructions?
Date: Mon, 19 Jul 2010 10:59:00 -0000	[thread overview]
Message-ID: <201007191059.o6JAx5r0026004@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <1279529477.3466.25.camel@e102319-lin.cambridge.arm.com> from "Matthew Gretton-Dann" at Jul 19, 2010 09:51:17 AM

Matthew Gretton-Dann wrote:

> If gdb is using arm_analyze_prologue and not thumb_analyze_prologue for
> Thumb (1 or 2) code then gdb is not guessing the instruction state
> correctly.

Actually, it seems I misspoke here; I intended to refer to arm_scan_prologue
where I wrote arm_analyze_prologue.  GDB is in fact then calling down to
thumb_analyze_prologue, not arm_analyze_prologue, in my test.  So at least
in the test case I'm looking at, instruction state detection does not appear
to be the problem ...

> I submitted a patch earlier this year
> (http://sourceware.org/ml/gdb-patches/2010-03/msg00168.html) to try to
> improve gdb's heuristic for determining the instruction state which may
> help - although in that particular use case it was for
> single-stepping.  

Thanks for the tip.  This patch did go upstream a while ago and is 
already included in the pre-7.2 GDB I was testing.

> Trunk thumb_analyze_prologue does have support for Thumb-2.

Well, all the support for Thumb-2 I can see is in this block:

      else if ((insn & 0xe000) == 0xe000 && cache == NULL)
        {
          /* Only recognize 32-bit instructions for prologue skipping.  */

which, as the comment says, is active *only* if this routine is
called from arm_skip_prologue (with cache == NULL), but not if the
routine is called from arm_scan_prologue (with cache != NULL),
which is what is used during unwinding.

> However,
> thumb_analyze_prologue will stop analyzing the prologue as soon as it
> sees an instruction which it does not understand as part of a prologue
> sequence.  This is the opposite from arm_analyze_prologue, which knows
> which non-prologue sequence instructions are safe to ignore and which
> are not.

That may or may not be an additional problem; right now during unwinding
GDB doesn't even get beyond the very first instruction of a Thumb-2
prologue ...

> Fixing thumb_analyze_prologue to behave like arm_analyze_prologue is on
> my list of things to do, but it is not going to happen immediately.  So
> if you want to have a go at fixing this please feel free.

OK, I'll have a look.

> A related issue with backtracing through system calls is that inline
> syscalls in glibc corrupt the frame pointer (during the syscall) so that
> if you try to backtrace when at a syscall you get garbage.  This was
> fixed in this glibc patch:
> http://sourceware.org/ml/libc-ports/2010-04/msg00001.html.

Thanks for the pointer!

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

  reply	other threads:[~2010-07-19 10:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16 17:03 Ulrich Weigand
2010-07-16 19:37 ` Daniel Jacobowitz
2010-07-19  8:51 ` Matthew Gretton-Dann
2010-07-19 10:59   ` Ulrich Weigand [this message]
2010-07-19 14:10     ` 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=201007191059.o6JAx5r0026004@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=dan@codesourcery.com \
    --cc=gdb@sourceware.org \
    --cc=matthew.gretton-dann@arm.com \
    --cc=rearnsha@arm.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).