Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Implementation of the 'SaveMemoryChanges' action.

Implementation of the 'SaveMemoryChanges' action.

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.37
diff -u -r1.37 ChangeLog
--- ChangeLog 30 Oct 2002 16:31:07 -0000 1.37
+++ ChangeLog 30 Oct 2002 21:55:06 -0000
@@ -1,4 +1,9 @@
-2002-10-29 Mikhail Khodjaiants
+2002-10-30 Mikhail Khodjaiants
+ Implementation of the 'SaveMemoryChanges' action.
+ * IFormattedMemoryBlock.java: added the 'saveChanges' method.
+ * CFormattedMemoryBlock.java: implementation of the 'saveChanges' method.

+2002-10-30 Mikhail Khodjaiants
  Fix for bug 25283.
  * CDebugTarget.java: in 'setCurrentThread' method set the 'isCurrent' flag to false for the currently current thread.
 
Index: src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java,v
retrieving revision 1.10
diff -u -r1.10 IFormattedMemoryBlock.java
--- src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java 30 Oct 2002 05:00:01 -0000 1.10
+++ src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java 30 Oct 2002 21:55:06 -0000
@@ -126,4 +126,6 @@
  void setFrozen( boolean frozen );
  
  boolean isDirty();

+ void saveChanges() throws DebugException;
 }
Index: src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java,v
retrieving revision 1.9
diff -u -r1.9 CFormattedMemoryBlock.java
--- src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java 30 Oct 2002 05:00:01 -0000 1.9
+++ src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java 30 Oct 2002 21:55:06 -0000
@@ -6,6 +6,7 @@
 package org.eclipse.cdt.debug.internal.core.model;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@@ -84,8 +85,7 @@
  private char fPaddingChar = '.';
  private List fRows = null;
  private Long[] fChangedAddresses = new Long[0];
- // temporary
- private boolean fIsDirty = false;
+ private boolean[] fDirtyBytes = null;
 
  /**
   * Constructor for CFormattedMemoryBlock.
@@ -199,7 +199,7 @@
  private void resetBytes()
  {
   fBytes = null;
-  fIsDirty = false;
+  fDirtyBytes = null;
  }
 
  private void resetRows()
@@ -305,6 +305,8 @@
     try
     {
      fBytes = fCDIMemoryBlock.getBytes();
+     fDirtyBytes = new boolean[fBytes.length];
+     Arrays.fill( fDirtyBytes, false );
     }
     catch( CDIException e )
     {
@@ -486,7 +488,7 @@
  {
   byte[] bytes = itemToBytes( newValue.toCharArray() );
   setBytes( index * getWordSize(), bytes );
-  fIsDirty = true;
+  Arrays.fill( fDirtyBytes, index * getWordSize(), index * getWordSize() + bytes.length, true );
   resetRows();
  }
  
@@ -530,6 +532,56 @@
   */
  public boolean isDirty()
  {
-  return fIsDirty;
+  if ( fDirtyBytes != null )
+  {
+   for ( int i = 0; i < fDirtyBytes.length; ++i )
+   {
+    if ( fDirtyBytes[i] )
+     return true;
+   }
+  }
+  return false;
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.core.IFormattedMemoryBlock#saveChanges()
+  */
+ public void saveChanges() throws DebugException
+ {
+  if ( getBytes() != null && fDirtyBytes != null && getCDIMemoryBlock() != null )
+  {
+   int startIndex = -1;
+   for ( int i = 0; i < fDirtyBytes.length; ++i )
+   {
+    if ( fDirtyBytes[i] )
+    {
+     if ( startIndex == -1 )
+     {
+      startIndex = i;
+     }
+    }
+    else
+    {
+     if ( startIndex != -1 )
+     {
+      byte[] bytes = new byte[i - startIndex];
+      for ( int j = startIndex; j < i; ++j )
+      {
+       bytes[j - startIndex] = getBytes()[j];
+      }
+      try
+      {
+       getCDIMemoryBlock().setValue( startIndex, bytes );
+       startIndex = -1;
+      }
+      catch( CDIException e )
+      {
+       targetRequestFailed( e.getMessage(), null );
+      }
+     }
+    }
+   }
+   Arrays.fill( fDirtyBytes, false );
+  }
  }
 }


Back to the top