Commit 03bc775b authored by Lukáš Marek's avatar Lukáš Marek

Reintroduced error reporting - seems ok after all :)

parent c5c39352
......@@ -24,6 +24,7 @@ import ch.usi.dag.disl.cbloader.ManifestHelper.ManifestInfo;
import ch.usi.dag.disl.classparser.ClassParser;
import ch.usi.dag.disl.exception.DiSLException;
import ch.usi.dag.disl.exception.DiSLIOException;
import ch.usi.dag.disl.exception.DiSLInMethodException;
import ch.usi.dag.disl.exception.DynamicInfoException;
import ch.usi.dag.disl.exception.InitException;
import ch.usi.dag.disl.exception.ManifestInfoException;
......@@ -221,6 +222,11 @@ public class DiSL {
String className = classNode.name;
String methodName = methodNode.name;
String methodDesc = methodNode.desc;
if(debug) {
System.out.println("Instrumenting method: " + className
+ Constants.CLASS_DELIM + methodName + "(" + methodDesc
+ ")");
// evaluate exclusions
for (Scope exclScope : exclusionSet) {
......@@ -311,11 +317,6 @@ public class DiSL {
Weaver.instrument(classNode, methodNode, snippetMarkings,
new LinkedList<SyntheticLocalVar>(usedSLVs), staticInfo,
piResolver);
if(debug) {
System.out.println("Instumenting method: " + className
+ Constants.CLASS_DELIM + methodName + "(" + methodDesc
+ ")");
}
return true;
......@@ -395,7 +396,17 @@ public class DiSL {
// instrument all methods in a class
for (MethodNode methodNode : classNode.methods) {
boolean methodChanged = instrumentMethod(classNode, methodNode);
boolean methodChanged = false;
// intercept all exceptions and add a method name
try {
methodChanged = instrumentMethod(classNode, methodNode);
}
catch(DiSLException e) {
throw new DiSLInMethodException(
classNode.name + "." + methodNode.name, e);
}
// add method to the set of changed methods
if (methodChanged) {
......
package ch.usi.dag.disl.exception;
public class DiSLInMethodException extends DiSLException {
private static final long serialVersionUID = 4819683200958042417L;
public DiSLInMethodException() {
super();
}
public DiSLInMethodException(String message, Throwable cause) {
super(message, cause);
}
public DiSLInMethodException(String message) {
super(message);
}
public DiSLInMethodException(Throwable cause) {
super(cause);
}
}
......@@ -300,9 +300,11 @@ public class WeavingCode {
// index should be less than the stack height
if (operand >= basicframe.getStackSize() || operand < 0) {
throw new DiSLFatalException("Illegal access of index "
+ operand + " on a stack with "
+ basicframe.getStackSize() + " operands");
throw new DynamicInfoException(
"Dynamic context wrong access." +
" Access out of bounds. Accessed " + operand +
", but the size of stack is "
+ basicframe.getLocals());
}
// Type checking
......@@ -310,9 +312,10 @@ public class WeavingCode {
operand).getType();
if (t.getSort() != targetType.getSort()) {
throw new DiSLFatalException("Unwanted type \""
+ targetType + "\", while user needs \"" + t
+ "\"");
throw new DynamicInfoException(
"Dynamic context wrong access. Requested \"" +
t + "\" but found \"" + targetType
+ "\" on the stack.");
}
// store the stack value without changing the semantic
......@@ -343,8 +346,10 @@ public class WeavingCode {
// index should be less than the size of local variables
if (slot >= basicframe.getLocals() || slot < 0) {
throw new DiSLFatalException("Illegal access of index "
+ slot + " while the size of local variable is "
throw new DynamicInfoException(
"Dynamic context wrong access." +
" Access out of bounds. Accessed " + slot +
", but the size of stack is "
+ basicframe.getLocals());
}
......@@ -352,8 +357,10 @@ public class WeavingCode {
Type targetType = basicframe.getLocal(slot).getType();
if (t.getSort() != targetType.getSort()) {
throw new DiSLFatalException("Unwanted type \""
+ targetType + "\", while user needs \"" + t + "\"");
throw new DynamicInfoException(
"Dynamic context wrong access. Requested \"" +
t + "\" but found \"" + targetType
+ "\" on the stack.");
}
// box value if applicable
......@@ -372,8 +379,10 @@ public class WeavingCode {
// index should be less than the size of local variables
if (operand >= basicframe.getLocals() || operand < 0) {
throw new DiSLFatalException("Illegal access of index "
+ operand + " while the size of local variable is "
throw new DynamicInfoException(
"Dynamic context wrong access." +
" Access out of bounds. Accessed " + operand +
", but the size of stack is "
+ basicframe.getLocals());
}
......@@ -381,8 +390,10 @@ public class WeavingCode {
Type targetType = basicframe.getLocal(operand).getType();
if (t.getSort() != targetType.getSort()) {
throw new DiSLFatalException("Unwanted type \""
+ targetType + "\", while user needs \"" + t + "\"");
throw new DynamicInfoException(
"Dynamic context wrong access. Requested \"" +
t + "\" but found \"" + targetType
+ "\" on the stack.");
}
// box value if applicable
......
......@@ -8,6 +8,7 @@ import java.util.concurrent.atomic.AtomicLong;
import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.exception.DiSLException;
import ch.usi.dag.disl.exception.DiSLInMethodException;
public abstract class DiSLServer {
......@@ -83,7 +84,19 @@ public abstract class DiSLServer {
if (e instanceof DiSLException) {
System.err.println("DiSL error: " + e.getMessage());
System.err.print("DiSL error");
// report during which method it happened
if (e instanceof DiSLInMethodException) {
System.err.print(" (while instrumenting method \""
+ e.getMessage() + "\")");
// set inner error
e = e.getCause();
}
System.err.println(": " + e.getMessage());
reportInnerError(e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment