temporary fix for catching new emulationexception

This commit is contained in:
fros4943 2009-03-12 17:47:57 +00:00
parent a27ec1bbef
commit 536af1381a
2 changed files with 31 additions and 16 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MspMote.java,v 1.22 2009/03/09 17:12:27 fros4943 Exp $ * $Id: MspMote.java,v 1.23 2009/03/12 17:47:58 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote; package se.sics.cooja.mspmote;
@ -51,6 +51,7 @@ import se.sics.cooja.mspmote.interfaces.TR1001Radio;
import se.sics.mspsim.cli.CommandHandler; import se.sics.mspsim.cli.CommandHandler;
import se.sics.mspsim.cli.LineListener; import se.sics.mspsim.cli.LineListener;
import se.sics.mspsim.cli.LineOutputStream; import se.sics.mspsim.cli.LineOutputStream;
import se.sics.mspsim.core.EmulationException;
import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.MSP430;
import se.sics.mspsim.platform.GenericNode; import se.sics.mspsim.platform.GenericNode;
import se.sics.mspsim.util.ConfigManager; import se.sics.mspsim.util.ConfigManager;
@ -327,7 +328,12 @@ public abstract class MspMote implements Mote {
} }
myMoteInterfaceHandler.doActiveActionsBeforeTick(); myMoteInterfaceHandler.doActiveActionsBeforeTick();
cpu.step(cycleCounter); try {
cpu.step(cycleCounter);
} catch (EmulationException e) {
throw (RuntimeException)
new RuntimeException("Emulated exception: " + e.getMessage()).initCause(e);
}
/* Check if radio has pending incoming bytes */ /* Check if radio has pending incoming bytes */
if (myRadio != null && myRadio.hasPendingBytes()) { if (myRadio != null && myRadio.hasPendingBytes()) {

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MspCodeWatcher.java,v 1.15 2009/03/12 15:12:23 fros4943 Exp $ * $Id: MspCodeWatcher.java,v 1.16 2009/03/12 17:47:57 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote.plugins; package se.sics.cooja.mspmote.plugins;
@ -52,6 +52,7 @@ import se.sics.cooja.*;
import se.sics.cooja.mspmote.MspMote; import se.sics.cooja.mspmote.MspMote;
import se.sics.cooja.mspmote.MspMoteType; import se.sics.cooja.mspmote.MspMoteType;
import se.sics.mspsim.core.CPUMonitor; import se.sics.mspsim.core.CPUMonitor;
import se.sics.mspsim.core.EmulationException;
import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.MSP430;
import se.sics.mspsim.core.MSP430Core; import se.sics.mspsim.core.MSP430Core;
import se.sics.mspsim.ui.DebugUI; import se.sics.mspsim.ui.DebugUI;
@ -190,7 +191,11 @@ public class MspCodeWatcher extends VisPlugin {
stepButton.addActionListener(new ActionListener() { stepButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Perform single step here // TODO Perform single step here
mspMote.getCPU().step(mspMote.getCPU().cycles+1); try {
mspMote.getCPU().step(mspMote.getCPU().cycles+1);
} catch (EmulationException e1) {
logger.fatal("Error: ", e1);
}
updateInfo(); updateInfo();
} }
}); });
@ -223,20 +228,24 @@ public class MspCodeWatcher extends VisPlugin {
return; return;
} }
while (count++ < max) { try {
cpu.step(mspMote.getCPU().cycles+1); while (count++ < max) {
pc = cpu.readRegister(MSP430Core.PC); cpu.step(mspMote.getCPU().cycles+1);
instruction = cpu.memory[pc] + (cpu.memory[pc + 1] << 8); pc = cpu.readRegister(MSP430Core.PC);
if ((instruction & 0xff80) == MSP430.CALL) { instruction = cpu.memory[pc] + (cpu.memory[pc + 1] << 8);
depth++; if ((instruction & 0xff80) == MSP430.CALL) {
} else if (instruction == MSP430.RETURN) { depth++;
depth--; } else if (instruction == MSP430.RETURN) {
if (depth < 0) { depth--;
updateInfo(); if (depth < 0) {
return; updateInfo();
} return;
}
}
} }
} catch (EmulationException e1) {
logger.fatal("Error: ", e1);
} }
logger.fatal("Function '" + functionName + "' did not return within " + max + " instructions"); logger.fatal("Function '" + functionName + "' did not return within " + max + " instructions");