Commit d2d75a78 authored by Yliès's avatar Yliès

upload of scripts we have for now

parent d3890b2d
#! /bin/sh
echo "Running Experiment collect (collect.sh)" >> run.log
results=run-`hostname`-`date +%Y%m%d_%H%M`.tar.gz
tar czf $results run.log >> /dev/null 2>&1
echo $results
echo $results >> run.log
#! /bin/sh
echo "Running Experiment collect (collect.sh)" >> run.monitor.log
results=run-monitor-`hostname`-`date +%Y%m%d_%H%M`.tar.gz
tar czf $results run.monitor.log >> /dev/null 2>&1
echo $results
echo $results >> run.monitor.log
#!/bin/sh
# creates tar archives ready for the CSRV 2014 submission
# creates one archive with, and one without monitoring for each C file
# present in the current directory
# requires in the current directory:
# - patterns:
# setup_pattern_0.sh for setup.sh W/O monotoring
# run_pattern_0.sh for run.sh W/O monotoring
# collect_pattern_0.sh for collect.sh W/O monotoring
# setup_pattern_1.sh for setup.sh WITH monotoring
# run_pattern_1.sh for run.sh WITH monotoring
# collect_pattern_1.sh for collect.sh WITH monotoring
# - file reportVmPeak.c
# - directory e-acsl-library that can be a link to `frama-c -print-share-path`/e-acsl
# - file annotated_libc.h if it is necessary in examples
echo "=============Starting the script $0...==============="
SHARE=`frama-c -print-share-path`
rm -rf e-acsl-library e-acsl
ln -s ${SHARE}/e-acsl/
mv e-acsl e-acsl-library
if [ $# -gt 0 ]; then
tarNamePrefix=$1
mask="*.c"
cur_dir=`pwd`
annotatedLibC="annotated_libc.h"
rm -f run.log setup.sh *.nomonitor.c run.out
rm -f run.sh collect.sh
echo "Creating archives WITHOUT monitoring..."
cp run_pattern_0.sh run.sh
cp collect_pattern_0.sh collect.sh
for filename in `ls $cur_dir/$mask`
do
filebaseExt=`basename $filename`
filebase=`basename $filename ".c"`
fileNomonitor=${filebase}.nomonitor.c
archiveNameNoMonitoring=${tarNamePrefix}_${filebase}_0.tar.gz
if [ "${filebaseExt}" != "reportVmPeak.c" ]; then
# add include for reportVmPeak.c, set atexit and decomment reporting VmPeak if any
echo "#include\"reportVmPeak.c\"" > $fileNomonitor
sed -e '{s/\(main.*{\)/\1\n\nsetbye(); \/\/ set atexit function to report memory peak\n/g}' -e '{s/\/\/bye()/ bye()/g}' < ${filebaseExt} >> $fileNomonitor
echo "\n\n=================Creating archive WITHOUT monitoring for $filebaseExt..."
sed -e {s/BenchmarkNameToReplace/$fileNomonitor/} setup_pattern_0.sh > setup.sh
chmod +x setup.sh run.sh collect.sh
if [ -f "$annotatedLibC" ]; then
tar czf $archiveNameNoMonitoring $fileNomonitor run.sh setup.sh collect.sh reportVmPeak.c $annotatedLibC
else
tar czf $archiveNameNoMonitoring $fileNomonitor run.sh setup.sh collect.sh reportVmPeak.c
fi
echo $archiveNameNoMonitoring
echo "\nrunning setup.sh..."
./setup.sh
echo "\nrunning run.sh..."
./run.sh
echo "\nrunning collect.sh..."
./collect.sh
fi
rm -f run.log setup.sh $fileNomonitor run.out
done
rm -f run.log setup.sh *.nomonitor.c bench.c run.out
rm -f run.sh collect.sh
echo "Creating archives WITH monitoring..."
cp run_pattern_1.sh run.sh
cp collect_pattern_1.sh collect.sh
for filename in `ls $cur_dir/$mask`
do
filebaseExt=`basename $filename`
filebase=`basename $filename ".c"`
fileNomonitor=${filebase}.nomonitor.c
fileMonitor=${filebase}.monitor.c
archiveNameWithMonitoring=${tarNamePrefix}_${filebase}_1.tar.gz
if [ "${filebaseExt}" != "reportVmPeak.c" ]; then
# add include for reportVmPeak.c, set atexit and decomment reporting VmPeak if any
echo "#include\"reportVmPeak.c\"" > $fileNomonitor
sed -e '{s/\(main.*{\)/\1\n\nsetbye(); \/\/ set atexit function to report memory peak\n/g}' -e '{s/\/\/bye()/ bye()/g}' < ${filebaseExt} >> $fileNomonitor
echo "\n\n---------------Creating archive WITH monitoring for $filebase..."
if [ "$2" = "-rte" ]; then
frama-c -machdep x86_64 $fileNomonitor -e-acsl-prepare -rte -rte-verbose 0 -then -e-acsl -then-on e-acsl -print -ocode ${fileMonitor}
else
frama-c -pp-annot -machdep x86_64 $fileNomonitor -e-acsl -then-on e-acsl -print -ocode ${fileMonitor}
fi
sed -e {s/BenchmarkNameToReplace/${fileMonitor}/} setup_pattern_1.sh > setup.sh
chmod +x setup.sh run.sh collect.sh
if [ -f "$annotatedLibC" ]; then
tar czf $archiveNameWithMonitoring ${fileMonitor} ${fileNomonitor} run.sh setup.sh collect.sh reportVmPeak.c e-acsl-library/* $annotatedLibC
else
tar czf $archiveNameWithMonitoring ${fileMonitor} ${fileNomonitor} run.sh setup.sh collect.sh reportVmPeak.c e-acsl-library/*
fi
echo $archiveNameWithMonitoring
echo "\nrunning setup.sh..."
./setup.sh
echo "\nrunning run.sh..."
./run.sh
echo "\nrunning collect.sh..."
./collect.sh
rm -f ${fileMonitor} ${fileNomonitor} run.monitor.log setup.sh bench.c *.monitor.c *.monitor.out
fi
done
rm -f run.monitor.log setup.sh bench.c *.nomonitor.c *.monitor.c *.monitor.out
rm -f run.sh collect.sh
else
echo 'Use this command with a tar prefix argument, e.g.: createTarForCSVR.sh "t2_t1_b1" ["-rte"] with optional argument "-rte" for using RTE plugin'
fi
echo "==============End of $0 !=============="
#include<stdio.h>
#include<stdlib.h>
// reports memory peak up to now
void bye(void)
{
system("cat /proc/$PPID/status | grep VmPeak");
}
// sets atexit function to report memory peak, exits if it fails
void setbye(void){
int i = atexit(bye);
if (i != 0) {
fprintf(stderr, "cannot set exit function\n");
exit(1);
}
}
#! /bin/sh
#exec 1>>run.log
#exec 2>&1
echo "Running Experiment (run.sh)" >>run.log 2>&1
(time ./run.out) >>run.log 2>&1
cat run.log
#! /bin/sh
#exec 1>>run.monitor.log
#exec 2>&1
echo "Running Experiment (run.sh)" >>run.monitor.log 2>&1
(time ./run.monitor.out) >>run.monitor.log 2>&1
cat run.monitor.log
#! /bin/sh
exec 1>run.log
exec 2>&1
echo "Running Experiment setup (setup.sh)"
gcc -std=c99 -pedantic -Wall -Wno-long-long -Wno-attributes -Wno-unused-but-set-variable -fno-builtin -o run.out BenchmarkNameToReplace -lgmp
#! /bin/sh
exec 1>run.monitor.log
exec 2>&1
echo "Running Experiment setup (setup.sh)"
export SHARE=./e-acsl-library
gcc -std=c99 -pedantic -Wall -Wno-long-long -Wno-attributes -Wno-unused-but-set-variable -fno-builtin -o run.monitor.out $SHARE/e_acsl.c $SHARE/memory_model/e_acsl_bittree.c $SHARE/memory_model/e_acsl_mmodel.c BenchmarkNameToReplace -lgmp
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
include $(top_srcdir)/config/Makefile.for.ROSE.includes.and.libs
INCLUDES = \
$(ROSE_INCLUDES)
bin_PROGRAMS = RTC
LDADD = $(LIBS_WITH_RPATH) $(ROSE_LIBS) #-ldl $(LIBLTDL)
.PHONY: plainrun instrun
RTC_SOURCES = RTC.C \
funcDecl.C \
strDecl.C \
util.C \
preProcessAST.C \
traverse.C \
instr.C \
instrBinaryOps.C \
instrCallExps.C \
instrDeclStmts.C \
instrDeleteExps.C \
instrNewExps.C \
instrRefExps.C \
instrRetStmts.C \
instrScopeStmts.C \
instrSizeOfOps.C \
instrThisExps.C \
instrUnaryOps.C \
instrVarRefs.C \
RTC.h \
funcDecl.h \
util.h \
strDecl.h \
preProcessAST.h \
traverse.h \
instr.h
RTED_TESTS = pointer_example \
pointer_example2 \
pointer_example3 \
pointer_example3_fixed \
pointer_example4 \
pointer_example5 \
pointer_example6 \
pointer_example7 \
pointer_example7_simplified \
pointer_example8 \
pointer_example8_simplified \
pointer_example9 \
pointer_example9_simplified \
arith_example4 \ # Not on S7
pointer_example11_simplified \
pointer_example10_simplified \
pointer_example12_simplified \
pointer_example13_simplified \
pointer_example14_simplified \
pointer_example15_simplified \
pointer_example16_simplified \
pointer_example17_array_test \
pointer_example18_array_arrow_test \
pointer_example_class \
pointer_example_class2 \
pointer_example_class3 \
pointer_example_class4 \
pointer_example_class5 \
pointer_example_class6 \
pointer_example_class_structed \
pointer_example_class_cout \
pointer_example_class_void_lock \
pointer_example_class_void_lock_fn \
pointer_example_link_test \
pointer_example_int \
pointer_example_lock_key_test \
pointer_example_struct \
pointer_example_struct2 \
pointer_example_struct_copy \
pointer_example_struct_copy_ret \
pointer_example_static \
pointer_example_simple_int
check: plainrun instrun
@echo "Executing commands for check"
# Needs to be updated just like the instrun below
plainrun: RTC
for test in $(RTED_TESTS); do \
echo "$$test"; \
echo "./RTC -plain -rose:o $$test.out.cpp $$test.cpp;"; \
./RTC -plain -rose:o $$test.out.c $$test.cpp; \
./a.out;\
done
#instrun: RTC
# for test in $(RTED_TESTS); do \
# echo "$$test"; \
# echo "./RTC -rose:o $(addsuffix _out.cpp, $(basename $$test)) $$test"; \
# g++ $(addsuffix _out.cpp, $(basename $$test)) metadata.o; \
# ./a.out >& instrun.txt; \
# done
instrun: RTC
echo "Instrumented Run"; \
for test in $(RTED_TESTS); do \
./RTC -rose:o $$test.out.cpp $$test.cpp; \
g++ $$test.out.cpp -c -o $$test.o; \
g++ $$test.o metadata.o; \
./a.out >& instrun.txt; \
done
#instrun: RTC
# echo "Instrumented Run"; \
# for test in $(RTED_TESTS); do \
# ./RTC -rose:o $$test.out.cpp $$test.cpp ptr_lib.o; \
# g++ $$test.out.c ptr_lib.o; \
# ./a.out >& instrun.txt; \
# done
EXTRA_DIST = RTC.h
CLEANFILES = *.o
clean:
rm -f *.o RTC
runclean:
rm -f instrun.txt plainrun.txt
check-local:
@echo "********************************************************************************"
@echo "*** ROSE/projects/RTC: make check rule complete (terminated normally) ***"
@echo "********************************************************************************"
#ifndef RTC_C
#define RTC_C
#include "RTC.h"
#if 0
#include "CheckBase.h"
#include "QSTraversal.h"
#include "ArithCheck.h"
#include "BinarySimpleTraversal.h"
#endif
//CheckBase* checkbaseobject;
//NodeContainer TraversalBase::MallocRefs;
//NodeContainer TraversalBase::VarNames;
//NodeContainer TraversalBase::VarRefs;
void insertTimingSupport(SgProject* project) {
SgFilePtrList file_list = project->get_fileList();
SgFilePtrList::iterator iter;
for(iter = file_list.begin(); iter!=file_list.end(); iter++) {
SgSourceFile* cur_file = isSgSourceFile(*iter);
SgGlobal* global_scope = cur_file->get_globalScope();
SageInterface::insertHeader("foo2_c.h", PreprocessingInfo::after,false,global_scope);
}
//hackyPtrCheck();
//AnotherHackyPtrCheck();
//YetAnotherHackyPtrCheck();
//HackyPtrCheck4();
// SgProject* project = CheckBase::CBProject;
SgNode* TopNode = isSgNode(project);
SgFunctionDeclaration* MainFn = SageInterface::findMain(TopNode);
SgScopeStatement* scope = MainFn->get_scope();
SgFunctionDefinition* MainFnDef = MainFn->get_definition();
SgBasicBlock* FirstBlock = MainFnDef->get_body();
SgStatementPtrList& Stmts = FirstBlock->get_statements();
SgName s_name ("StartClock");
SgExprListExp* parameter_list = SageBuilder::buildExprListExp();
SgExprStatement* NewFunction = SageBuilder::buildFunctionCallStmt(s_name,
SgTypeVoid::createType(),
parameter_list,
scope);
SgStatementPtrList::iterator FirstStmt = Stmts.begin();
// Equivalent to above, I guess
// SgStatement* FirstStmt = SageInterface::getFirstStatement(scope);
SageInterface::insertStatementBefore(*FirstStmt,
NewFunction);
#if 1
SgName s_name2 ("EndClock");
SgExprListExp* parameter_list2 = SageBuilder::buildExprListExp();
SgExprStatement* NewFunction2 = SageBuilder::buildFunctionCallStmt(s_name2,
SgTypeVoid::createType(),
parameter_list2,
scope);
//SgStatementPtrList::iterator sit2 = Stmts.begin();
//SgStatement* LastStatement = SageInterface::getLastStatement(scope);
// FIXME: This is a dirty hack which uses the fact that the StatementPtrList
// is an ROSE_STL_Container, which is a standard STL vector
//SgStatement* LastStmt = Stmts[Stmts.size() - 1];
SgStatement* LastStmt = Stmts.back();
SageInterface::insertStatementBefore(LastStmt,
NewFunction2);
#endif
}
int main(int argc, char* argv[]) {
Rose_STL_Container<std::string> ArgList = CommandlineProcessing::generateArgListFromArgcArgv(argc, argv);
SgProject* project = frontend(argc, argv);
ROSE_ASSERT(project != NULL);
// So here's what we do... three steps...
// 1. preprocess the ast
// this is where all the simplify expressions,
// and other modifications before the main traversal
// happen
// 2. the main traversal
// this the top down bottom up traversal that
// feeds our instrumentation. It fills up the
// NodesToInstrument
// 3. the instrumentation
// this instruments the nodes provided in
// NodesToInstrument.
Util::setProject(project);
//generateDOT(*project); //RMM
#if 1
// preprocess the ast
printf("Preprocessing AST\n");
PPA::preProcess(project);
// the main traversal
printf("Main Traversal\n");
Trav::traverse(project);
// the instrumentation
printf("Instrumentation\n");
Instr::instrument(project);
#endif
#if 0
// CheckBase::CBProject = project;
#if 1
#if 0
ArithCheck AC;
AC.setProject(project);
AC.instrument();
#endif
#else
// Create the Check and Traversal objects
CheckBase* CB = new ArithCheck;
// printf("%lu\n", &(*CB));
#if 1
CB->instrument();
#else
bool plainRun = false;
for(Rose_STL_Container<std::string>::iterator rit = ArgList.begin(); rit != ArgList.end(); rit++) {
//printf("Arg: %s\n", *rit);
//std::cout << "Arg: " << *rit << "\n";
if(*rit == "-plain") {
plainRun = true;
break;
}
}
if(!plainRun) {
// checkbaseobject = CB;
//CB->registerCheck();
//CheckBase::RegisterBinaryOpCheck(CB);
// TraversalBase* TB = new QSTraversal;
TraversalBase* TB = new BinarySimpleTraversal;
// Let them know about each other
CheckBase::TBObj = TB;
TraversalBase::CBObj = CB;
// Traverse the tree, starting from SgProject
// Call CheckType if required
// FIXME: Would be great if we knew exactly when to call
// the process Node. Right now, we call it always --
// This is a basic one. Very bad performance
TB->nodeCollection(project);
TB->nodeInstrumentation(project);
}
else {
insertTimingSupport(project);
}
#endif
#endif
#endif
#if 0
printf("runAllTests\n");
AstTests::runAllTests(project);
printf("runAllTests - done\n");
#endif
#if 0
CppToDotTranslator c;
c.translate(argc, argv);
#endif
//generateAstGraph(project, 80000);
//generateDOT(*project);//RMM
printf("backend/unparser\n");
// backend = unparse + compile
// return backend(project);
project->unparse();
printf("backend/unparser - done\n");
return 0;
}
#endif
#ifndef RTC_H
#define RTC_H
//#include "CheckBase.h"
//#include "QSTraversal.h"
//#include "ArithCheck.h"
//#include "BinarySimpleTraversal.h"
#include "preProcessAST.h"
#include "instr.h"
#include "wholeAST.h"
//#include "traverse.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdint.h>
#include <map>
#include <stack>
#include <list>