From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6802 invoked by alias); 9 Jul 2007 13:43:09 -0000 Received: (qmail 6794 invoked by uid 22791); 9 Jul 2007 13:43:08 -0000 X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 09 Jul 2007 13:43:05 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.1/8.13.1) with ESMTP id l69Dh0HR001446; Mon, 9 Jul 2007 09:43:00 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l69Dh09F003677; Mon, 9 Jul 2007 09:43:00 -0400 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l69DgwfO012191; Mon, 9 Jul 2007 09:42:59 -0400 Message-ID: <46923B73.4050000@redhat.com> Date: Mon, 09 Jul 2007 13:43:00 -0000 From: Andrew Cagney User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: Mark Wielaard CC: frysk@sourceware.org Subject: Re: [patch] Breakpoint - only reset instruction bytes covered by breakpoint instruction bytes References: <1183969101.3654.5.camel@dijkstra.wildebeest.org> In-Reply-To: <1183969101.3654.5.camel@dijkstra.wildebeest.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q3/txt/msg00052.txt.bz2 Please use the ByteBuffer's bulk get/put methods. Andrew Mark Wielaard wrote: > Hi, > > This is kind of an micro optimization. But it was noticable during a > trace while investigating breakpoint set/reset behavior. And potentially > setting bytes in the inferior is expensive. So here is a little patchlet > to not do any unnecessary work while resetting (or uninstalling) a > breakpoint. > > 2007-07-09 Mark Wielaard > > * Breakpoint.java (reset): Only copy back bytes covered by > breakpiont instructions. > > Tested on x86_64/FC6, no regressions. > > Cheers, > > Mark > > ------------------------------------------------------------------------ > > Index: frysk-core/frysk/proc/Breakpoint.java > =================================================================== > RCS file: /cvs/frysk/frysk-core/frysk/proc/Breakpoint.java,v > retrieving revision 1.12 > diff -u -r1.12 Breakpoint.java > --- frysk-core/frysk/proc/Breakpoint.java 2 Jul 2007 14:40:16 -0000 1.12 > +++ frysk-core/frysk/proc/Breakpoint.java 9 Jul 2007 08:15:17 -0000 > @@ -172,13 +172,18 @@ > */ > private void reset(Task task) > { > - ByteBuffer buffer; > - > - buffer = task.getMemory(); > + ByteBuffer buffer = task.getMemory(); > buffer.position(address); > > + Isa isa = task.getIsa(); > + Instruction bpInstruction = isa.getBreakpointInstruction(); > + byte[] bp = bpInstruction.getBytes(); > + > byte[] bs = origInstruction.getBytes(); > - for (int index = 0; index < bs.length; index++) > + > + // Only need to put back the part of the original instruction > + // covered by the breakpoint instruction bytes. > + for (int index = 0; index < bp.length; index++) > buffer.putByte(bs[index]); > } > >