Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: yao@codesourcery.com
Cc: gdb-patches@sourceware.org
Subject: Re: [rfa] Update PC without side effect in displaced stepping
Date: Mon, 20 Dec 2010 08:06:00 -0000	[thread overview]
Message-ID: <201012200804.oBK84oPu005379@glazunov.sibelius.xs4all.nl> (raw)
In-Reply-To: <4D0F0ABA.9010506@codesourcery.com> (message from Yao Qi on Mon,	20 Dec 2010 15:50:18 +0800)

> Date: Mon, 20 Dec 2010 15:50:18 +0800
> From: Yao Qi <yao@codesourcery.com>
> 
> During preparation of displaced stepping (in displaced_step_prepare),
> regcache_write_pc is called to update PC to the address of copy area,
> and gdbarch_write_pc is called subsequently.  However, gdbarch_write_pc
> has some side effects besides updating PC values.
> 
> As far as I know on updating PC in displaced_step_prepare, what we need
> here is to force program to execute one or some instructions in copy
> area, and get the *same* effect of single-step one instruction on
> original place, so we should update PC without any side effect.
> 
> Current approach may have some drawbacks in some cases.  For example, on
> ARM, system library is compiled in Thumb mode, and application is
> compiled in ARM mode.  The copy area for displaced stepping is in thumb
> mode.  During displaced stepping, GDB copies that ARM instruction to
> copy area, and using regcache_write_pc to update PC to the new address
> of this instruction.  Due to the side effect of arm_write_pc, the T bit
> is set in status register, so one 32-bit ARM instruction is interpreted
> as two 16-bit thumb instructions by mistake.
> 
> This patch is to fix this problem.  Regression tested on x86_64-linux.
> OK for mainline?

Sorry, no this isn't right.  On sparc and hppa for example, the
effects of write_pc() are needed here, since both the pc and the "next
pc" registers need to be updated to make sure all instructions in the
copy area get executed.

I think you'll have to make sure that if the displaced instructions
are Thumb instructions, the copy area gets properly marked as Thumb
such that write_pc() can do the right thing on arm as well.


  reply	other threads:[~2010-12-20  8:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20  7:50 Yao Qi
2010-12-20  8:06 ` Mark Kettenis [this message]
2010-12-20 13:42   ` Yao Qi
2010-12-21 16:19     ` Yao Qi
2010-12-23  4:54       ` Joel Brobecker
2010-12-23  8:45         ` Yao Qi
2011-01-06 14:19           ` [PING : rfa] " Yao Qi
2011-01-12  5:39           ` [try 3rd] arm_pc_is_thumb takes displaced stepping into account Yao Qi
2011-01-13 15:55             ` Matthew Gretton-Dann
2011-01-13 16:34               ` Yao Qi
2011-01-19 16:09             ` [Ping 1: try " Yao Qi
2011-01-30  3:21               ` [Ping 2: " Yao Qi
2011-01-31 15:40             ` [try " Ulrich Weigand
2011-02-10  6:42               ` Yao Qi
2011-02-15 21:15                 ` Ulrich Weigand
2010-12-23 12:04         ` [rfa] Update PC without side effect in displaced stepping Mark Kettenis

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=201012200804.oBK84oPu005379@glazunov.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@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