public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* [patch] Breakpoint - only reset instruction bytes covered by  breakpoint instruction bytes
@ 2007-07-09  8:18 Mark Wielaard
  2007-07-09 13:43 ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Wielaard @ 2007-07-09  8:18 UTC (permalink / raw)
  To: frysk

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-07-10 17:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-09  8:18 [patch] Breakpoint - only reset instruction bytes covered by breakpoint instruction bytes Mark Wielaard
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

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).