8 #ifndef DP_MONITORCREATOR_H 9 #define DP_MONITORCREATOR_H 17 #include "formulaAnalyser.h" 19 #define GENERATED_FILES_NAME "monitor" 27 long fileSize(
const char *filename);
35 std::string formulaFile;
67 void generateHeaderFile(
const std::string &defsFile,
const std::string &comment)
const;
99 std::vector<std::string> contents, std::vector<std::string> varsDefinitions,
148 void setFormulaFile(
const std::string &formulaFile);
154 #define HEADER_FILE "%s\n" \ 155 "#ifndef MONITOR_H\n"\ 156 "#define MONITOR_H\n\n"\ 157 "#include <stdio.h>\n"\ 158 "#include <string.h>\n"\ 159 "#include <stdbool.h>\n"\ 160 "#include \"%s\"\n\n" \ 161 "#ifdef __cplusplus\n"\ 162 "extern \"C\" {\n#endif\n\n"\ 163 " bool monitorVerify();\n\n"\ 164 "#ifdef __cplusplus\n}\n#endif\n\n"\ 167 #define MONITOR_C_HEADER "%s\n" \ 168 "#include \"" GENERATED_FILES_NAME ".h\"\n\n"\ 169 "#ifdef __cplusplus\n"\ 173 #define ENUM_VAR_NAMES "\ntypedef bool (*fce)();\n"\ 175 "enum VarNames { %s };\n\n" 177 #define MONITOR_STRUCT_DECLARATION "typedef struct {\n"\ 178 " fce values[%d];\n" \ 179 " const char* formulaeContents[%d];\n" \ 180 " bool pre[%d], now[%d], check[%d];\n" \ 181 " int since[%d];\n" \ 182 " int children[%d][%d];\n"\ 183 " int chCnt[%d];\n" \ 187 #define MONITOR_STRUCT_DEFINITION "monitor M = {\n"\ 201 "bool initiated = false;\n\n" 203 #define MONITOR_VERIFY_INIT "bool monitorVerify() {\n" \ 204 " if (!initiated) {prepare();}\n" \ 206 " for (int i = 0; i < %d; i++) {\n" \ 207 " if (M.pre[i] != M.now[i])\n"\ 208 " M.since[i] = M.hb;\n\n"\ 209 " M.pre[i] = M.now[i]; \n" \ 215 #define MONITOR_VERIFY_CHECK_AND_FINALIZE "\n" \ 216 " for (int i = 0; i < %d; i++) {\n" \ 217 " if ((M.check[i] || i == 0) && M.now[i] != M.pre[i]) {\n" \ 218 " M.check[i] = true;\n" \ 219 " for (int j = 0; j < M.chCnt[i]; j++) {\n" \ 220 " M.check[M.children[i][j]] = true;\n" \ 222 " } else M.check[i] = false;\n" \ 225 " if (!M.now[0]) printFailReport();\n" \ 226 " return M.now[0];\n" \ 229 #define FAIL_REPORT_METHOD "\n"\ 230 "void printFailReport() {\n"\ 231 " fprintf(stderr,\"Verification failed after round #%%d!\\nRelevant changes:\\n\", M.hb);\n"\ 235 " for (i = %d; i > 0 ; i--) {\n" \ 236 " if (M.check[i]) {\n"\ 237 " fprintf(stderr, M.formulaeContents[i], (M.now[i]?\"true\":\"false\"), (M.pre[i]?\"true\":\"false\"),"\ 238 " M.hb - M.since[i]); \n"\ 243 #define RESET_METHOD "\n"\ 245 " initiated = false;"\ 248 #endif //DP_MONITORCREATOR_H void printProcessing(FILE *monitor, std::vector< formula > formulae)
Definition: monitorCreator.cpp:247
monitorCreator(std::string)
Definition: monitorCreator.cpp:24
bool printMonitor(const std::string &defsFile)
Definition: monitorCreator.cpp:43
Definition: monitorCreator.h:33
void replaceInstrumentationComments(const std::vector< std::string > &srcList)
Definition: monitorCreator.cpp:365
std::string getCommentForGeneratedFiles(const std::string &defsFile)
Definition: monitorCreator.cpp:272
void printPreparation(FILE *monitor, std::vector< formula > formulae)
Definition: monitorCreator.cpp:223
void generateMonitorImplementation(formulaAnalyser &analyser, const std::string &comment)
Definition: monitorCreator.cpp:88
void printMonitorStructure(FILE *monitor, std::vector< formula > formulae, std::vector< std::string > contents, std::vector< std::string > varsDefinitions, int childrenCnt)
Definition: monitorCreator.cpp:155
void printVarNamesEnum(std::set< std::string > varNames, FILE *monitor)
Definition: monitorCreator.cpp:134
void replaceLabelsInFileWithMonitorCalls(const std::string &filename)
Definition: monitorCreator.cpp:287
void generateHeaderFile(const std::string &defsFile, const std::string &comment) const
Definition: monitorCreator.cpp:71