Package se.sics.mspsim.util

Examples of se.sics.mspsim.util.DebugInfo


  private static String getMoteString(Mote mote) {
    if (!(mote instanceof MspMote)) {
      return null;
    }
    try {
      DebugInfo debugInfo =
        ((MspMoteType)mote.getType()).getELF().getDebugInfo(((MspMote)mote).getCPU().reg[MSP430.PC]);
      if (debugInfo == null) {
        return null;
      }
      return debugInfo.getFile() + ":" + debugInfo.getLine();
    } catch (Exception e) {
      return "?";
    }
  }
View Full Code Here


  private void updateCurrentSourceCodeFile() {
    currentCodeFile = null;

    try {
      int pc = mspMote.getCPU().getPC();
      DebugInfo debugInfo = debug.getDebugInfo(pc);
      if (pc <= 0) {
        return;
      }
      if (debugInfo == null) {
        logger.warn("No source info at " + String.format("0x%04x", pc));
        return;
      }
      File f = applySubstitutionRules(new File(debugInfo.getPath(), debugInfo.getFile()), rules);
      if (f == null || !f.exists()) {
        logger.warn("Unknown source at " + String.format("0x%04x", pc) + ": " + debugInfo.getPath() + " " + debugInfo.getFile());
        return;
      }

      currentCodeFile = f;
      currentLineNumber = debugInfo.getLine();
    } catch (Exception e) {
      logger.fatal("Exception: " + e.getMessage(), e);
      currentCodeFile = null;
      currentLineNumber = -1;
    }
View Full Code Here

      // No debug information is available
      return fileToLineHash;
    }

    for (int address: addresses) {
      DebugInfo info = elf.getDebugInfo(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;
  }
View Full Code Here

  }

  public String getPCString() {
    int pc = myCpu.getPC();
    ELF elf = myCpu.getRegistry().getComponent(ELF.class);
    DebugInfo di = elf.getDebugInfo(pc);

    /* Following code examples from MSPsim, DebugCommands.java */
    if (di == null) {
      di = elf.getDebugInfo(pc + 1);
    }
    if (di == null) {
      /* Return PC value */
      SimpleProfiler sp = (SimpleProfiler)myCpu.getProfiler();
      try {
        MapEntry mapEntry = sp.getCallMapEntry(0);
        if (mapEntry != null) {
          String file = mapEntry.getFile();
          if (file != null) {
            if (file.indexOf('/') >= 0) {
              file = file.substring(file.lastIndexOf('/')+1);
            }
          }
          String name = mapEntry.getName();
          return file + ":?:" + name;
        }
        return String.format("*%02x", pc);
      } catch (Exception e) {
        return null;
      }
    }

    int lineNo = di.getLine();
    String file = di.getFile();
    file = file==null?"?":file;
    if (file.contains("/")) {
      /* strip path */
      file = file.substring(file.lastIndexOf('/')+1, file.length());
    }

    String function = di.getFunction();
    function = function==null?"":function;
    if (function.contains(":")) {
      /* strip arguments */
      function = function.substring(0, function.lastIndexOf(':'));
    }
View Full Code Here

        if (DEBUG) {
    System.out.println("File: " + currentPath + " " + currentFile);
    System.out.println("Function: " + currentFunction);
    System.out.println("Line No: " + currentLine);
        }
        return new DebugInfo(currentLine, currentPath, currentFile,
           currentFunction);
      }
    }
  }
  break;
View Full Code Here

                    /* do not match prologue entries */
                    continue;
                  }
                  if (address >= startEntry &&
                      address <= endEntry) {
                    return new DebugInfo(lineEntry.line, null, data.sourceFiles[lineEntry.file-1], "* not available");
                  }
                }
            }
        }
        return null;
View Full Code Here

      ELF elf = ELF.readELF(args[0]);
      DwarfReader dwarfReader = new DwarfReader(elf);
      dwarfReader.read();
      if (args.length > 1) {
        int address = Integer.parseInt(args[1], 16);
        DebugInfo debugInfo = dwarfReader.getDebugInfo(address);
        if (debugInfo == null) {
          System.out.println(String.format("0x%08x", address) + ": "
              + "??" + ":" + "0");
        } else {
          System.out.println(String.format("0x%08x", address) + ": "
              + new File(debugInfo.getFile()).getName() + ":" + debugInfo.getLine());
        }
      } else {
        for (int address = 0; address <= 0xffff; address++) {
          DebugInfo debugInfo = dwarfReader.getDebugInfo(address);
          if (debugInfo == null) {
            System.out.println(String.format("0x%08x", address) + ": "
                + "??" + ":" + "0");
          } else {
            System.out.println(String.format("0x%08x", address) + ": "
                + new File(debugInfo.getFile()).getName() + ":" + debugInfo.getLine());
          }
        }
      }
    }
View Full Code Here

    dui.updateRegs();
    dui.repaint();
    if (elfData != null && sourceViewer != null
        && sourceViewer.isVisible()) {
      int pc = ControlUI.this.cpu.getPC();
      DebugInfo dbg = elfData.getDebugInfo(pc);
      if (dbg != null) {
        if (ControlUI.this.cpu.getDebug()) {
    System.out.println("looking up $" + Integer.toString(pc, 16) +
           " => " + dbg.getFile() + ':' +
           dbg.getLine());
        }
        sourceViewer.viewFile(dbg.getPath(), dbg.getFile());
        sourceViewer.viewLine(dbg.getLine());
      }
    }
  }
      };
    stepAction.putValue(Action.MNEMONIC_KEY,
View Full Code Here

      //       cpu.step();
//       dui.repaint();
    } else if ("Show Source".equals(cmd)) {
      int pc = cpu.getPC();
      if (elfData != null) {
  DebugInfo dbg = elfData.getDebugInfo(pc);
  if (dbg != null) {
    if (cpu.getDebug()) {
      System.out.println("looking up $" + Integer.toString(pc, 16) +
             " => " + dbg.getFile() + ':' + dbg.getLine());
    }
    if (sourceViewer != null) {
      sourceViewer.viewFile(dbg.getPath(), dbg.getFile());
      sourceViewer.viewLine(dbg.getLine());
    } else {
      System.out.println("File: " + dbg.getFile());
      System.out.println("LineNr: " + dbg.getLine());
    }
  }
      }
    } else if ("Stack Trace".equals(cmd)) {
      cpu.getProfiler().printStackTrace(System.out);
View Full Code Here

      });

      ch.registerCommand("line", new BasicCommand("print line number of address/symbol", "<address or symbol>") {
        public int executeCommand(final CommandContext context) {
          int adr = context.getArgumentAsAddress(0);
          DebugInfo di = getELF().getDebugInfo(adr);
          if (di == null) {
            /* quick hack to test next address too... - since something seems to be off by one sometimes... */
            di = getELF().getDebugInfo(adr + 1);
          }
          if (di != null) {
            di.getLine();
            context.out.println(di);
          } else {
            context.err.println("No line number found for: " + context.getArgument(0));
          }
          return 0;
View Full Code Here

TOP

Related Classes of se.sics.mspsim.util.DebugInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.