1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

2005-01-10 Mikhail Khodjaiants

PR 82601 changes to the memory block interface
	* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/ICDIMemoryBlock.java
	* mi/org/eclipse/cdt/debug/mi/core/output/MIMemory.java
This commit is contained in:
Alain Magloire 2005-01-11 20:46:19 +00:00
parent a502144d5d
commit aea694040c
3 changed files with 79 additions and 13 deletions

View file

@ -1,3 +1,8 @@
2005-01-10 Mikhail Khodjaiants
PR 82601 changes to the memory block interface
* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/ICDIMemoryBlock.java
* mi/org/eclipse/cdt/debug/mi/core/output/MIMemory.java
2005-01-10 Alain Magloire
Fix for PR 82506
* mi/org/eclipse/cdt/debug/mi/core/MISession.java

View file

@ -12,8 +12,6 @@
package org.eclipse.cdt.debug.mi.core.cdi.model;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
@ -39,8 +37,9 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
boolean dirty;
private MIDataReadMemoryInfo mem;
private BigInteger cStartAddress; //cashed start address
private byte[] cBytes; //cashed bytes
private BigInteger cStartAddress; //cached start address
private byte[] cBytes; //cached bytes
private int[] badOffsets;
public MemoryBlock(Target target, String exp, MIDataReadMemoryInfo info) {
super(target);
@ -117,22 +116,53 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
*
*/
private byte[] getBytes(MIDataReadMemoryInfo m) {
byte[] bytes = new byte[0];
// sanity.
if (m == null) {
return bytes;
}
// collect the data
MIMemory[] miMem = m.getMemories();
List aList = new ArrayList();
for (int i = 0; i < miMem.length; i++) {
for (int i = 0; i < miMem.length; ++i) {
long[] data = miMem[i].getData();
for (int j = 0; j < data.length; j++) {
aList.add(new Long(data[j]));
if (data.length > 0) {
int blen = bytes.length;
byte[] newBytes = new byte[blen + data.length];
System.arraycopy(bytes, 0, newBytes, 0, blen);
for (int j = 0; j < data.length; ++j, ++blen) {
newBytes[blen] = (byte)data[j];
}
bytes = newBytes;
}
}
byte[] bytes = new byte[aList.size()];
for (int i = 0; i < aList.size(); i++) {
Long l = (Long)aList.get(i);
bytes[i] = l.byteValue();
}
return bytes;
}
private int[] getBadOffsets(MIDataReadMemoryInfo m) {
int[] offsets = new int[0];
// sanity
if (m == null) {
return offsets;
}
// collect the data
MIMemory[] miMem = m.getMemories();
for (int i = 0; i < miMem.length; i++) {
int[] data = miMem[i].getBadOffsets();
if (data.length > 0) {
int olen = offsets.length;
int[] newOffsets = new int[olen + data.length];
System.arraycopy(offsets, 0, newOffsets, 0, olen);
System.arraycopy(data, 0, newOffsets, olen, data.length);
offsets = newOffsets;
}
}
return offsets;
}
public byte[] getBytes() throws CDIException {
return cBytes;
}
@ -214,4 +244,21 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
refresh();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#getFlags(int)
*/
public synchronized byte getFlags(int offset) {
if (badOffsets == null) {
badOffsets = getBadOffsets(mem);
}
if (badOffsets != null) {
for (int i = 0; i < badOffsets.length; ++i) {
if (badOffsets[i] == offset) {
return VALID;
}
}
}
return 0;
}
}

View file

@ -10,12 +10,16 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.output;
import java.util.ArrayList;
import java.util.List;
/**
* GDB/MI memory parsing.
*/
public class MIMemory {
String addr;
long [] data = new long[0];
List badOffsets = new ArrayList();
String ascii = ""; //$NON-NLS-1$
public MIMemory(MITuple tuple) {
@ -30,6 +34,15 @@ public class MIMemory {
return data;
}
public int[] getBadOffsets() {
int[] data = new int[badOffsets.size()];
for (int i = 0; i < data.length; ++i) {
Integer o = (Integer)badOffsets.get(i);
data[i] = o.intValue();
}
return data;
}
public String getAscii() {
return ascii;
}
@ -85,6 +98,7 @@ public class MIMemory {
try {
data[i] = Long.decode(str.trim()).longValue();
} catch (NumberFormatException e) {
badOffsets.add(new Integer(i));
data[i] = 0;
}
}