From 00ca041f6bd35ee1b6d206c737055f8f354df887 Mon Sep 17 00:00:00 2001 From: John Dallaway Date: Mon, 24 Sep 2012 10:21:15 -0400 Subject: [PATCH] Bug 387688: Memory cache update fix --- .../src/org/eclipse/cdt/dsf/mi/service/MIMemory.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java index 4aa41ceff4a..9ef79683285 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java @@ -11,6 +11,7 @@ * Ericsson AB - added support for event handling * Ericsson AB - added memory cache * Vladimir Prus (CodeSourcery) - support for -data-read-memory-bytes (bug 322658) + * John Dallaway - memory cache update fix (bug 387688) *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service; @@ -829,12 +830,20 @@ public class MIMemory extends AbstractDsfService implements IMemory, ICachingSer System.arraycopy(modBlock, 0, cachedBlock.fBlock, pos, count); } + // Case where the cached block is completely included in the modified block + else if (modBlockStart.distanceTo(cachedBlockStart).longValue() >= 0 + && cachedBlockEnd.distanceTo(modBlockEnd).longValue() >= 0) + { + int pos = (int) modBlockStart.distanceTo(cachedBlockStart).longValue(); + System.arraycopy(modBlock, pos, cachedBlock.fBlock, 0, (int) cachedBlock.fLength); + } + // Case where the beginning of the modified block is within the cached block else if (cachedBlockStart.distanceTo(modBlockStart).longValue() >= 0 && modBlockStart.distanceTo(cachedBlockEnd).longValue() > 0) { int pos = (int) cachedBlockStart.distanceTo(modBlockStart).longValue(); - int length = (int) cachedBlockStart.distanceTo(modBlockEnd).longValue(); + int length = (int) modBlockStart.distanceTo(cachedBlockEnd).longValue(); System.arraycopy(modBlock, 0, cachedBlock.fBlock, pos, length); }