Updated to allow MSPSim emulated nodes without debug information (the debug information generated by mspgcc4 is not yet supported).

This commit is contained in:
nifi 2010-08-26 14:10:42 +00:00
parent 2c5f5cd849
commit 4ad3e9d04f
2 changed files with 28 additions and 8 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MspMoteType.java,v 1.35 2010/03/26 12:29:11 fros4943 Exp $ * $Id: MspMoteType.java,v 1.36 2010/08/26 14:10:42 nifi Exp $
*/ */
package se.sics.cooja.mspmote; package se.sics.cooja.mspmote;
@ -390,12 +390,17 @@ public abstract class MspMoteType implements MoteType {
} }
public static Hashtable<File, Hashtable<Integer, Integer>> getFirmwareDebugInfo(ELF elf) { public static Hashtable<File, Hashtable<Integer, Integer>> getFirmwareDebugInfo(ELF elf) {
/* Fetch all executable addresses */
ArrayList<Integer> addresses = elf.getDebug().getExecutableAddresses();
Hashtable<File, Hashtable<Integer, Integer>> fileToLineHash = Hashtable<File, Hashtable<Integer, Integer>> fileToLineHash =
new Hashtable<File, Hashtable<Integer, Integer>>(); new Hashtable<File, Hashtable<Integer, Integer>>();
if (elf.getDebug() == null) {
// No debug information is available
return fileToLineHash;
}
/* Fetch all executable addresses */
ArrayList<Integer> addresses = elf.getDebug().getExecutableAddresses();
for (int address: addresses) { for (int address: addresses) {
DebugInfo info = elf.getDebugInfo(address); DebugInfo info = elf.getDebugInfo(address);

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MspCodeWatcher.java,v 1.23 2010/03/26 12:29:11 fros4943 Exp $ * $Id: MspCodeWatcher.java,v 1.24 2010/08/26 14:10:43 nifi Exp $
*/ */
package se.sics.cooja.mspmote.plugins; package se.sics.cooja.mspmote.plugins;
@ -80,6 +80,7 @@ import se.sics.cooja.util.StringUtils;
import se.sics.mspsim.core.EmulationException; import se.sics.mspsim.core.EmulationException;
import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.MSP430;
import se.sics.mspsim.ui.DebugUI; import se.sics.mspsim.ui.DebugUI;
import se.sics.mspsim.util.ELFDebug;
import se.sics.mspsim.util.DebugInfo; import se.sics.mspsim.util.DebugInfo;
@ClassDescription("Msp Code Watcher") @ClassDescription("Msp Code Watcher")
@ -284,7 +285,11 @@ public class MspCodeWatcher extends VisPlugin implements MotePlugin {
currentCodeFile = null; currentCodeFile = null;
try { try {
DebugInfo debugInfo = ((MspMoteType)mspMote.getType()).getELF().getDebugInfo(mspMote.getCPU().reg[MSP430.PC]); ELFDebug debug = ((MspMoteType)mspMote.getType()).getELF().getDebug();
if (debug == null) {
return;
}
DebugInfo debugInfo = debug.getDebugInfo(mspMote.getCPU().reg[MSP430.PC]);
if (debugInfo == null) { if (debugInfo == null) {
return; return;
} }
@ -321,7 +326,12 @@ public class MspCodeWatcher extends VisPlugin implements MotePlugin {
private void tryMapDebugInfo() { private void tryMapDebugInfo() {
final String[] debugFiles; final String[] debugFiles;
try { try {
debugFiles = ((MspMoteType)mspMote.getType()).getELF().getDebug().getSourceFiles(); ELFDebug debug = ((MspMoteType)mspMote.getType()).getELF().getDebug();
if (debug == null) {
logger.fatal("Error: No debug information is available");
return;
}
debugFiles = debug.getSourceFiles();
} catch (IOException e1) { } catch (IOException e1) {
logger.fatal("Error: " + e1.getMessage(), e1); logger.fatal("Error: " + e1.getMessage(), e1);
return; return;
@ -438,7 +448,12 @@ public class MspCodeWatcher extends VisPlugin implements MotePlugin {
private static File[] getSourceFiles(MspMote mote, String[] map) { private static File[] getSourceFiles(MspMote mote, String[] map) {
final String[] sourceFiles; final String[] sourceFiles;
try { try {
sourceFiles = ((MspMoteType)mote.getType()).getELF().getDebug().getSourceFiles(); ELFDebug debug = ((MspMoteType)mote.getType()).getELF().getDebug();
if (debug == null) {
logger.fatal("Error: No debug information is available");
return new File[0];
}
sourceFiles = debug.getSourceFiles();
} catch (IOException e1) { } catch (IOException e1) {
logger.fatal("Error: " + e1.getMessage(), e1); logger.fatal("Error: " + e1.getMessage(), e1);
return null; return null;