public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] Strip Thumb bit from PC returned by arm_get_longjmp_target
Date: Fri, 20 Aug 2010 08:53:00 -0000	[thread overview]
Message-ID: <1282294368.7290.23.camel@e102319-lin.cambridge.arm.com> (raw)
In-Reply-To: <201008181828.o7IISkgd004584@d12av02.megacenter.de.ibm.com>

On Wed, 2010-08-18 at 20:28 +0200, Ulrich Weigand wrote:
> Matthew Gretton-Dann wrote:
> > However, I think there is a more fundamental issue to be solved in the
> > ARM backend.  For ARM (and possibly other architectures) you do not have
> > enough information in the PC to be able to accurately set a breakpoint,
> > you also need to know the instruction set in use at that address.
> > 
> > Currently this is being done in a fairly ad hoc and inconsistent fashion
> > by using bit-0 to indicate Thumb or ARM state.  But this troublesome to
> > maintain, and can make the debugger behave in a non-obvious manner to
> > the user.  I think it would be cleaner to change the interfaces to
> > various functions (for example breakpoint_from_pc) to take an
> > 'instruction set state' parameter as well as the pc (or change the pc
> > from a CORE_ADDR to a { CORE_ADDR pc; enum instruction_set isa; } pair),
> > but this would be a large scale change with impacts throughout the code
> > base - which probably makes it impractical, and certainly in need of
> > discussion.
> 
> Good point.  I think there are two potential longer-term options.  On
> the one hand, we've been planning to add support for multiple address
> spaces within a single process; this would imply that all gdbarch
> callbacks that get an address today also receive an address space
> identifier.  If we have that, we could create two address spaces to 
> represent the Thumb vs. ARM instruction space ...
> 
> Another option would be to actually have two separate *gdbarch*
> implementations for Thumb vs. ARM, and use the multi-architecture
> support to choose the proper architecture to use.  For frames,
> this would already be possible today using the frame-arch unwinder
> I've added for Cell support.  There is even a breakpoint-location
> architecture, but no way yet for the back-end to influence how
> this is selected ... that can be added, though.  (There may be
> other places where support is currently insufficient, of course.)
> 
> In fact, the latter option seems nice anyway since in several gdbarch
> callback we already basically have a big "if ARM vs. Thumb" switching
> between two quite different implementations.  Just having two different
> gdbarch's in the first place might actually simplify this ...

Using two gdbarch objects seems reasonable, and also extends nicely if
we decide to support the ThumbEE ISA as well (which is intended for JITs
so gdb is unlikely to have any debug info to help it along).

However, I am concerned about a couple of things:

1) What changes does this make to the user interface?  Can I user still
say 'break main' and gdb will determine ARM or Thumb automatically?
Will the user still be able to see a backtrace with some frames in ARM
state and some in Thumb?

2) This moves the decision what instruction set state a breakpoint is
targetting from the time we set the breakpoint to the time the
breakpoint is requested by the user.  Is this a reasonable thing to do?
I think so - I don't expect code to change under the debugger's feet, so
making the decision when we have most information available (at
breakpoint request time) is the correct way to go.

Thanks,

Matt


-- 
Matthew Gretton-Dann
Principal Engineer - PDSW Tools
ARM Ltd

  parent reply	other threads:[~2010-08-20  8:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-17 19:16 Ulrich Weigand
2010-08-18  9:01 ` Matthew Gretton-Dann
2010-08-18 18:28   ` Ulrich Weigand
2010-08-19  8:49     ` Ulrich Weigand
2010-08-20  8:38       ` Matthew Gretton-Dann
2010-08-20 12:00         ` Ulrich Weigand
2010-08-20  8:53     ` Matthew Gretton-Dann [this message]
2010-08-20 11:45       ` Ulrich Weigand

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=1282294368.7290.23.camel@e102319-lin.cambridge.arm.com \
    --to=matthew.gretton-dann@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.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).