private int nextPC;
// The filename if the binary we're running
- private String image;
+ private Object image;
// Register Operations
private final void setFC(boolean b) { fcsr = (fcsr&~0x800000) | (b ? 0x800000 : 0x000000); }
}
// Image loading function
- void loadImage(String file) throws IOException {
- ELF elf = new ELF(file);
+ void loadImage(Object file) throws IOException {
+ ELF elf = null;
+ if (file instanceof String) elf = new ELF(new RandomAccessFile((String)file,"r"));
+ else if (file instanceof byte[]) elf = new ELF((byte[])file);
if(elf.header.type != ELF.ELFHeader.ET_EXEC)
throw new IOException("Binary is not an executable");
if(elf.header.machine != ELF.ELFHeader.EM_MIPS)
}
public Interpreter() { }
public Interpreter(String image) throws IOException { loadImage(image); }
+ public Interpreter(byte[] image) throws IOException { loadImage(image); }
// Debug functions
// NOTE: This probably requires a jdk > 1.1, however, it is only used for debugging
String line;
if(image==null) return null;
try {
- Process p = Runtime.getRuntime().exec(new String[]{addr2line,"-e",image,toHex(pc)});
+ Process p = Runtime.getRuntime().exec(new String[]{addr2line,"-e",image.toString(),toHex(pc)});
line = new BufferedReader(new InputStreamReader(p.getInputStream())).readLine();
if(line == null) return null;
while(line.startsWith("../")) line = line.substring(3);