mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implememnt setValue().
This commit is contained in:
parent
d05df2d9de
commit
1a7d9c7c71
2 changed files with 40 additions and 2 deletions
|
@ -5,7 +5,13 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.MIFormat;
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIDataWriteMemory;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataReadMemoryInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIMemory;
|
||||
|
||||
/**
|
||||
|
@ -120,7 +126,23 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#setValue(long, byte[])
|
||||
*/
|
||||
public void setValue(long offset, byte[] bytes) throws CDIException {
|
||||
throw new CDIException("Not supported");
|
||||
MISession mi = getCTarget().getCSession().getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
long l = new Byte(bytes[i]).longValue();
|
||||
String value = "0x" + Long.toHexString(l);
|
||||
MIDataWriteMemory mem = factory.createMIDataWriteMemory(offset + i,
|
||||
expression, MIFormat.HEXADECIMAL, 1, value);
|
||||
try {
|
||||
mi.postCommand(mem);
|
||||
MIInfo info = mem.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ import org.eclipse.cdt.debug.mi.core.MIFormat;
|
|||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterValues;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIDataWriteRegisterValues;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIDataListRegisterValuesInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIRegisterValue;
|
||||
|
||||
/**
|
||||
|
@ -198,7 +200,21 @@ public class Register extends CObject implements ICDIRegister, ICDIValue {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(String)
|
||||
*/
|
||||
public void setValue(String expression) throws CDIException {
|
||||
throw new CDIException("Register setting is not supported");
|
||||
MISession mi = getCTarget().getCSession().getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
int[] regnos = new int[]{((RegisterObject)regObject).getId()};
|
||||
String[] values = new String[]{expression};
|
||||
MIDataWriteRegisterValues registers =
|
||||
factory.createMIDataWriteRegisterValues(format, regnos, values);
|
||||
try {
|
||||
mi.postCommand(registers);
|
||||
MIInfo info = registers.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue