X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fmips%2FInterpreter.java;h=a957297f1ac11efff4d05237e6cb771ca3551f72;hb=38786988d12f2c48a314ee37c326965ff0bcadb6;hp=81aa042cb80ae4607b623445e0a7f174f221b282;hpb=4923e8529bbd51d0d03387d2f08ae08b38d5ef4a;p=org.ibex.core.git diff --git a/src/org/xwt/mips/Interpreter.java b/src/org/xwt/mips/Interpreter.java index 81aa042..a957297 100644 --- a/src/org/xwt/mips/Interpreter.java +++ b/src/org/xwt/mips/Interpreter.java @@ -26,7 +26,7 @@ public class Interpreter extends VM { 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); } @@ -614,8 +614,10 @@ public class Interpreter extends VM { } // 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) @@ -662,6 +664,7 @@ public class Interpreter extends VM { } 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 @@ -670,7 +673,7 @@ public class Interpreter extends VM { 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);