bugfixed parsing of files read from mspsim
This commit is contained in:
parent
0c94b567b9
commit
4222d0adcd
|
@ -36,7 +36,6 @@ import java.io.IOException;
|
|||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Observable;
|
||||
|
||||
|
@ -582,9 +581,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
|||
/* Match file */
|
||||
Hashtable<Integer, Integer> lineTable = debuggingInfo.get(file);
|
||||
if (lineTable == null) {
|
||||
Enumeration<File> fileEnum = debuggingInfo.keys();
|
||||
while (fileEnum.hasMoreElements()) {
|
||||
File f = fileEnum.nextElement();
|
||||
for (File f: debuggingInfo.keySet()) {
|
||||
if (f != null && f.getName().equals(file.getName())) {
|
||||
lineTable = debuggingInfo.get(f);
|
||||
break;
|
||||
|
@ -598,9 +595,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
|||
/* Match line number */
|
||||
Integer address = lineTable.get(lineNr);
|
||||
if (address != null) {
|
||||
Enumeration<Integer> lineEnum = lineTable.keys();
|
||||
while (lineEnum.hasMoreElements()) {
|
||||
Integer l = lineEnum.nextElement();
|
||||
for (Integer l: lineTable.keySet()) {
|
||||
if (l != null && l.intValue() == lineNr) {
|
||||
/* Found line address */
|
||||
return lineTable.get(l);
|
||||
|
|
|
@ -317,7 +317,7 @@ public abstract class MspMoteType implements MoteType {
|
|||
logger.warn("Old simulation config detected: SkySerial was replaced by MspSerial");
|
||||
intfClass = MspSerial.class.getName();
|
||||
}
|
||||
|
||||
|
||||
Class<? extends MoteInterface> moteInterfaceClass =
|
||||
simulation.getGUI().tryLoadClass(this, MoteInterface.class, intfClass);
|
||||
|
||||
|
@ -368,7 +368,7 @@ public abstract class MspMoteType implements MoteType {
|
|||
private static ELF loadELF(String filepath) throws IOException {
|
||||
return ELF.readELF(filepath);
|
||||
}
|
||||
|
||||
|
||||
private ELF elf; /* cached */
|
||||
public ELF getELF() throws IOException {
|
||||
if (elf == null) {
|
||||
|
@ -379,9 +379,9 @@ public abstract class MspMoteType implements MoteType {
|
|||
}
|
||||
return elf;
|
||||
}
|
||||
|
||||
|
||||
private Hashtable<File, Hashtable<Integer, Integer>> debuggingInfo = null; /* cached */
|
||||
public Hashtable<File, Hashtable<Integer, Integer>> getFirmwareDebugInfo()
|
||||
public Hashtable<File, Hashtable<Integer, Integer>> getFirmwareDebugInfo()
|
||||
throws IOException {
|
||||
if (debuggingInfo == null) {
|
||||
debuggingInfo = getFirmwareDebugInfo(getELF());
|
||||
|
@ -407,33 +407,35 @@ public abstract class MspMoteType implements MoteType {
|
|||
|
||||
for (int address: addresses) {
|
||||
DebugInfo info = elf.getDebugInfo(address);
|
||||
|
||||
if (info != null && info.getPath() != null && info.getFile() != null && info.getLine() >= 0) {
|
||||
|
||||
/* Nasty Cygwin-Windows fix */
|
||||
String path = info.getPath();
|
||||
if (path.contains("/cygdrive/")) {
|
||||
int index = path.indexOf("/cygdrive/");
|
||||
char driveCharacter = path.charAt(index+10);
|
||||
|
||||
path = path.replace("/cygdrive/" + driveCharacter + "/", driveCharacter + ":/");
|
||||
}
|
||||
|
||||
File file = new File(path, info.getFile());
|
||||
try {
|
||||
file = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
} catch (java.security.AccessControlException e) {
|
||||
}
|
||||
|
||||
Hashtable<Integer, Integer> lineToAddrHash = fileToLineHash.get(file);
|
||||
if (lineToAddrHash == null) {
|
||||
lineToAddrHash = new Hashtable<Integer, Integer>();
|
||||
fileToLineHash.put(file, lineToAddrHash);
|
||||
}
|
||||
|
||||
lineToAddrHash.put(info.getLine(), address);
|
||||
if (info == null) {
|
||||
continue;
|
||||
}
|
||||
if (info.getPath() == null && info.getFile() == null) {
|
||||
continue;
|
||||
}
|
||||
if (info.getLine() < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file;
|
||||
if (info.getPath() != null) {
|
||||
file = new File(info.getPath(), info.getFile());
|
||||
} else {
|
||||
file = new File(info.getFile());
|
||||
}
|
||||
try {
|
||||
file = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
} catch (java.security.AccessControlException e) {
|
||||
}
|
||||
|
||||
Hashtable<Integer, Integer> lineToAddrHash = fileToLineHash.get(file);
|
||||
if (lineToAddrHash == null) {
|
||||
lineToAddrHash = new Hashtable<Integer, Integer>();
|
||||
fileToLineHash.put(file, lineToAddrHash);
|
||||
}
|
||||
|
||||
lineToAddrHash.put(info.getLine(), address);
|
||||
}
|
||||
|
||||
return fileToLineHash;
|
||||
|
|
Loading…
Reference in a new issue