This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfa] Update PC without side effect in displaced stepping
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: yao at codesourcery dot com
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 20 Dec 2010 09:04:51 +0100 (CET)
- Subject: Re: [rfa] Update PC without side effect in displaced stepping
- References: <4D0F0ABA.9010506@codesourcery.com>
> 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.