From: pcm <pcm...@us...> - 2005-08-25 17:11:19
|
Update of /cvsroot/javapathfinder/javapathfinder/src/gov/nasa/jpf/jvm/bytecode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5576/src/gov/nasa/jpf/jvm/bytecode Modified Files: Instruction.java Log Message: added a convenience method getSourceLocation() returning a String with file:line info Index: Instruction.java =================================================================== RCS file: /cvsroot/javapathfinder/javapathfinder/src/gov/nasa/jpf/jvm/bytecode/Instruction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Instruction.java 7 May 2005 00:10:56 -0000 1.2 +++ Instruction.java 25 Aug 2005 17:11:11 -0000 1.3 @@ -19,6 +19,7 @@ package gov.nasa.jpf.jvm.bytecode; import gov.nasa.jpf.JPFException; +import gov.nasa.jpf.jvm.ClassInfo; import gov.nasa.jpf.jvm.JVM; import gov.nasa.jpf.jvm.KernelState; import gov.nasa.jpf.jvm.MethodInfo; @@ -188,6 +189,25 @@ return s.substring(26); // gov.nasa.jpf.jvm.bytecode package } + public String getSourceLocation () { + ClassInfo ci = mi.getClassInfo(); + int line = mi.getLineNumber(this); + String file = ci.getSourceFileName(); + + String s = ci.getName() + '.' + mi.getFullName() + " at "; + + if (file != null) { + s += file; + s += ':'; + s += line; + } else { + s += "pc "; + s += position; + } + + return s; + } + //SUNYSB protected abstract void setPeer (org.apache.bcel.generic.Instruction i, ConstantPool cp); |