From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4592 invoked by alias); 20 Dec 2010 08:06:21 -0000 Received: (qmail 4573 invoked by uid 22791); 20 Dec 2010 08:06:20 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Dec 2010 08:06:14 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id oBK84qfL004939; Mon, 20 Dec 2010 09:04:52 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id oBK84oPu005379; Mon, 20 Dec 2010 09:04:51 +0100 (CET) Date: Mon, 20 Dec 2010 08:06:00 -0000 Message-Id: <201012200804.oBK84oPu005379@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: yao@codesourcery.com CC: gdb-patches@sourceware.org In-reply-to: <4D0F0ABA.9010506@codesourcery.com> (message from Yao Qi on Mon, 20 Dec 2010 15:50:18 +0800) Subject: Re: [rfa] Update PC without side effect in displaced stepping References: <4D0F0ABA.9010506@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-12/txt/msg00365.txt.bz2 > Date: Mon, 20 Dec 2010 15:50:18 +0800 > From: Yao Qi > > 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.