bugfixed parsing of files read from mspsim

This commit is contained in:
Fredrik Osterlind 2012-03-28 14:44:59 +02:00
parent 0c94b567b9
commit 4222d0adcd
2 changed files with 34 additions and 37 deletions

View File

@ -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);

View File

@ -407,19 +407,22 @@ 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 + ":/");
if (info == null) {
continue;
}
if (info.getPath() == null && info.getFile() == null) {
continue;
}
if (info.getLine() < 0) {
continue;
}
File file = new File(path, info.getFile());
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) {
@ -434,7 +437,6 @@ public abstract class MspMoteType implements MoteType {
lineToAddrHash.put(info.getLine(), address);
}
}
return fileToLineHash;
}