mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bugzilla 293480.
This commit is contained in:
parent
5c8a3a78a4
commit
e2a14c751f
1 changed files with 217 additions and 112 deletions
|
@ -300,6 +300,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromAddress(java.math.BigInteger, long)
|
* @see org.eclipse.debug.core.model.IMemoryBlockExtension#getBytesFromAddress(java.math.BigInteger, long)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("null")
|
||||||
public MemoryByte[] getBytesFromAddress(BigInteger address, long units) throws DebugException {
|
public MemoryByte[] getBytesFromAddress(BigInteger address, long units) throws DebugException {
|
||||||
|
|
||||||
if (isUseCacheData() && fBlockAddress.compareTo(address) == 0 && units * getAddressableSize() <= fBlock.length)
|
if (isUseCacheData() && fBlockAddress.compareTo(address) == 0 && units * getAddressableSize() <= fBlock.length)
|
||||||
|
@ -316,7 +317,43 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
if (fBlock != null && newLength > 0) {
|
if (fBlock != null && newLength > 0) {
|
||||||
switch (fBlockAddress.compareTo(address)) {
|
switch (fBlockAddress.compareTo(address)) {
|
||||||
// Cached block begins before the retrieved block location
|
// Cached block begins before the retrieved block location
|
||||||
// If there is no overlap, there are no bytes to flag
|
//
|
||||||
|
// <--- fLength -------------------------------------------------->
|
||||||
|
// +--------------------------------------------------------------+
|
||||||
|
// | Cached data from previous retrieve |
|
||||||
|
// | |
|
||||||
|
// | <------------------ length ----------------------------->|
|
||||||
|
// | <------------------ newLength --------------------> |
|
||||||
|
// | +-------------------------------------------------+ |
|
||||||
|
// | | | |
|
||||||
|
// | | Newly retrieved data | |
|
||||||
|
// |<-+->+-------------------------------------------------+ |
|
||||||
|
// | | address |
|
||||||
|
// | | |
|
||||||
|
// | +--- bigDistance/distance |
|
||||||
|
// | |
|
||||||
|
// | <------------------ length ----------------------------->|
|
||||||
|
// | <------------------ newLength -------------------------->|
|
||||||
|
// | +--------------------------------------------------------+
|
||||||
|
// | | |
|
||||||
|
// | | Newly retrieved data |
|
||||||
|
// |<-+->+--------------------------------------------------------+
|
||||||
|
// | | address |
|
||||||
|
// | | |
|
||||||
|
// | +--- bigDistance/distance |
|
||||||
|
// | |
|
||||||
|
// | <------------------ length ----------------------------->|
|
||||||
|
// | <------------------ newLength ---------------------------------->
|
||||||
|
// | +---------------------------------------------------------------+
|
||||||
|
// | | |
|
||||||
|
// | | Newly retrieved data |
|
||||||
|
// |<-+->+---------------------------------------------------------------+
|
||||||
|
// | | address |
|
||||||
|
// | | |
|
||||||
|
// | +--- bigDistance/distance |
|
||||||
|
// | |
|
||||||
|
// +--------------------------------------------------------------+
|
||||||
|
// fBlockAddress
|
||||||
case -1:
|
case -1:
|
||||||
{
|
{
|
||||||
// Determine the distance between the cached and the
|
// Determine the distance between the cached and the
|
||||||
|
@ -330,33 +367,99 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
// Here we can reasonably assume that java integers are OK
|
// Here we can reasonably assume that java integers are OK
|
||||||
int distance = bigDistance.intValue();
|
int distance = bigDistance.intValue();
|
||||||
int length = fLength - distance;
|
int length = fLength - distance;
|
||||||
|
if ( length > newLength ) {
|
||||||
|
length = newLength;
|
||||||
|
}
|
||||||
|
|
||||||
// Work by cells of 4 bytes
|
// Work by cells of 4 bytes
|
||||||
for (int i = 0; i < length; i += 4) {
|
for (int i = 0; i < length && i + 4 < newLength; i += 4) {
|
||||||
// Determine if any byte within the cell was modified
|
// Determine if any byte within the cell was modified
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (int j = i; j < (i + 4) && j < length; j++) {
|
for (int j = i; j < (i + 4) && j < length; j++) {
|
||||||
if ( j < fBlock.length ) {
|
if ( j < newLength ) {
|
||||||
newBlock[j].setFlags(fBlock[distance + j].getFlags());
|
newBlock[j].setFlags(fBlock[distance + j].getFlags());
|
||||||
if (newBlock[j].getValue() != fBlock[distance + j].getValue())
|
if (newBlock[j].getValue() != fBlock[distance + j].getValue()) {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// If so, flag the whole cell as modified
|
// If so, flag the whole cell as modified
|
||||||
if (changed)
|
if (changed) {
|
||||||
for (int j = i; j < (i + 4) && j < length; j++) {
|
for (int j = i; j < (i + 4) && j < length; j++) {
|
||||||
|
if ( j < newLength ) {
|
||||||
newBlock[j].setHistoryKnown(true);
|
newBlock[j].setHistoryKnown(true);
|
||||||
newBlock[j].setChanged(true);
|
newBlock[j].setChanged(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cached block begins before the retrieved block location
|
// The cached block starts at the same address as the retrieved data
|
||||||
// If there is no overlap, there are no bytes to flag
|
// or it starts after the retrieved block and the retrieved block runs
|
||||||
// (this block of code is symmetric with the previous one)
|
// in to it.
|
||||||
|
//
|
||||||
|
// Case 0:
|
||||||
|
//
|
||||||
|
// <--- fLength -------------------------------------------------->
|
||||||
|
// +--------------------------------------------------------------+
|
||||||
|
// | Cached data from previous retrieve |
|
||||||
|
// | |
|
||||||
|
// |<-- length ----------------> |
|
||||||
|
// |<-- newLength -------------> |
|
||||||
|
// +---------------------------+ |
|
||||||
|
// | | |
|
||||||
|
// | Newly retrieve data | |
|
||||||
|
// +---------------------------+ |
|
||||||
|
// |address |
|
||||||
|
// | |
|
||||||
|
// |<--------------------- length ------------------------------->|
|
||||||
|
// |<--------------------- newLength ---------------------------->|
|
||||||
|
// +--------------------------------------------------------------+
|
||||||
|
// | |
|
||||||
|
// | Newly retrieve data |
|
||||||
|
// +--------------------------------------------------------------+
|
||||||
|
// |address |
|
||||||
|
// | |
|
||||||
|
// +--------------------------------------------------------------+
|
||||||
|
// fBlockAddress
|
||||||
|
// bigDistance/distance = 0
|
||||||
|
//
|
||||||
|
// Case 1:
|
||||||
|
// <--- fLength -------------------------------------------------->
|
||||||
|
// +--------------------------------------------------------------+
|
||||||
|
// | Cached data from previous retrieve |
|
||||||
|
// | |
|
||||||
|
// |<-- length -----> |
|
||||||
|
// <-- newLength ----------> |
|
||||||
|
// +-----------------------+ |
|
||||||
|
// | | |
|
||||||
|
// | Newly retrieved data | |
|
||||||
|
// +-----------------------+ |
|
||||||
|
// address| |
|
||||||
|
// | |
|
||||||
|
// |<----------------------- length ----------------------------->|
|
||||||
|
// <------------------------------- newLength -------------------------->|
|
||||||
|
// +---------------------------------------------------------------------+
|
||||||
|
// | |
|
||||||
|
// | Newly retrieved data |
|
||||||
|
// +---------------------------------------------------------------------+
|
||||||
|
// address| |
|
||||||
|
// | |
|
||||||
|
// |<----------------------- length ----------------------------->|
|
||||||
|
// <------------------------------- newLength --------------------------------->
|
||||||
|
// +---------------------------------------------------------------------------+
|
||||||
|
// | |
|
||||||
|
// | Newly retrieved data |
|
||||||
|
// +---------------------------------------------------------------------------+
|
||||||
|
// address| |
|
||||||
|
// <--+-->| |
|
||||||
|
// | +--------------------------------------------------------------+
|
||||||
|
// | fBlockAddress
|
||||||
|
// +---bigDistance/distance
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
|
@ -371,26 +474,33 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
// Here we can reasonably assume that java integers are OK
|
// Here we can reasonably assume that java integers are OK
|
||||||
int distance = bigDistance.intValue();
|
int distance = bigDistance.intValue();
|
||||||
int length = newLength - distance;
|
int length = newLength - distance;
|
||||||
|
if ( length > fBlock.length ) {
|
||||||
|
length = fBlock.length;
|
||||||
|
}
|
||||||
|
|
||||||
// Work by cells of 4 bytes
|
// Work by cells of 4 bytes
|
||||||
for (int i = 0; i < length; i += 4) {
|
for (int i = 0; i < length && distance + i + 4 < newLength; i += 4) {
|
||||||
// Determine if any byte within the cell was modified
|
// Determine if any byte within the cell was modified
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (int j = i; j < (i + 4) && j < length; j++) {
|
for (int j = i; j < (i + 4) && j < length; j++) {
|
||||||
if ( j < fBlock.length ) {
|
if ( ( distance + j ) < newLength ) {
|
||||||
newBlock[distance + j].setFlags(fBlock[j].getFlags());
|
newBlock[distance + j].setFlags(fBlock[j].getFlags());
|
||||||
if (newBlock[distance + j].getValue() != fBlock[j].getValue())
|
if (newBlock[distance + j].getValue() != fBlock[j].getValue()) {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// If so, flag the whole cell as modified
|
// If so, flag the whole cell as modified
|
||||||
if (changed)
|
if (changed) {
|
||||||
for (int j = i; j < (i + 4) && j < length; j++) {
|
for (int j = i; j < (i + 4) && j < length; j++) {
|
||||||
|
if ( ( distance + j ) < newLength ) {
|
||||||
newBlock[distance + j].setHistoryKnown(true);
|
newBlock[distance + j].setHistoryKnown(true);
|
||||||
newBlock[distance + j].setChanged(true);
|
newBlock[distance + j].setChanged(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +632,6 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
else {
|
else {
|
||||||
drm.done();
|
drm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fRetrieval.getExecutor().execute(query);
|
fRetrieval.getExecutor().execute(query);
|
||||||
|
@ -530,13 +639,9 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
try {
|
try {
|
||||||
return query.get();
|
return query.get();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR,
|
throw new DebugException(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Error reading memory block (InterruptedException)", e)); //$NON-NLS-1$
|
||||||
DsfPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
|
|
||||||
"Error reading memory block (InterruptedException)", e)); //$NON-NLS-1$
|
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR,
|
throw new DebugException(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Error reading memory block (ExecutionException)", e)); //$NON-NLS-1$
|
||||||
DsfPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
|
|
||||||
"Error reading memory block (ExecutionException)", e)); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue