From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20144 invoked by alias); 29 Mar 2012 15:26:02 -0000 Received: (qmail 20128 invoked by uid 22791); 29 Mar 2012 15:26:01 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MISSING_HEADERS X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Mar 2012 15:25:48 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1SDHER-0002Lw-FN from Luis_Gustavo@mentor.com for gdb-patches@sourceware.org; Thu, 29 Mar 2012 08:25:47 -0700 Received: from NA1-MAIL.mgc.mentorg.com ([147.34.98.181]) by svr-orw-fem-01.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 29 Mar 2012 08:25:47 -0700 Received: from [0.0.0.0] ([172.16.63.104]) by NA1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 29 Mar 2012 08:25:46 -0700 Message-ID: <4F747EEA.4080509@mentor.com> Date: Thu, 29 Mar 2012 15:26:00 -0000 From: Luis Gustavo Reply-To: "Gustavo, Luis" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.27) Gecko/20120216 Lightning/1.0b2 Thunderbird/3.1.19 MIME-Version: 1.0 CC: gdb-patches@sourceware.org Subject: Re: [PATCH] Fix displaced stepping for remote targets References: <4F67E54C.1010904@mentor.com> In-Reply-To: <4F67E54C.1010904@mentor.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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: 2012-03/txt/msg01000.txt.bz2 Ping? On 03/19/2012 11:02 PM, Luis Gustavo wrote: > Hi, > > While debugging a remote target that supports hardware single-stepping > with a GDB that supports displaced stepping, i've ran into the following > problem... > > When reaching a breakpoint, GDB should take care of relocating the > instruction underneath that breakpoint to the scratch space where it > will be executed out-of-line. > > If a target supports hw single-stepping for displaced stepping, GDB > should just send a vCont;s packet to tell the target to step a single > instruction. In my case, GDB was always sending a vCont;c instead. > > I've tracked it down to infrun.c:resume, where we have this check: > > if (gdbarch_cannot_step_breakpoint (gdbarch)) > { > /* Most targets can step a breakpoint instruction, thus > executing it normally. But if this one cannot, just > continue and we will hit it anyway. */ > if (step && breakpoint_inserted_here_p (aspace, pc)) > step = 0; > } > > My target can't step breakpoints and, if we're doing displaced stepping, > it's because we're trying to step off a breakpoint, thus > breakpoint_inserted_here_p returns true, and we disable single-stepping > by setting step to 0. > > It seems to me we need to update the PC prior to calling > breakpoint_inserted_here_p since the displaced stepping machinery > adjusted the old PC to point to the space in the scratch area. That way > we can properly command the target to step the displaced instruction and > we can check for breakpoints at the real execution place. > > The following patch fixes this by pushing the if block further down in > the code and taking care of updating PC if displaced stepping is being > used. > > I've regtested this on x86 and everything looks OK. This also makes GDB > send vCont;s now. > > Ok? > > Luis