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