Skip to content

Commit

Permalink
Added RTOpts.debugFlag guards to lessen overhead when debug output is…
Browse files Browse the repository at this point in the history
…n't used.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4649 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Dec 9, 2009
1 parent 7ba64e9 commit 7282df0
Show file tree
Hide file tree
Showing 26 changed files with 128 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Compiler/Ceval.mo
Expand Up @@ -1227,6 +1227,7 @@ algorithm

case (cache,env,e,_,impl,st,dim,msg)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- Ceval.cevalCallFunction failed: ");
str = Exp.printExpStr(e);
Debug.fprintln("failtrace", str);
Expand Down Expand Up @@ -4330,6 +4331,7 @@ algorithm

case (v1,op,v2)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "- Ceval.cevalRelation failed on: " +&
ValuesUtil.printValStr(v1) +&
Exp.binopSymbol(op) +&
Expand Down Expand Up @@ -4691,6 +4693,7 @@ algorithm
(cache,res);
case (cache,env,_,DAE.EQBOUND(exp = exp,constant_ = DAE.C_VAR()),impl,MSG())
equation
true = RTOpts.debugFlag("ceval");
Debug.fprint("ceval", "#- Ceval.cevalCrefBinding failed (nonconstant EQBOUND(");
expstr = Exp.printExpStr(exp);
Debug.fprint("ceval", expstr);
Expand Down
3 changes: 2 additions & 1 deletion Compiler/CevalScript.mo
Expand Up @@ -4235,6 +4235,7 @@ algorithm
case (_,path,env,_)
local String ss1;
equation
true = RTOpts.debugFlag("failtrace");
false = RTOpts.debugFlag("nogen");
ss1 = Absyn.pathString(path);
ss1 = Util.stringAppendList({"/*- CevalScript.cevalGenerateFunctionDAEs failed( ",ss1," )*/\n"});
Expand Down Expand Up @@ -4276,4 +4277,4 @@ algorithm
end matchcontinue;
end cevalGenerateFunctionDAEsList;

end CevalScript;
end CevalScript;
4 changes: 4 additions & 0 deletions Compiler/Cevalfunc.mo
Expand Up @@ -18,6 +18,7 @@ public import Prefix;
public import Connect;
public import ClassInf;
public import ConnectionGraph;
public import RTOpts;

protected import Ceval;
protected import Util;
Expand Down Expand Up @@ -73,6 +74,7 @@ algorithm
sc as SCode.CLASS(_,false,_,SCode.R_FUNCTION(),
SCode.PARTS(elementLst=elementList) ),daeList)
equation
true = RTOpts.debugFlag("failtrace");
_ = extendEnvWithInputArgs(env,elementList,inArgs,crefArgs);
str = Absyn.pathString(funcpath);
str = Util.stringAppendList({"- Cevalfunc.evaluateStatements failed for function /* ",str," */\n"});
Expand All @@ -83,6 +85,7 @@ algorithm
sc as SCode.CLASS(_,false,_,SCode.R_FUNCTION(),
SCode.PARTS(elementLst=elementList) ),daeList)
equation
true = RTOpts.debugFlag("failtrace");
failure(_ = extendEnvWithInputArgs(env,elementList,inArgs,crefArgs));
str = Absyn.pathString(funcpath);
str = Util.stringAppendList({"- Cevalfunc.extendEnvWithInputArgs failed for function /* ",str," */"});
Expand Down Expand Up @@ -836,6 +839,7 @@ algorithm outVal := matchcontinue(inVal,env,toAssign)
case(_,_,Absyn.CREF(dbgcr))
local String dbgString; Absyn.ComponentRef dbgcr;
equation
true = RTOpts.debugFlag("failtrace");
(Absyn.CREF_IDENT(dbgString,_)) = Absyn.crefGetFirst(dbgcr);
dbgString = Util.stringAppendList({"- Cevalfunc.setValue failed for ", dbgString,"\n"});
Debug.fprint("failtrace", dbgString);
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Codegen.mo
Expand Up @@ -2061,6 +2061,7 @@ algorithm

case (ty)
equation
true = RTOpts.debugFlag("failtrace");
t_str = Types.unparseType(ty);
Debug.fprint("failtrace", "#--Codegen.generateSimpleType failed: " +& t_str +& "\n");
then
Expand Down Expand Up @@ -5370,6 +5371,7 @@ algorithm
fail();
case (DAE.UMINUS(ty = tp),_,_,_)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "-generate_unary failed\n");
s = Exp.typeString(tp);
Debug.fprint("failtrace", " tp = ");
Expand Down
3 changes: 3 additions & 0 deletions Compiler/DAELow.mo
Expand Up @@ -704,6 +704,7 @@ algorithm

then (WHEN_EQUATION(wheneq),vars);
case (eqn ,vars) equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "-DAELow.expandDerOperatorEqn, eqn =");
Debug.fprint("failtrace", equationStr(eqn));
Debug.fprint("failtrace", " failed\n");
Expand Down Expand Up @@ -6703,6 +6704,7 @@ algorithm
v;
case (VARIABLES(varArr = vararr),n)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "DAELow.getVarAt failed to get the variable at index:" +& intString(n));
then
fail();
Expand Down Expand Up @@ -10614,6 +10616,7 @@ algorithm
reachable_2;
case (eqn,_,_,_,_)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "-reachable_nodes failed, eqn: ");
eqnstr = intString(eqn);
Debug.fprint("failtrace", eqnstr);
Expand Down
3 changes: 2 additions & 1 deletion Compiler/DAEUtil.mo
Expand Up @@ -4098,6 +4098,7 @@ algorithm
case (cache,env,_,el::_,_)
local String str;
equation
true = RTOpts.debugFlag("failtrace");
str = dumpDebugDAE(DAE.DAE({el}));
Debug.fprintln("failtrace", "- DAEUtil.daeToRecordValue failed on: " +& str);
then
Expand Down Expand Up @@ -5802,4 +5803,4 @@ algorithm
end matchcontinue;
end traverseDAEVarAttr;

end DAEUtil;
end DAEUtil;
3 changes: 3 additions & 0 deletions Compiler/DFA.mo
Expand Up @@ -46,6 +46,7 @@ public import Debug;
public import Error;
public import MetaUtil;
public import SCode;
public import RTOpts;

type Stamp = Integer;
type ArcName = Absyn.Ident;
Expand Down Expand Up @@ -1511,6 +1512,7 @@ algorithm
then (localDfaEnv,localCache);
case (e::_,_,_,_)
equation
true = RTOpts.debugFlag("matchcase");
str = Dump.printExpStr(e);
Debug.fprintln("matchcase", "- DFA.addVarsToDfaEnv failed " +& str);
then fail();
Expand Down Expand Up @@ -2349,6 +2351,7 @@ algorithm
case (pat :: _,_,_,_,_)
local String str;
equation
true = RTOpts.debugFlag("matchcase");
str = printPatternStr(pat);
Debug.fprintln("matchcase", "- generatePathVarDeclarationsList failed: " +& str);
then fail();
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Derive.mo
Expand Up @@ -45,6 +45,7 @@ package Derive
public import Absyn;
public import DAE;
public import DAELow;
public import RTOpts;

protected import Exp;
protected import Util;
Expand Down Expand Up @@ -694,6 +695,7 @@ algorithm

case (e,cr,differentiateIfExp)
equation
true = RTOpts.debugFlag("failtrace");
s = Exp.printExpStr(e);
s2 = Exp.printComponentRefStr(cr);
str = Util.stringAppendList({"differentiate_exp ",s," w.r.t:",s2," failed\n"});
Expand Down
1 change: 1 addition & 0 deletions Compiler/Derive_stub.mo
Expand Up @@ -417,6 +417,7 @@ algorithm

case (e,cr,differentiateIfExp)
equation
true = RTOpts.debugFlag("failtrace");
s = Exp.printExpStr(e);
s2 = Exp.printComponentRefStr(cr);
str = Util.stringAppendList({"differentiate_exp ",s," w.r.t:",s2," failed\n"});
Expand Down
8 changes: 7 additions & 1 deletion Compiler/Exp.mo
Expand Up @@ -3076,6 +3076,7 @@ algorithm
exp;
case (factor,expr)
equation
true = RTOpts.debugFlag("failtrace");
fs = printExpStr(factor);
es = printExpStr(expr);
Debug.fprint("failtrace","-Exp.removeFactor failed, factor:");
Expand Down Expand Up @@ -3491,6 +3492,7 @@ algorithm
res;
case (lst)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace","-Exp.makeProductLst failed, exp lst:");
explst = Util.listMap(lst, printExpStr);
str = Util.stringDelimitList(explst, ", ");
Expand Down Expand Up @@ -3617,6 +3619,7 @@ algorithm
res;
case (lst)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace","-Exp.makeSum failed, exp lst:");
explst = Util.listMap(lst, printExpStr);
str = Util.stringDelimitList(explst, ", ");
Expand Down Expand Up @@ -3896,7 +3899,7 @@ algorithm
case (DAE.POW_SCALAR_ARRAY(ty = t)) then t;
case (DAE.MUL_SCALAR_PRODUCT(ty = t)) then t;
case (DAE.MUL_MATRIX_PRODUCT(ty = t)) then t;
case (DAE.DIV_ARRAY_SCALAR(ty = t)) then t;
case (DAE.DIV_ARRAY_SCALAR(ty = t)) then t;
case (DAE.POW_ARR(ty = t)) then t;
case (DAE.AND()) then DAE.ET_BOOL();
case (DAE.OR()) then DAE.ET_BOOL();
Expand Down Expand Up @@ -8273,6 +8276,7 @@ algorithm
res;
case (e,cr)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "-Exp.expContains failed\n");
s = printExpStr(e);
str = Util.stringAppendList({"exp = ",s,"\n"});
Expand Down Expand Up @@ -10066,6 +10070,7 @@ algorithm
case(cr)
local ComponentRef cr;String s;
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "-Exp.crefType failed on Cref:");
s = printComponentRefStr(cr);
Debug.fprint("failtrace", s);
Expand Down Expand Up @@ -10096,6 +10101,7 @@ algorithm
case(cr)
local ComponentRef cr;String s;
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "-Exp.crefType failed on Cref:");
s = printComponentRefStr(cr);
Debug.fprint("failtrace", s);
Expand Down
21 changes: 21 additions & 0 deletions Compiler/Inst.mo
Expand Up @@ -548,6 +548,7 @@ algorithm
case (_,_,_,path)
equation
//print("-instantiateFunctionImplicit ");print(Absyn.pathString(path));print(" failed\n");
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "-Inst.instantiateFunctionImplicit " +& Absyn.pathString(path) +& " failed\n");
then
fail();
Expand Down Expand Up @@ -1857,13 +1858,15 @@ algorithm
Error.addMessage(Error.TYPE_ERROR,{s1,s2});
then fail();
case(cache,env,id,SOME(v),bind,expectedTp,bindProp) equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "instBuiltinAttribute failed for: " +& id +&
" value binding: " +& ValuesUtil.printValStr(v) +&
" binding: " +& Exp.printExpStr(bind) +&
" expected type: " +& Types.printTypeStr(expectedTp) +&
" type props: " +& Types.printPropStr(bindProp));
then fail();
case(cache,env,id,_,bind,expectedTp,bindProp) equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "instBuiltinAttribute failed for: " +& id +&
" value binding: NONE()" +&
" binding: " +& Exp.printExpStr(bind) +&
Expand Down Expand Up @@ -2484,6 +2487,7 @@ algorithm
SCode.DERIVED(Absyn.TPATH(path = cn, arrayDim = ad),modifications = mod),
re,prot,inst_dims,impl,graph,instSingleCref)
equation
true = RTOpts.debugFlag("failtrace");
failure((_,_,_) = Lookup.lookupClass(cache,env, cn, false));
Debug.fprint("failtrace", "- inst_classdef DERIVED( ");
Debug.fprint("failtrace", Absyn.pathString(cn));
Expand All @@ -2494,6 +2498,7 @@ algorithm

case (_,env,ih,_,_,_,_,_,_,_,_,_,_,_,_,instSingleCref)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- Inst.instClassdef failed\n class :");
s = Env.printEnvPathStr(env);
Debug.fprint("failtrace", s);
Expand Down Expand Up @@ -2585,6 +2590,7 @@ algorithm outComps := matchcontinue(inComps, ocr,allComps,className)
outComps;
case(inComps, SOME(cr), allComps,className)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "ExtractConstantPlusDeps::Failure to find " +& Exp.printComponentRefStr(cr) +& ", returning \n");
Debug.fprint("failtrace", "Elements to instantiate:" +& intString(listLength(inComps)) +& "\n");
then
Expand Down Expand Up @@ -5644,6 +5650,7 @@ algorithm

case (cache,env,ih,store,omod,_,_,_,(el,mod),_,_,_)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "- Inst.instElement failed: " +& SCode.printElementStr(el));
then
fail();
Expand Down Expand Up @@ -5780,6 +5787,7 @@ algorithm
// failure
case(env,tp,ci_state,cl)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace","-Inst.checkRecursiveDefinition failed, envpath="+&Env.printEnvPathStr(env)+&" tp :"+&Absyn.pathString(tp)+&"\n");
then fail();
end matchcontinue;
Expand Down Expand Up @@ -6607,6 +6615,7 @@ algorithm

case (_,_,ih,_,_,_,_,_,n,_,_,_,_,_,_,_,_,_,_,_)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "- Inst.instVar2 failed: " +& n);
then
fail();
Expand Down Expand Up @@ -6823,6 +6832,7 @@ algorithm

case (_,_,_,_,SCode.CLASS(name = id),_,_)
equation
true = RTOpts.debugFlag("failtrace");
id = SCode.printClassStr(inClass);
Debug.fprintl("failtrace", {"Inst.getUsertypeDimensions failed: ", id, "\n"});
then fail();
Expand Down Expand Up @@ -7647,6 +7657,7 @@ algorithm

case (_,_,ih,_,_,_,_,_,n,(_,_),_,_,_,_,_,_,_,_,_,_,_)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "- Inst.instArray failed: " +& n);
then
fail();
Expand Down Expand Up @@ -8229,6 +8240,7 @@ algorithm
l; */
case (t,(_ :: ad)) /* PR, for debugging */
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "Undefined!");
Debug.fprint("failtrace", " The type detected: ");
Debug.fprint("failtrace", Types.printTypeStr(t));
Expand Down Expand Up @@ -9597,6 +9609,7 @@ algorithm
case (_,_,_,_,_,_,_,SCode.EQUATION(eEquation = eqn),impl,graph)
local SCode.EEquation eqn; String str;
equation
true = RTOpts.debugFlag("failtrace");
str= SCode.equationStr(eqn);
Debug.fprint("failtrace", "- instEquation failed eqn:");
Debug.fprint("failtrace", str);
Expand Down Expand Up @@ -10154,6 +10167,7 @@ algorithm

case (_,env,ih,_,_,_,_,eqn,_,impl,graph)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- instEquationCommon failed for eqn: ");
s = SCode.equationStr(eqn);
Debug.fprint("failtrace", s +& " in scope:" +& Env.getScopeName(env) +& "\n");
Expand Down Expand Up @@ -10753,6 +10767,7 @@ algorithm
(cache,dae,csets_2,graph);
case (_,_,_,_,_,_,_,v,_,_,_,_)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- Inst.unroll ");
Debug.fcall("failtrace", ValuesUtil.printVal, v);
Debug.fprint("failtrace", " failed\n");
Expand Down Expand Up @@ -11329,6 +11344,7 @@ algorithm
case (cache,env,pre,alg,initial_,impl)
local String str;
equation
true = RTOpts.debugFlag("failtrace");
str = Dump.unparseAlgorithmStr(0,Absyn.ALGORITHMITEM(alg,NONE()));
Debug.fprintln("failtrace", "- Inst.instStatement failed: " +& str);
//Debug.fcall("failtrace", Dump.printAlgorithm, alg);
Expand Down Expand Up @@ -11914,6 +11930,7 @@ algorithm

case (env,_,c1,_,_,c2,_,_,io1,io2)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "- Inst.checkConnectTypes(" +&
Exp.printComponentRefStr(c1) +& " <-> " +&
Exp.printComponentRefStr(c2) +& " failed");
Expand All @@ -11923,6 +11940,7 @@ algorithm
case (env,ih,c1,t1,DAE.ATTR(flowPrefix = flow1),c2,t2,DAE.ATTR(flowPrefix = flow2),io1,io2)
local DAE.Type t1,t2; Boolean flow1,flow2,b0; String s0,s1,s2;
equation
true = RTOpts.debugFlag("failtrace");
b0 = Types.equivtypes(t1, t2);
s0 = Util.if_(b0,"types equivalent;","types NOT equivalent");
s1 = Util.if_(flow1,"flow "," ");
Expand Down Expand Up @@ -13202,6 +13220,7 @@ algorithm
case (c,t,m,impl)
local tuple<DAE.TType, Option<Absyn.Path>> t;
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- Inst.instModEquation failed\n type: ");
Debug.fprint("failtrace", Types.printTypeStr(t));
Debug.fprint("failtrace", "\n cref: ");
Expand Down Expand Up @@ -13519,6 +13538,7 @@ algorithm

case (cache,env,ih,elt,outerMod,impl)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- instRecordConstructorElt failed.,elt:");
str = SCode.printElementStr(elt);
Debug.fprint("failtrace", str);
Expand Down Expand Up @@ -15128,6 +15148,7 @@ algorithm
(cache,env_2,ih,lb::llb,csets_2,ci_state_2,graph);
case (cache,env,ih,mod,pre,csets,ci_state,(e :: es),_,impl,graph)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "Inst.instIfTrueBranches failed on equations: " +&
Util.stringDelimitList(Util.listMap(e, SCode.equationStr), "\n"));
then
Expand Down

0 comments on commit 7282df0

Please sign in to comment.