updated to mspsims new watchpoint api

This commit is contained in:
Fredrik Osterlind 2012-01-26 16:09:31 +01:00
parent 681b40c3c1
commit 5bcb6ad8a5
3 changed files with 47 additions and 53 deletions

View File

@ -67,6 +67,7 @@ public class MspDebugOutput extends Log {
private MspMoteMemory mem;
private String lastLog = null;
private CPUMonitor cpuMonitor = null;
public MspDebugOutput(Mote mote) {
this.mote = (MspMote) mote;
@ -76,8 +77,8 @@ public class MspDebugOutput extends Log {
/* Disabled */
return;
}
this.mote.getCPU().setBreakPoint(mem.getVariableAddress(CONTIKI_POINTER),
new CPUMonitor() {
this.mote.getCPU().addWatchPoint(mem.getVariableAddress(CONTIKI_POINTER),
cpuMonitor = new CPUMonitor() {
public void cpuAction(int type, int adr, int data) {
if (type != MEMORY_WRITE) {
return;
@ -136,6 +137,9 @@ public class MspDebugOutput extends Log {
public void removed() {
super.removed();
/* TODO Remove watchpoint */
if (cpuMonitor != null) {
mote.getCPU().removeWatchPoint(mem.getVariableAddress(CONTIKI_POINTER), cpuMonitor);
}
}
}

View File

@ -64,6 +64,8 @@ public class MspMoteID extends MoteID {
private boolean writeFlashHeader = true;
private int moteID = -1;
private CPUMonitor cpuMonitor;
/**
* Creates an interface to the mote ID at mote.
*
@ -81,61 +83,33 @@ public class MspMoteID extends MoteID {
}
};
cpuMonitor = new CPUMonitor() {
public void cpuAction(int type, int adr, int data) {
if (type != MEMORY_WRITE) {
return;
}
if (data == moteID) {
return;
}
Simulation s = mote.getSimulation();
if (writeIDEvent.isScheduled()) {
return;
}
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
}
};
if (moteMem.variableExists("node_id")) {
this.mote.getCPU().setBreakPoint(moteMem.getVariableAddress("node_id"), new CPUMonitor() {
public void cpuAction(int type, int adr, int data) {
if (type != MEMORY_WRITE) {
return;
}
if (data == moteID) {
return;
}
Simulation s = mote.getSimulation();
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
}
});
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
}
if (moteMem.variableExists("TOS_NODE_ID")) {
this.mote.getCPU().setBreakPoint(moteMem.getVariableAddress("TOS_NODE_ID"), new CPUMonitor() {
public void cpuAction(int type, int adr, int data) {
if (type != MEMORY_WRITE) {
return;
}
if (data == moteID) {
return;
}
Simulation s = mote.getSimulation();
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
}
});
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
}
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
this.mote.getCPU().setBreakPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), new CPUMonitor() {
public void cpuAction(int type, int adr, int data) {
if (type != MEMORY_WRITE) {
return;
}
if (data == moteID) {
return;
}
Simulation s = mote.getSimulation();
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
}
});
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
}
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
this.mote.getCPU().setBreakPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), new CPUMonitor() {
public void cpuAction(int type, int adr, int data) {
if (type != MEMORY_WRITE) {
return;
}
if (data == moteID) {
return;
}
Simulation s = mote.getSimulation();
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
}
});
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
}
}
@ -224,4 +198,20 @@ public class MspMoteID extends MoteID {
}
}
}
public void removed() {
super.removed();
if (moteMem.variableExists("node_id")) {
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
}
if (moteMem.variableExists("TOS_NODE_ID")) {
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
}
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
}
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
}
}
}

View File

@ -128,11 +128,11 @@ public class MspBreakpoint implements Watchpoint {
breakpoints.signalBreakpointTrigger(MspBreakpoint.this);
}
};
mspMote.getCPU().setBreakPoint(address, cpuMonitor);
mspMote.getCPU().addWatchPoint(address, cpuMonitor);
}
public void unregisterBreakpoint() {
mspMote.getCPU().setBreakPoint(address, null);
mspMote.getCPU().removeWatchPoint(address, cpuMonitor);
}
public Collection<Element> getConfigXML() {