update debugging information in readme file
[satcheck.git] / eprecord.h
1 /*      Copyright (c) 2015 Regents of the University of California
2  *
3  *      Author: Brian Demsky <bdemsky@uci.edu>
4  *
5  *      This program is free software; you can redistribute it and/or
6  *      modify it under the terms of the GNU General Public License
7  *      version 2 as published by the Free Software Foundation.
8  */
9
10 #ifndef EPRECORD_H
11 #define EPRECORD_H
12 #include "epvalue.h"
13 #include "stl-model.h"
14 #include "cgoal.h"
15 #include "hashset.h"
16 #include "modeltypes.h"
17 #include <libinterface.h>
18 #include <stdio.h>
19
20 typedef ModelVector<EPValue *> ValueVector;
21 const char * eventToStr(EventType event);
22 struct RecordIDPair {
23         EPRecord *record;
24         EPRecord *idrecord;
25 };
26
27 inline unsigned int RIDP_hash_function(struct RecordIDPair * pair) {
28         return (unsigned int)(((uintptr_t)pair->record) >> 4) ^ ((uintptr_t)pair->idrecord);
29 }
30
31 inline bool RIDP_equals(struct RecordIDPair * key1, struct RecordIDPair * key2) {
32         if (key1==NULL)
33                 return key1==key2;
34         return key1->record == key2->record && key1->idrecord == key2->idrecord;
35 }
36
37 typedef HashSet<struct RecordIDPair *, uintptr_t, 0, model_malloc, model_calloc, model_free, RIDP_hash_function, RIDP_equals> EPRecordIDSet;
38
39 typedef HSIterator<struct RecordIDPair *, uintptr_t, 0, model_malloc, model_calloc, model_free, RIDP_hash_function, RIDP_equals> EPRecordIDIterator;
40
41 class EPRecord {
42 public:
43         EPRecord(EventType event, ExecPoint *execpoint, EPValue *branch, uintptr_t _offset, unsigned int numinputs,uint len,  bool anyvalue = false);
44         ~EPRecord();
45         ExecPoint * getEP() {return execpoint;}
46         void addEPValue(EPValue *v) {valuevector->push_back(v);}
47         bool hasAddr(const void *addr);
48         bool hasValue(uint64_t val);
49         unsigned int numValues() {return valuevector->size();}
50         EPValue * getValue(unsigned int i) {return (*valuevector)[i];}
51         EPValue * getBranch() {return branch;}
52         int getIndex(EPValue *v);
53         int getIndex(uint64_t val);
54         EventType getType() {return event;}
55         CGoalSet *completedGoalSet() {return completed;}
56         IntHashSet * getSet(unsigned int i) {return setarray[i];}
57         IntHashSet * getReturnValueSet();
58         IntHashSet * getStoreSet() { if (event==RMW) return setarray[VC_RMWOUTINDEX]; else return setarray[VC_BASEINDEX];}
59         uint getNumInputs() {return numinputs;}
60         uint getNumFuncInputs() {return numinputs-VC_BASEINDEX;}
61         bool getBranchAnyValue() {return anyvalue;}
62         void print();
63         void print(int fd);
64         EPRecord *getNextRecord() {return nextRecord;}
65         EPRecord *getChildRecord() {return childRecord;}
66         void setNextRecord(EPRecord * n) {nextRecord=n;}
67         void setChildRecord(EPRecord *n) {childRecord=n;}
68         bool getPhi() {return phi;}
69         void setPhi() {phi=true;}
70         bool getLoopPhi() {return loopphi;}
71         void setLoopPhi() {if (philooptable==NULL) philooptable=new EPRecordIDSet(); phi=true; loopphi=true;}
72         void setRMW(enum atomicop _op) {op=_op;}
73         enum atomicop getOp() {return op;}
74         uint getLen() {return len;}
75         void setJoinThread(thread_id_t _j) {jointhread=_j;}
76         thread_id_t getJoinThread() {return jointhread;}
77         EPRecordIDSet * getPhiLoopTable() {return philooptable;}
78         void setSize(size_t s) {size=s;}
79         size_t getSize() {return size;}
80         void setPtr(void *p) {ptr=p;}
81         void * getPtr() {return ptr;}
82         void setCompletedGoal(CGoalSet *c, bool shared) {completed=c;func_shares_goalset=shared;}
83         bool isSharedGoals() {return func_shares_goalset;}
84         uintptr_t getOffset() {return offset;}
85         MEMALLOC;
86
87 private:
88         ValueVector * valuevector;
89         ExecPoint * execpoint;
90         CGoalSet *completed;
91         EPValue *branch;
92         IntHashSet **setarray;
93         EPRecord *nextRecord;
94         EPRecord *childRecord;
95         EPRecordIDSet * philooptable;
96         uintptr_t offset;
97         EventType event;
98         thread_id_t jointhread;
99         unsigned int numinputs;
100         uint len;
101         bool anyvalue;
102         bool phi;
103         bool loopphi;
104         enum atomicop op;
105         size_t size;
106         bool func_shares_goalset;
107         void *ptr;
108 };
109
110 #endif