public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: frysk@sourceware.org
Subject: [patch] Breakpoint - only reset instruction bytes covered by 	breakpoint instruction bytes
Date: Mon, 09 Jul 2007 08:18:00 -0000	[thread overview]
Message-ID: <1183969101.3654.5.camel@dijkstra.wildebeest.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 505 bytes --]

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  <mwielaard@redhat.com>

        * Breakpoint.java (reset): Only copy back bytes covered by
        breakpiont instructions.

Tested on x86_64/FC6, no regressions.

Cheers,

Mark

[-- Attachment #2: Breakpoint.patch --]
[-- Type: text/x-patch, Size: 1034 bytes --]

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]);
   }
 

             reply	other threads:[~2007-07-09  8:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-09  8:18 Mark Wielaard [this message]
2007-07-09 13:43 ` Andrew Cagney
2007-07-10  9:10   ` Mark Wielaard
2007-07-10 15:46     ` Andrew Cagney
2007-07-10 16:33       ` Chris Moller
2007-07-10 17:03         ` Andrew Cagney

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=1183969101.3654.5.camel@dijkstra.wildebeest.org \
    --to=mark@klomp.org \
    --cc=frysk@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).