mirror of https://github.com/contiki-ng/mspsim
Merge pull request #22 from nfi/Java7
Fix single step (GUI) to work again. Update build to use Java 7.
This commit is contained in:
commit
e1ce900b31
7
Makefile
7
Makefile
|
|
@ -2,7 +2,7 @@
|
|||
# Makefile for mspsim
|
||||
#
|
||||
# Needed stuff in the PATH:
|
||||
# java, javac (JDK 1.6 or newer)
|
||||
# java, javac (JDK 1.7 or newer)
|
||||
#
|
||||
# Under MS-DOS/Windows
|
||||
# A GNU compatible Make (for example Cygwin's)
|
||||
|
|
@ -46,7 +46,7 @@ SPACE := ${EMPTY} ${EMPTY}
|
|||
LIBS := ${wildcard lib/*.jar}
|
||||
BUILD := build
|
||||
CLASSPATH=${subst ${SPACE},${SEPARATOR},$(BUILD)/ ${LIBS}}
|
||||
CCARGS=-deprecation -classpath ".${SEPARATOR}${CLASSPATH}" -d $(BUILD)
|
||||
CCARGS=-deprecation -Xlint:unchecked -source 1.7 -target 1.7 -classpath ".${SEPARATOR}${CLASSPATH}" -d $(BUILD)
|
||||
|
||||
JAVAARGS=-classpath "${CLASSPATH}"
|
||||
|
||||
|
|
@ -196,3 +196,6 @@ $(BUILD)/%.class : %.java $(BUILD)
|
|||
|
||||
clean:
|
||||
-$(RM) -r $(BUILD)
|
||||
|
||||
distclean: clean
|
||||
-$(RM) -f $(JARFILE)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@ some tools for monitoring stack, setting breakpoints, and profiling.
|
|||
|
||||
* System requirements
|
||||
|
||||
You need a recent Java to run MSPSim. Java SE 1.5 or newer is
|
||||
recommended. The current version of MSPSim also requires make for
|
||||
compiling.
|
||||
You need a recent Java to run MSPSim. Java SE 1.7 or newer is recommended.
|
||||
The current version of MSPSim also requires make or ant for compiling.
|
||||
|
||||
* Building MSPSim
|
||||
|
||||
|
|
@ -60,4 +59,4 @@ Run the default example on the Sky node emulator by typing:
|
|||
- currently the emulator runs as if it can use all memory as RAM
|
||||
(e.g. flash writes, etc not supported)
|
||||
- no DMA implementation
|
||||
- timer system not 100% emulated
|
||||
- timer system not 100% emulated
|
||||
|
|
|
|||
10
build.xml
10
build.xml
|
|
@ -8,6 +8,8 @@
|
|||
<property name="lib" location="lib"/>
|
||||
<property name="jarfile" location="mspsim.jar"/>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="ant.build.javac.source" value="1.7"/>
|
||||
<property name="ant.build.javac.target" value="1.7"/>
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="${lib}" includes="**/*.jar"/>
|
||||
|
|
@ -23,8 +25,12 @@
|
|||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="compile the source">
|
||||
<javac srcdir="${src}" destdir="${build}" classpathref="classpath" debug="${javac.debug}"
|
||||
includeantruntime="false"/>
|
||||
<javac srcdir="${src}" destdir="${build}" classpathref="classpath"
|
||||
debug="${javac.debug}" includeantruntime="false">
|
||||
<compilerarg value="-Xlint:unchecked"/>
|
||||
<compilerarg value="-deprecation"/>
|
||||
<exclude name="tests/**" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="generate MSPSim jar file" >
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import java.io.PrintStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import se.sics.mspsim.core.EmulationException;
|
||||
import se.sics.mspsim.util.ActiveComponent;
|
||||
import se.sics.mspsim.util.ComponentRegistry;
|
||||
|
|
@ -32,7 +31,7 @@ public class CommandHandler implements ActiveComponent, LineListener {
|
|||
|
||||
private MapTable getMapTable() {
|
||||
if (mapTable == null && registry != null) {
|
||||
mapTable = (MapTable) registry.getComponent(MapTable.class);
|
||||
mapTable = registry.getComponent(MapTable.class);
|
||||
}
|
||||
return mapTable;
|
||||
}
|
||||
|
|
@ -42,6 +41,7 @@ public class CommandHandler implements ActiveComponent, LineListener {
|
|||
commands.put(cmd, command);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public int executeCommand(String commandLine, CommandContext context) {
|
||||
String[][] parts;
|
||||
final PrintStream cOut = context == null ? this.out : context.out;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@
|
|||
* Created : 17 jan 2008
|
||||
*/
|
||||
package se.sics.mspsim.core;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import se.sics.mspsim.core.EmulationLogger.WarningType;
|
||||
import se.sics.mspsim.util.ArrayUtils;
|
||||
|
||||
|
|
@ -63,7 +61,6 @@ public abstract class Chip implements Loggable, EventSource {
|
|||
private int mode;
|
||||
private int chipState;
|
||||
protected EmulationLogger logger;
|
||||
private PrintStream log;
|
||||
protected boolean DEBUG = false;
|
||||
protected int logLevel;
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ public class MSP430 extends MSP430Core {
|
|||
isStopping = isBreaking = false;
|
||||
}
|
||||
|
||||
public long step() throws EmulationException {
|
||||
/* Use stepInstructions or stepMicros instead */
|
||||
@Deprecated public long step() throws EmulationException {
|
||||
return stepMicros(1, 1);
|
||||
}
|
||||
|
||||
|
|
@ -156,16 +157,18 @@ public class MSP430 extends MSP430Core {
|
|||
}
|
||||
setRunning(true);
|
||||
try {
|
||||
while (count-- > 0 && !isStopping) {
|
||||
while (count > 0 && !isStopping) {
|
||||
int pc = emulateOP(-1);
|
||||
if (pc >= 0) {
|
||||
count--;
|
||||
if (execCounter != null) {
|
||||
execCounter[pc]++;
|
||||
}
|
||||
if (trace != null) {
|
||||
trace[tracePos++] = pc;
|
||||
if (tracePos >= trace.length)
|
||||
tracePos = 0;
|
||||
if (tracePos >= trace.length) {
|
||||
tracePos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -324,9 +324,8 @@ public class EmuLink {
|
|||
}
|
||||
}
|
||||
|
||||
public void run() throws IOException {
|
||||
try {
|
||||
ServerSocket serverSocket = new ServerSocket(8000);
|
||||
public void run() {
|
||||
try (ServerSocket serverSocket = new ServerSocket(8000)) {
|
||||
|
||||
while(true) {
|
||||
|
||||
|
|
@ -356,7 +355,7 @@ public class EmuLink {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
public static void main(String[] args) {
|
||||
EmuLink el = new EmuLink();
|
||||
el.run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@ import java.io.IOException;
|
|||
import java.io.PrintStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import se.sics.mspsim.cli.CommandHandler;
|
||||
import se.sics.mspsim.cli.DebugCommands;
|
||||
import se.sics.mspsim.cli.FileCommands;
|
||||
|
|
@ -54,7 +52,6 @@ import se.sics.mspsim.cli.StreamCommandHandler;
|
|||
import se.sics.mspsim.cli.WindowCommands;
|
||||
import se.sics.mspsim.core.Chip;
|
||||
import se.sics.mspsim.core.EmulationException;
|
||||
import se.sics.mspsim.core.EmulationLogger;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
import se.sics.mspsim.core.MSP430Constants;
|
||||
|
|
@ -67,7 +64,6 @@ import se.sics.mspsim.ui.WindowUtils;
|
|||
import se.sics.mspsim.util.ArgumentManager;
|
||||
import se.sics.mspsim.util.ComponentRegistry;
|
||||
import se.sics.mspsim.util.ConfigManager;
|
||||
import se.sics.mspsim.util.DefaultEmulationLogger;
|
||||
import se.sics.mspsim.util.ELF;
|
||||
import se.sics.mspsim.util.IHexReader;
|
||||
import se.sics.mspsim.util.MapTable;
|
||||
|
|
@ -276,11 +272,9 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
public void stop() {
|
||||
cpu.stop();
|
||||
}
|
||||
|
||||
|
||||
public void step() throws EmulationException {
|
||||
if (!cpu.isRunning()) {
|
||||
cpu.step();
|
||||
}
|
||||
step(1);
|
||||
}
|
||||
|
||||
// A step that will break out of breakpoints!
|
||||
|
|
|
|||
|
|
@ -47,19 +47,19 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import se.sics.mspsim.core.*;
|
||||
import se.sics.mspsim.core.DbgInstruction;
|
||||
import se.sics.mspsim.core.DisAsm;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.util.Utils;
|
||||
|
||||
public class DebugUI extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 2123628878332126912L;
|
||||
|
||||
private JList disList;
|
||||
private JList<DbgInstruction> disList;
|
||||
private DbgListModel listModel;
|
||||
private JLabel[] regsLabel;
|
||||
private MSP430 cpu;
|
||||
private DbgListModel listModel;
|
||||
private int currentAddress = 0;
|
||||
|
||||
private DisAsm disAsm;
|
||||
|
||||
|
|
@ -76,7 +76,8 @@ public class DebugUI extends JPanel {
|
|||
this.cpu = cpu;
|
||||
disAsm = cpu.getDisAsm();
|
||||
|
||||
disList = new JList(listModel = new DbgListModel());
|
||||
listModel = new DbgListModel();
|
||||
disList = new JList<DbgInstruction>(listModel);
|
||||
disList.setFont(new Font("courier", 0, 12));
|
||||
disList.setCellRenderer(new MyCellRenderer());
|
||||
disList.setPreferredSize(new Dimension(500, 350));
|
||||
|
|
@ -102,7 +103,7 @@ public class DebugUI extends JPanel {
|
|||
repaint();
|
||||
}
|
||||
|
||||
private class DbgListModel extends AbstractListModel {
|
||||
private class DbgListModel extends AbstractListModel<DbgInstruction> {
|
||||
private static final long serialVersionUID = -2856626511548201481L;
|
||||
|
||||
int startPos = -1;
|
||||
|
|
@ -111,44 +112,36 @@ public class DebugUI extends JPanel {
|
|||
|
||||
DbgInstruction[] instructions = new DbgInstruction[size];
|
||||
|
||||
// 64K Dbg instructions...
|
||||
// private DbgInstruction[] instrs = new DbgInstruction[0x10000];
|
||||
|
||||
public void setCurrentAddress(int address) {
|
||||
startPos = address;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// ListAPI
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
private void checkPC() {
|
||||
int pc = cpu.reg[MSP430Core.PC];
|
||||
int pc = cpu.getPC();
|
||||
if (pc < startPos || pc > endPos) {
|
||||
startPos = pc;
|
||||
// recalculate index!!! with PC at the top of the "page"
|
||||
int currentPos = pc;
|
||||
DbgInstruction inst;
|
||||
for (int i = 0, n = size; i < n; i++) {
|
||||
if (cpu.getExecCount(currentPos) != 0 || true) {
|
||||
inst = disAsm.getDbgInstruction(currentPos, cpu);
|
||||
inst.setPos(currentPos);
|
||||
currentPos += inst.getSize();
|
||||
} else {
|
||||
inst = new DbgInstruction();
|
||||
inst.setASMLine(" " + Utils.hex16(currentPos) + " " +
|
||||
Utils.hex8(cpu.memory[currentPos]) + " " +
|
||||
Utils.hex8(cpu.memory[currentPos + 1]) +
|
||||
" .word " + Utils.hex8(cpu.memory[currentPos]) +
|
||||
Utils.hex8(cpu.memory[currentPos + 1]));
|
||||
inst.setPos(currentPos);
|
||||
currentPos += 2;
|
||||
}
|
||||
instructions[i] = inst;
|
||||
// if (cpu.getExecCount(currentPos) == 0) {
|
||||
// inst = new DbgInstruction();
|
||||
// inst.setInstruction(cpu.memory[currentPos] + (cpu.memory[currentPos + 1] << 8), 2);
|
||||
// inst.setASMLine(" " + Utils.hex(currentPos, 4) + " " +
|
||||
// Utils.hex8(cpu.memory[currentPos]) + " " +
|
||||
// Utils.hex8(cpu.memory[currentPos + 1]) +
|
||||
// " .word " + Utils.hex8(cpu.memory[currentPos]) +
|
||||
// Utils.hex8(cpu.memory[currentPos + 1]));
|
||||
// } else {
|
||||
|
||||
DbgInstruction inst = disAsm.getDbgInstruction(currentPos, cpu);
|
||||
inst.setPos(currentPos);
|
||||
currentPos += inst.getSize();
|
||||
instructions[i] = inst;
|
||||
}
|
||||
endPos = currentPos;
|
||||
}
|
||||
|
|
@ -157,13 +150,14 @@ public class DebugUI extends JPanel {
|
|||
// Should cache the current 20 (or size) instructions to get a faster
|
||||
// version of this...
|
||||
// And have a call to "update" instead...
|
||||
public Object getElementAt(int index) {
|
||||
@Override
|
||||
public DbgInstruction getElementAt(int index) {
|
||||
checkPC();
|
||||
return instructions[index];
|
||||
}
|
||||
}
|
||||
|
||||
class MyCellRenderer extends JLabel implements ListCellRenderer {
|
||||
class MyCellRenderer extends JLabel implements ListCellRenderer<DbgInstruction> {
|
||||
|
||||
private static final long serialVersionUID = -2633138712695105181L;
|
||||
|
||||
|
|
@ -171,36 +165,32 @@ public class DebugUI extends JPanel {
|
|||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value, // value to display
|
||||
JList<? extends DbgInstruction> list,
|
||||
DbgInstruction instruction, // instruct to display
|
||||
int index, // cell index
|
||||
boolean isSelected, // is the cell selected
|
||||
boolean cellHasFocus) // the list and the cell have the focus
|
||||
{
|
||||
String s;
|
||||
int pos = 0;
|
||||
if (value == null) {
|
||||
s = "---";
|
||||
if (instruction == null) {
|
||||
s = "---";
|
||||
} else {
|
||||
if (value instanceof DbgInstruction) {
|
||||
DbgInstruction i = (DbgInstruction) value;
|
||||
s = i.getASMLine(false);
|
||||
if (i.getFunction() != null) {
|
||||
s += "; " + i.getFunction();
|
||||
}
|
||||
pos = i.getPos();
|
||||
pos = instruction.getPos();
|
||||
s = instruction.getASMLine(false);
|
||||
if (cpu.hasWatchPoint(pos)) {
|
||||
s = "*B " + s;
|
||||
} else {
|
||||
s = " " + s;
|
||||
}
|
||||
} else {
|
||||
s = value.toString();
|
||||
}
|
||||
if (instruction.getFunction() != null) {
|
||||
s += "; " + instruction.getFunction();
|
||||
}
|
||||
}
|
||||
setText(s);
|
||||
if (pos == cpu.reg[MSP430Core.PC]) {
|
||||
if (pos == cpu.getPC()) {
|
||||
setBackground(Color.green);
|
||||
} else {
|
||||
if (isSelected) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue