}
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(':'));
}