improved debugging output

This commit is contained in:
Fredrik Osterlind 2012-05-23 12:27:37 +02:00
parent af62e48103
commit ddef6c6b76
1 changed files with 27 additions and 27 deletions

View File

@ -127,7 +127,7 @@ public class ContikiMoteType implements MoteType {
public enum NetworkStack { public enum NetworkStack {
DEFAULT, MANUAL; DEFAULT, MANUAL;
public String manualHeader = "netstack-conf-example.h"; public String manualHeader = "netstack-conf-example.h";
public String toString() { public String toString() {
if (this == DEFAULT) { if (this == DEFAULT) {
return "Default (from contiki-conf.h)"; return "Default (from contiki-conf.h)";
@ -427,7 +427,7 @@ public class ContikiMoteType implements MoteType {
readonlySectionAddr = -1; readonlySectionAddr = -1;
readonlySectionSize = -1; readonlySectionSize = -1;
} }
} else { } else {
/* Parse command output */ /* Parse command output */
if (mapFile == null || if (mapFile == null ||
@ -459,28 +459,28 @@ public class ContikiMoteType implements MoteType {
if (dataSectionAddr >= 0) { if (dataSectionAddr >= 0) {
logger.info(getContikiFirmwareFile().getName() + logger.info(getContikiFirmwareFile().getName() +
": data section at 0x" + Integer.toHexString(dataSectionAddr) + ": data section at 0x" + Integer.toHexString(dataSectionAddr) +
" (" + dataSectionSize + " bytes)"); " (" + dataSectionSize + " == 0x" + Integer.toHexString(dataSectionSize) + " bytes)");
} else { } else {
logger.fatal(getContikiFirmwareFile().getName() + ": no data section found"); logger.fatal(getContikiFirmwareFile().getName() + ": no data section found");
} }
if (bssSectionAddr >= 0) { if (bssSectionAddr >= 0) {
logger.info(getContikiFirmwareFile().getName() + logger.info(getContikiFirmwareFile().getName() +
": BSS section at 0x" + Integer.toHexString(bssSectionAddr) + ": BSS section at 0x" + Integer.toHexString(bssSectionAddr) +
" (" + bssSectionSize + " bytes)"); " (" + bssSectionSize + " == 0x" + Integer.toHexString(bssSectionSize) + " bytes)");
} else { } else {
logger.fatal(getContikiFirmwareFile().getName() + ": no BSS section found"); logger.fatal(getContikiFirmwareFile().getName() + ": no BSS section found");
} }
if (commonSectionAddr >= 0) { if (commonSectionAddr >= 0) {
logger.info(getContikiFirmwareFile().getName() + logger.info(getContikiFirmwareFile().getName() +
": common section at 0x" + Integer.toHexString(commonSectionAddr) + ": common section at 0x" + Integer.toHexString(commonSectionAddr) +
" (" + commonSectionSize + " bytes)"); " (" + commonSectionSize + " == 0x" + Integer.toHexString(commonSectionSize) + " bytes)");
} else { } else {
logger.info(getContikiFirmwareFile().getName() + ": no common section found"); logger.info(getContikiFirmwareFile().getName() + ": no common section found");
} }
if (readonlySectionAddr >= 0) { if (readonlySectionAddr >= 0) {
logger.info(getContikiFirmwareFile().getName() + logger.info(getContikiFirmwareFile().getName() +
": readonly section at 0x" + Integer.toHexString(readonlySectionAddr) + ": readonly section at 0x" + Integer.toHexString(readonlySectionAddr) +
" (" + readonlySectionSize + " bytes)"); " (" + readonlySectionSize + " == 0x" + Integer.toHexString(readonlySectionSize) + " bytes)");
} else { } else {
logger.warn(getContikiFirmwareFile().getName() + ": no readonly section found"); logger.warn(getContikiFirmwareFile().getName() + ": no readonly section found");
} }
@ -494,18 +494,18 @@ public class ContikiMoteType implements MoteType {
try { try {
/* Relative <-> absolute addresses offset */ /* Relative <-> absolute addresses offset */
int referenceVar = (Integer) addresses.get("referenceVar"); int referenceVar = addresses.get("referenceVar");
myCoreComm.setReferenceAddress(referenceVar); myCoreComm.setReferenceAddress(referenceVar);
} catch (Exception e) { } catch (Exception e) {
throw (MoteTypeCreationException) new MoteTypeCreationException( throw (MoteTypeCreationException) new MoteTypeCreationException(
"JNI call error: " + e.getMessage()).initCause(e); "JNI call error: " + e.getMessage()).initCause(e);
} }
/* We first need the value of Contiki's referenceVar, which tells us the /* We first need the value of Contiki's referenceVar, which tells us the
* memory offset between Contiki's variable and the relative addresses that * memory offset between Contiki's variable and the relative addresses that
* were calculated directly from the library file. * were calculated directly from the library file.
* *
* This offset will be used in Cooja in the memory abstraction to match * This offset will be used in Cooja in the memory abstraction to match
* Contiki's and Cooja's address spaces */ * Contiki's and Cooja's address spaces */
int offset; int offset;
{ {
@ -521,24 +521,24 @@ public class ContikiMoteType implements MoteType {
logger.info(getContikiFirmwareFile().getName() + logger.info(getContikiFirmwareFile().getName() +
": offsetting Contiki mote address space: " + offset); ": offsetting Contiki mote address space: " + offset);
} }
/* Create initial memory: data+bss+optional common */ /* Create initial memory: data+bss+optional common */
initialMemory = new SectionMoteMemory(addresses, offset); initialMemory = new SectionMoteMemory(addresses, offset);
byte[] initialDataSection = new byte[dataSectionSize]; byte[] initialDataSection = new byte[dataSectionSize];
getCoreMemory(dataSectionAddr, dataSectionSize, initialDataSection); getCoreMemory(dataSectionAddr, dataSectionSize, initialDataSection);
initialMemory.setMemorySegmentNative(dataSectionAddr, initialDataSection); initialMemory.setMemorySegmentNative(dataSectionAddr, initialDataSection);
byte[] initialBssSection = new byte[bssSectionSize]; byte[] initialBssSection = new byte[bssSectionSize];
getCoreMemory(bssSectionAddr, bssSectionSize, initialBssSection); getCoreMemory(bssSectionAddr, bssSectionSize, initialBssSection);
initialMemory.setMemorySegmentNative(bssSectionAddr, initialBssSection); initialMemory.setMemorySegmentNative(bssSectionAddr, initialBssSection);
if (commonSectionAddr >= 0 && commonSectionSize > 0) { if (commonSectionAddr >= 0 && commonSectionSize > 0) {
byte[] initialCommonSection = new byte[commonSectionSize]; byte[] initialCommonSection = new byte[commonSectionSize];
getCoreMemory(commonSectionAddr, commonSectionSize, initialCommonSection); getCoreMemory(commonSectionAddr, commonSectionSize, initialCommonSection);
initialMemory.setMemorySegmentNative(commonSectionAddr, initialCommonSection); initialMemory.setMemorySegmentNative(commonSectionAddr, initialCommonSection);
} }
/* Read "read-only" memory */ /* Read "read-only" memory */
if (readonlySectionAddr >= 0 && readonlySectionSize > 0) { if (readonlySectionAddr >= 0 && readonlySectionSize > 0) {
byte[] readonlySection = new byte[readonlySectionSize]; byte[] readonlySection = new byte[readonlySectionSize];
@ -619,7 +619,7 @@ public class ContikiMoteType implements MoteType {
public static boolean parseCommandData(String[] output, HashMap<String, Integer> addresses) { public static boolean parseCommandData(String[] output, HashMap<String, Integer> addresses) {
int nrNew = 0, nrOld = 0, nrMismatch = 0; int nrNew = 0, nrOld = 0, nrMismatch = 0;
Pattern pattern = Pattern pattern =
Pattern.compile(GUI.getExternalToolsSetting("COMMAND_VAR_NAME_ADDRESS")); Pattern.compile(GUI.getExternalToolsSetting("COMMAND_VAR_NAME_ADDRESS"));
for (String line : output) { for (String line : output) {
@ -634,7 +634,7 @@ public class ContikiMoteType implements MoteType {
nrNew++; nrNew++;
addresses.put(symbol, new Integer(address)); addresses.put(symbol, new Integer(address));
} else { } else {
int oldAddress = (Integer) addresses.get(symbol); int oldAddress = addresses.get(symbol);
if (oldAddress != address) { if (oldAddress != address) {
/*logger.warn("Warning, command response not matching previous entry of: " /*logger.warn("Warning, command response not matching previous entry of: "
+ varName);*/ + varName);*/
@ -827,8 +827,8 @@ public class ContikiMoteType implements MoteType {
protected int getVariableSize(Vector<String> lines, String varName) { protected int getVariableSize(Vector<String> lines, String varName) {
Pattern pattern = Pattern.compile( Pattern pattern = Pattern.compile(
GUI.getExternalToolsSetting("MAPFILE_VAR_SIZE_1") + GUI.getExternalToolsSetting("MAPFILE_VAR_SIZE_1") +
varName + varName +
GUI.getExternalToolsSetting("MAPFILE_VAR_SIZE_2")); GUI.getExternalToolsSetting("MAPFILE_VAR_SIZE_2"));
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
Matcher matcher = pattern.matcher(lines.get(i)); Matcher matcher = pattern.matcher(lines.get(i));
@ -840,7 +840,7 @@ public class ContikiMoteType implements MoteType {
} }
private static int parseFirstHexInt(String regexp, String[] data) { private static int parseFirstHexInt(String regexp, String[] data) {
String retString = String retString =
getFirstMatchGroup(data, regexp, 1); getFirstMatchGroup(data, regexp, 1);
if (retString != null) { if (retString != null) {
@ -962,7 +962,7 @@ public class ContikiMoteType implements MoteType {
} }
return end - start; return end - start;
} }
private static int parseCommandReadonlySectionAddr(String[] output) { private static int parseCommandReadonlySectionAddr(String[] output) {
return parseFirstHexInt("^([0-9A-Fa-f]*)[ \t]t[ \t].text$", output); return parseFirstHexInt("^([0-9A-Fa-f]*)[ \t]t[ \t].text$", output);
} }
@ -971,7 +971,7 @@ public class ContikiMoteType implements MoteType {
if (start < 0) { if (start < 0) {
return -1; return -1;
} }
/* Extract the last specified address, assuming that the interval covers all the memory */ /* Extract the last specified address, assuming that the interval covers all the memory */
String last = output[output.length-1]; String last = output[output.length-1];
int lastAddress = Integer.parseInt(last.split("[ \t]")[0],16); int lastAddress = Integer.parseInt(last.split("[ \t]")[0],16);
@ -979,9 +979,9 @@ public class ContikiMoteType implements MoteType {
} }
private static int getRelVarAddr(String mapFileData[], String varName) { private static int getRelVarAddr(String mapFileData[], String varName) {
String regExp = String regExp =
GUI.getExternalToolsSetting("MAPFILE_VAR_ADDRESS_1") + GUI.getExternalToolsSetting("MAPFILE_VAR_ADDRESS_1") +
varName + varName +
GUI.getExternalToolsSetting("MAPFILE_VAR_ADDRESS_2"); GUI.getExternalToolsSetting("MAPFILE_VAR_ADDRESS_2");
String retString = getFirstMatchGroup(mapFileData, regExp, 1); String retString = getFirstMatchGroup(mapFileData, regExp, 1);
@ -1016,14 +1016,14 @@ public class ContikiMoteType implements MoteType {
} }
/* Prepare command */ /* Prepare command */
command = command.replace("$(LIBFILE)", command = command.replace("$(LIBFILE)",
libraryFile.getName().replace(File.separatorChar, '/')); libraryFile.getName().replace(File.separatorChar, '/'));
/* Execute command, read response */ /* Execute command, read response */
String line; String line;
Process p = Runtime.getRuntime().exec( Process p = Runtime.getRuntime().exec(
command.split(" "), command.split(" "),
null, null,
libraryFile.getParentFile() libraryFile.getParentFile()
); );
BufferedReader input = new BufferedReader( BufferedReader input = new BufferedReader(