1 /* Defines interfaces for the applications and exports function calls that
2 the applications should use instead of the standard ones. */
14 #include "Hashtable.h"
21 void initializeanalysis()
23 exportmodel=new model("testabstract", "testmodel", "testspace", "teststruct", "testconcrete", "testrange");
31 struct timeval begin,end;
33 gettimeofday(&begin,NULL);
34 exportmodel->doabstraction();
35 exportmodel->getdomainrelation()->fixstuff();
36 bool found = exportmodel->docheck();
37 exportmodel->doconcrete();
38 gettimeofday(&end,NULL);
39 t=(end.tv_sec-begin.tv_sec)*1000000+end.tv_usec-begin.tv_usec;
41 #ifdef DEBUGMANYMESSAGES
44 exportmodel->getdomainrelation()->print();
45 printf("Time used for analysis(us): %ld\n",t);
49 /* This procedure invokes the tool.
50 If the model hasn't been initialized, it simply returns.
51 If a bug was constraint violation was found, displays a message
52 and terminates the program. */
53 void doanalysisfordebugging(char* msg)
55 if (exportmodel == NULL) {
56 printf("Initialize tool first...\n");
61 exportmodel->doabstraction();
63 //exportmodel->getdomainrelation()->fixstuff();
64 //bool found = exportmodel->docheck();
66 bool found = exportmodel->getdomainrelation()->fixstuff() || exportmodel->docheck();
68 #ifdef DEBUGMANYMESSAGES
69 exportmodel->getdomainrelation()->print();
81 // returns true if a violated constraint was found
82 unsigned long benchmark()
84 struct timeval begin,end;
86 gettimeofday(&begin,NULL);
87 exportmodel->doabstraction();
88 exportmodel->getdomainrelation()->fixstuff();
89 bool found = exportmodel->docheck();
90 exportmodel->doconcrete();
91 gettimeofday(&end,NULL);
92 t=(end.tv_sec-begin.tv_sec)*1000000+end.tv_usec-begin.tv_usec;
97 // insert errors that break the specs
100 struct timeval begin,end;
102 gettimeofday(&begin,NULL);
103 exportmodel->doabstraction();
104 exportmodel->getdomainrelation()->fixstuff();
107 exportmodel->breakspec();
109 printf("\n\nSpecs BROKEN \n\n");
113 exportmodel->docheck();
114 exportmodel->doconcrete();
115 gettimeofday(&end,NULL);
116 t=(end.tv_sec-begin.tv_sec)*1000000+end.tv_usec-begin.tv_usec;
118 printf("Time used for analysis(us): %ld\n",t);
122 // insert errors that do not break the specs
125 struct timeval begin,end;
127 gettimeofday(&begin,NULL);
128 exportmodel->doabstraction();
129 exportmodel->getdomainrelation()->fixstuff();
131 exportmodel->inserterrors();
134 printf("\n\nErrors INSERTED \n\n");
138 exportmodel->docheck();
139 exportmodel->doconcrete();
140 gettimeofday(&end,NULL);
141 t=(end.tv_sec-begin.tv_sec)*1000000+end.tv_usec-begin.tv_usec;
143 printf("Time used for analysis(us): %ld\n",t);
148 void resetanalysis() {
149 exportmodel->reset();
152 void addmapping(char *key, void * address, char *type) {
153 Hashtable *env=exportmodel->gethashtable();
154 env->put(key,new Element(address,exportmodel->getstructure(type)));//should be of badstruct
157 void addintmapping(char *key, int value) {
158 Hashtable *env=exportmodel->gethashtable();
159 env->put(key,new Element(value)); //should be of badstruct
162 void *ourcalloc(size_t nmemb, size_t size) {
163 typemap *tm=exportmodel->gettypemap();
164 void *oc=calloc(nmemb,size);
165 tm->allocate(oc,size*nmemb);
169 void *ourmalloc(size_t size) {
170 typemap *tm=exportmodel->gettypemap();
171 void *oc=malloc(size);
172 tm->allocate(oc,size);
176 void ourfree(void *ptr) {
177 typemap *tm=exportmodel->gettypemap();
182 void *ourrealloc(void *ptr, size_t size) {
183 typemap *tm=exportmodel->gettypemap();
184 void *orr=realloc(ptr,size);
193 tm->allocate(ptr,size);
196 void alloc(void *ptr,int size) {
197 typemap *tm=exportmodel->gettypemap();
198 tm->allocate(ptr,size);
201 void dealloc(void *ptr) {
202 typemap *tm=exportmodel->gettypemap();