new watchpoint api, and method that allows for manipulating simulation time without affecting the
mote execution
This commit is contained in:
parent
5bcb6ad8a5
commit
caade67d62
1 changed files with 13 additions and 48 deletions
|
@ -299,6 +299,15 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||||
*/
|
*/
|
||||||
protected abstract boolean initEmulator(File ELFFile);
|
protected abstract boolean initEmulator(File ELFFile);
|
||||||
|
|
||||||
|
private boolean booted = false;
|
||||||
|
|
||||||
|
public void simTimeChanged(long diff) {
|
||||||
|
/* Compensates for simulation time changes (without simulation execution) */
|
||||||
|
lastExecute -= diff;
|
||||||
|
nextExecute -= diff;
|
||||||
|
scheduleNextWakeup(nextExecute);
|
||||||
|
}
|
||||||
|
|
||||||
private long lastExecute = -1; /* Last time mote executed */
|
private long lastExecute = -1; /* Last time mote executed */
|
||||||
private long nextExecute;
|
private long nextExecute;
|
||||||
public void execute(long time) {
|
public void execute(long time) {
|
||||||
|
@ -306,10 +315,11 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||||
}
|
}
|
||||||
public void execute(long t, int duration) {
|
public void execute(long t, int duration) {
|
||||||
/* Wait until mote boots */
|
/* Wait until mote boots */
|
||||||
if (myMoteInterfaceHandler.getClock().getTime() < 0) {
|
if (!booted && myMoteInterfaceHandler.getClock().getTime() < 0) {
|
||||||
scheduleNextWakeup(t - myMoteInterfaceHandler.getClock().getTime());
|
scheduleNextWakeup(t - myMoteInterfaceHandler.getClock().getTime());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
booted = true;
|
||||||
|
|
||||||
if (stopNextInstruction) {
|
if (stopNextInstruction) {
|
||||||
stopNextInstruction = false;
|
stopNextInstruction = false;
|
||||||
|
@ -524,20 +534,6 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||||
/*return executeCLICommand("line " + myCpu.reg[MSP430Constants.PC]);*/
|
/*return executeCLICommand("line " + myCpu.reg[MSP430Constants.PC]);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MultiCPUMonitor implements CPUMonitor {
|
|
||||||
private ArrayList<CPUMonitor> ms = new ArrayList<CPUMonitor>();
|
|
||||||
public void add(CPUMonitor m) {
|
|
||||||
ms.add(m);
|
|
||||||
}
|
|
||||||
public void remove(CPUMonitor m) {
|
|
||||||
ms.remove(m);
|
|
||||||
}
|
|
||||||
public void cpuAction(int type, int adr, int data) {
|
|
||||||
for (CPUMonitor m: ms) {
|
|
||||||
m.cpuAction(type, adr, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public MemoryMonitor createMemoryMonitor(final MemoryEventHandler meh) {
|
public MemoryMonitor createMemoryMonitor(final MemoryEventHandler meh) {
|
||||||
return new MemoryMonitor() {
|
return new MemoryMonitor() {
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
|
@ -568,24 +564,8 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO Make sure no other part of Cooja overrides this! */
|
/* TODO Make sure no other part of Cooja overrides this! */
|
||||||
|
|
||||||
for (int a = address; a < address+size; a++) {
|
for (int a = address; a < address+size; a++) {
|
||||||
if (myCpu.hasBreakPoint(a)) {
|
myCpu.addWatchPoint(a, myMonitor);
|
||||||
if (myCpu.breakPoints[a] instanceof MultiCPUMonitor) {
|
|
||||||
/* Extend */
|
|
||||||
((MultiCPUMonitor)myCpu.breakPoints[a]).add(myMonitor);
|
|
||||||
} else {
|
|
||||||
/* Create multi and replace */
|
|
||||||
CPUMonitor existingMonitor = myCpu.breakPoints[a];
|
|
||||||
MultiCPUMonitor multiMonitor = new MultiCPUMonitor();
|
|
||||||
multiMonitor.add(existingMonitor);
|
|
||||||
multiMonitor.add(myMonitor);
|
|
||||||
myCpu.clearBreakPoint(a);
|
|
||||||
myCpu.setBreakPoint(a, multiMonitor);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
myCpu.setBreakPoint(a, myMonitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.address = address;
|
this.address = address;
|
||||||
|
@ -600,22 +580,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||||
started = false;
|
started = false;
|
||||||
|
|
||||||
for (int a = address; a < address+size; a++) {
|
for (int a = address; a < address+size; a++) {
|
||||||
if (!myCpu.hasBreakPoint(a)) {
|
myCpu.removeWatchPoint(a, myMonitor);
|
||||||
logger.fatal("Memory breakpoint was previously removed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myCpu.breakPoints[a] instanceof MultiCPUMonitor) {
|
|
||||||
/* Remove */
|
|
||||||
((MultiCPUMonitor)myCpu.breakPoints[a]).remove(myMonitor);
|
|
||||||
} else {
|
|
||||||
/* Clear */
|
|
||||||
if (myCpu.breakPoints[a] != myMonitor) {
|
|
||||||
logger.fatal("Memory breakpoint is not mine");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
myCpu.clearBreakPoint(a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Mote getMote() {
|
public Mote getMote() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue