Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: "Joseph S. Myers" <joseph@codesourcery.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: Fix ARM stepping over Thumb-mode "bx pc" or "blx pc"
Date: Sat, 11 Aug 2012 07:45:00 -0000	[thread overview]
Message-ID: <50260D91.5070000@codesourcery.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1208101705020.7722@digraph.polyomino.org.uk>

On 08/11/2012 01:06 AM, Joseph S. Myers wrote:
> arm-tdep.c has code to determine the next instruction for use in
> single stepping.  This code fails to handle a Thumb-mode "bx pc" or
> "blx pc" correctly; it acts as if the branch target (four bytes after
> the current instruction) should be in Thumb mode, when actually these

Yes, as we can see, at the beginning of thumb_get_next_pc_raw, the
'pc_val' is converted to THUMB_ADDR,

static CORE_ADDR
thumb_get_next_pc_raw (struct frame_info *frame, CORE_ADDR pc)
{
[...]
  pc_val = MAKE_THUMB_ADDR (pc_val)

> Index: gdb/arm-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/arm-tdep.c,v
> retrieving revision 1.365
> diff -u -r1.365 arm-tdep.c
> --- gdb/arm-tdep.c	25 Jun 2012 12:32:45 -0000	1.365
> +++ gdb/arm-tdep.c	10 Aug 2012 15:18:37 -0000
> @@ -4541,7 +4541,7 @@
>    else if ((inst1 & 0xff00) == 0x4700)	/* bx REG, blx REG */
>      {
>        if (bits (inst1, 3, 6) == 0x0f)
> -	nextpc = pc_val;
> +	nextpc = pc_val & 0xfffffffc;
>        else
>  	nextpc = get_frame_register_unsigned (frame, bits (inst1, 3, 6));
>      }

I don't have any preference on clearing either the last one bit in
address or the last two bits.  Looks like two ways coexist in arm-tdep.c
nowadays.  As 'pc_val' is set by MAKE_THUMB_ADDR at the beginning, it is
better to revert its change by using UNMAKE_THUMB_ADDR (which only
clears the last one bit of address).

-- 
Yao (齐尧)



  reply	other threads:[~2012-08-11  7:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 17:06 Joseph S. Myers
2012-08-11  7:45 ` Yao Qi [this message]
2012-08-13 16:31   ` Joseph S. Myers
2012-08-20 11:09     ` Ping " Joseph S. Myers
2012-08-22 14:36       ` Yao Qi
2012-08-23 19:09         ` Tom Tromey
2012-08-22 18:01     ` Pedro Alves
2012-08-22 19:43       ` Tom Tromey

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=50260D91.5070000@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=joseph@codesourcery.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