if (state.main!=null) {
outmethod.println("#include <string.h>");
}
- if (state.SSJAVA){
+ if (state.SSJAVA_GENCODE_PREVENT_CRASHES){
outmethod.println("#include <stdio.h>");
}
if (state.CONSCHECK) {
}
}
// redirect to the global_defs_p structure
- if(state.SSJAVA){
+ if(state.SSJAVA_GENCODE_PREVENT_CRASHES){
if (ffn.getField().getType().isPtr()){
output.println("if ( global_defs_p == NULL) {");
output.println("printf(\"SSJAVA: Dereferencing NULL Pointer at file:%s, func:%s, line:%d \\n\", __FILE__, __func__, __LINE__);");
} else if (ffn.getField().isEnum()) {
// an Enum value, directly replace the field access as int
output.println(generateTemp(fm, ffn.getDst()) + "=" + ffn.getField().enumValue() + ";");
- } else if(state.SSJAVA){
+ } else if(state.SSJAVA_GENCODE_PREVENT_CRASHES){
output.println("if (" + generateTemp(fm,ffn.getSrc()) + " == NULL) {");
output.println("printf(\"SSJAVA: Dereferencing NULL Pointer at file:%s, func:%s, line:%d \\n\", __FILE__, __func__, __LINE__);");
if(ffn.getDst().getType().isPrimitive()){
}
}
// redirect to the global_defs_p structure
- if(state.SSJAVA){
+ if(state.SSJAVA_GENCODE_PREVENT_CRASHES){
if (fsfn.getField().getType().isPtr()) {
output.println("if ( global_defs_p == NULL) {");
output.println("printf(\"SSJAVA: Discard a write due to dereferencing NULL Pointer at file:%s, func:%s, line:%d \\n\", __FILE__, __func__, __LINE__);");
output.println("global_defsprim_p->" +
fsfn.getField().getSafeSymbol()+"="+ generateTemp(fm,fsfn.getSrc())+";");
}
- } else if(state.SSJAVA){
+ } else if(state.SSJAVA_GENCODE_PREVENT_CRASHES){
output.println("if (" + generateTemp(fm,fsfn.getDst()) + " == NULL) {");
output.println("printf(\"SSJAVA: Dereferencing NULL Pointer at file:%s, func:%s, line:%d \\n\", __FILE__, __func__, __LINE__);");
output.println("}else{");
else
type=elementtype.getSafeSymbol()+" ";
- if(state.SSJAVA){
+ if(state.SSJAVA_GENCODE_PREVENT_CRASHES){
output.println("if (" + generateTemp(fm,fen.getSrc()) + " == NULL) {");
output.println("printf(\"SSJAVA: Dereferencing NULL Pointer at file:%s, func:%s, line:%d \\n\", __FILE__, __func__, __LINE__);");
output.println("}else{");
else
type=elementtype.getSafeSymbol()+" ";
- if(state.SSJAVA){
+ if(state.SSJAVA_GENCODE_PREVENT_CRASHES){
output.println("if ("+generateTemp(fm,fsen.getDst())+"==NULL){");
output.println("printf(\"SSJAVA: Dereferencing NULL Pointer at file:%s, func:%s, line:%d \\n\", __FILE__, __func__, __LINE__);");
output.println("}else{");
output.println(generateTemp(fm, fon.getDest())+" = ((unsigned int)"+generateTemp(fm, fon.getLeft())+")>>"+generateTemp(fm,fon.getRight())+";");
} else {
- if(state.SSJAVA && fon.getOp().getOp()==Operation.DIV){
+ if(state.SSJAVA_GENCODE_PREVENT_CRASHES && fon.getOp().getOp()==Operation.DIV){
output.println("if (unlikely("+generateTemp(fm,fon.getRight())+"==0)){");
output.println("printf(\"SSJAVA: Divided by zero at file:%s, func:%s, line:%d \\n\", __FILE__, __func__, __LINE__);");
output.println(generateTemp(fm, fon.getDest())+" = 0;");
state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
} else if (option.equals("-nostalltr")) {
state.NOSTALLTR = true;
+
} else if (option.equals("-ssjava")) {
state.SSJAVA = true;
+ state.SSJAVA_GENCODE_PREVENT_CRASHES = true;
+
} else if (option.equals("-ssjavadebug")) {
state.SSJAVADEBUG = true;
} else if( option.equals( "-ssjava-inject-error" ) ) {
+ state.SSJAVA_GENCODE_PREVENT_CRASHES = true;
state.SSJAVA_INJECT_ERROR = true;
state.SSJAVA_INV_ERROR_PROB = Integer.parseInt( args[++i] );
state.SSJAVA_ERROR_SEED = Integer.parseInt( args[++i] );
+ // special case, if the inverse prob is 0, turn off errors
+ if( state.SSJAVA_INV_ERROR_PROB == 0 ) {
+ state.SSJAVA_INJECT_ERROR = false;
+ }
+
+
}else if (option.equals("-printlinenum")) {
state.LINENUM=true;
} else if (option.equals("-help")) {
tmpbuilddirectory="tmpbuilddirectory"
JNI=false
SSJAVA=false
+USE_SSJAVA_CLASSPATH=false
SRCAFTERPP=false;
COREPROF=false;
NUMA=false;
elif [[ $1 = '-ssjava' ]]
then
SSJAVA=true
+USE_SSJAVA_CLASSPATH=true
JAVAOPTS="$JAVAOPTS -ssjava"
elif [[ $1 = '-ssjavadebug' ]]
elif [[ $1 = '-ssjava-inject-error' ]]
then
+USE_SSJAVA_CLASSPATH=true
JAVAOPTS="$JAVAOPTS -ssjava-inject-error $2 $3"
shift
shift
#base multicore gc files
JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/MGC/ -classlibrary $ROBUSTROOT/ClassLibrary/MGC/gnu/"
-elif $SSJAVA
+elif $USE_SSJAVA_CLASSPATH
then
JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/SSJava"
fi
# everyone gets this except ssjava!
-if ! $SSJAVA
+if ! $USE_SSJAVA_CLASSPATH
then
JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/"
fi