mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implementation of the 'SaveMemoryChanges' action.
This commit is contained in:
parent
d54c3caff1
commit
f5a02f5aab
3 changed files with 65 additions and 6 deletions
|
@ -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.
|
Fix for bug 25283.
|
||||||
* CDebugTarget.java: in 'setCurrentThread' method set the 'isCurrent' flag to false for the currently current thread.
|
* CDebugTarget.java: in 'setCurrentThread' method set the 'isCurrent' flag to false for the currently current thread.
|
||||||
|
|
||||||
|
|
|
@ -126,4 +126,6 @@ public interface IFormattedMemoryBlock extends IMemoryBlock
|
||||||
void setFrozen( boolean frozen );
|
void setFrozen( boolean frozen );
|
||||||
|
|
||||||
boolean isDirty();
|
boolean isDirty();
|
||||||
|
|
||||||
|
void saveChanges() throws DebugException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
package org.eclipse.cdt.debug.internal.core.model;
|
package org.eclipse.cdt.debug.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
|
@ -84,8 +85,7 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
private char fPaddingChar = '.';
|
private char fPaddingChar = '.';
|
||||||
private List fRows = null;
|
private List fRows = null;
|
||||||
private Long[] fChangedAddresses = new Long[0];
|
private Long[] fChangedAddresses = new Long[0];
|
||||||
// temporary
|
private boolean[] fDirtyBytes = null;
|
||||||
private boolean fIsDirty = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CFormattedMemoryBlock.
|
* Constructor for CFormattedMemoryBlock.
|
||||||
|
@ -199,7 +199,7 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
private void resetBytes()
|
private void resetBytes()
|
||||||
{
|
{
|
||||||
fBytes = null;
|
fBytes = null;
|
||||||
fIsDirty = false;
|
fDirtyBytes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetRows()
|
private void resetRows()
|
||||||
|
@ -305,6 +305,8 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fBytes = fCDIMemoryBlock.getBytes();
|
fBytes = fCDIMemoryBlock.getBytes();
|
||||||
|
fDirtyBytes = new boolean[fBytes.length];
|
||||||
|
Arrays.fill( fDirtyBytes, false );
|
||||||
}
|
}
|
||||||
catch( CDIException e )
|
catch( CDIException e )
|
||||||
{
|
{
|
||||||
|
@ -486,7 +488,7 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
{
|
{
|
||||||
byte[] bytes = itemToBytes( newValue.toCharArray() );
|
byte[] bytes = itemToBytes( newValue.toCharArray() );
|
||||||
setBytes( index * getWordSize(), bytes );
|
setBytes( index * getWordSize(), bytes );
|
||||||
fIsDirty = true;
|
Arrays.fill( fDirtyBytes, index * getWordSize(), index * getWordSize() + bytes.length, true );
|
||||||
resetRows();
|
resetRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,6 +532,56 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public boolean isDirty()
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue