| 1 |
|
|---|
| 2 | exceptions:
|
|---|
| 3 |
|
|---|
| 4 | need to log exceptions and keep going, but backtrack as soon as
|
|---|
| 5 | pc is unsat.
|
|---|
| 6 |
|
|---|
| 7 | need to see if pc is sat before deciding there is an error to report.
|
|---|
| 8 |
|
|---|
| 9 | Enabler: evalutes guard, forms new path condition.
|
|---|
| 10 | check at this point that new path condition is sat.
|
|---|
| 11 |
|
|---|
| 12 | Evaluator: in the course of evaluation, pc may change, things
|
|---|
| 13 | may be checked. log errors
|
|---|
| 14 |
|
|---|
| 15 | evaluate:
|
|---|
| 16 | step 1, step 2, step 3 (check something, pc becomes unsat),
|
|---|
| 17 | step 4, step 5 (check something), ..., return
|
|---|
| 18 |
|
|---|
| 19 | When check something, first check if pc is false. Skip the check
|
|---|
| 20 | if it is.
|
|---|
| 21 |
|
|---|
| 22 | Let us assume pc is not certainly unsat when evaluate is called.
|
|---|
| 23 |
|
|---|
| 24 | Check protocol: check condition condsat. if consat OK, proceed.
|
|---|
| 25 | Otherwise: check pc satisfiability, pcsat
|
|---|
| 26 | - pcsat=YES && condsat=NO : certainty=PROVEABLE
|
|---|
| 27 | - pcsat=YES && condsat=MAYBE : certainty=MAYBE
|
|---|
| 28 | - pcsat=MAYBE && condsat=NO : MAYBE
|
|---|
| 29 | - pcsat=MAYBE && condsat=MAYBE : MAYBE
|
|---|
| 30 | - pcsat=NO: should not happen (assertion)
|
|---|
| 31 | Add claim to pc and check satisfiability of pc again.
|
|---|
| 32 | Add to the log report a note about recovery attempt:
|
|---|
| 33 | updating PC changed PC to MAYBE unsat, or definitely
|
|---|
| 34 | unsat, ...
|
|---|
| 35 | If pcsat=NO, throw UnsatisfiablePathConditionException.
|
|---|
| 36 | This gets thrown all the way up to Enabler or Executor.
|
|---|
| 37 |
|
|---|
| 38 | In Executor, the exception is caught, and the intermediate state
|
|---|
| 39 | (whatever the state was when the exception was thrown) with
|
|---|
| 40 | path condition set to false is returned.
|
|---|
| 41 |
|
|---|
| 42 | In Enabler, this happens when determining if a transition is enabled.
|
|---|
| 43 | I.e., in evaluating a guard, a side-effect occurred.
|
|---|
| 44 | Example: guard: a[i]=0. i might be out of range, what happens?
|
|---|
| 45 | The error has been logged, now pc is false, so don't include
|
|---|
| 46 | this transition in the list of enabled ones. No need to do
|
|---|
| 47 | anything with the exception.
|
|---|
| 48 |
|
|---|
| 49 | Enabler:
|
|---|
| 50 |
|
|---|
| 51 | when examining potential transition:
|
|---|
| 52 | form new path condition.
|
|---|
| 53 | check for satisfiability.
|
|---|
| 54 | if not certain unsat, add it.
|
|---|
| 55 |
|
|---|
| 56 | next state: after producing state, simplify and canonicalize.
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | Fundamentals:
|
|---|
| 60 |
|
|---|
| 61 | expression: $length(array)
|
|---|
| 62 | expression: $append(array, element)
|
|---|
| 63 | $concatenate, $remove,
|
|---|
| 64 |
|
|---|
| 65 | /* A system type for any segment of memory used as a buffer,
|
|---|
| 66 | * formed using union types */
|
|---|
| 67 | typedef struct __bundle__ $bundle;
|
|---|
| 68 |
|
|---|
| 69 | /* Creates a buffer from the memory region specified by
|
|---|
| 70 | * ptr and size, copying the data into the new buffer */
|
|---|
| 71 | $bundle $bundle_pack(void *ptr, int size);
|
|---|
| 72 |
|
|---|
| 73 | /* Copies the data out of the buffer into the region
|
|---|
| 74 | * specified */
|
|---|
| 75 | void $bundle_unpack($bundle bundle, void *ptr, int size);
|
|---|
| 76 |
|
|---|
| 77 | /* creates a new comm from the given sequence of processes,
|
|---|
| 78 | * by allocating memory and copying the process sequence;
|
|---|
| 79 | * the new comm has no messages */
|
|---|
| 80 | $comm $comm_create(int nprocs, $proc * procs);
|
|---|
| 81 |
|
|---|
| 82 | /* adds the message to the comm */
|
|---|
| 83 | void $comm_enqueue($comm * comm, $message * message);
|
|---|
| 84 |
|
|---|
| 85 | /* finds the first matching message, removes it from
|
|---|
| 86 | * comm, and returns pointer to message */
|
|---|
| 87 | $message * $comm_dequeue($comm * comm, int source, int dest, int tag);
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | Action Plan:
|
|---|
| 91 | - add a CIVLBundleType, similar to CIVLHeapType
|
|---|
| 92 | - collect all types during model building
|
|---|
| 93 | - complete the CIVLBundleType by giving it the list of all types,
|
|---|
| 94 | and the symbolic type which is the union of array of t_i
|
|---|
| 95 | - defined $bundle_pack in executor by:
|
|---|
| 96 | 1. let v = dereference ptr* (just first element)
|
|---|
| 97 | 2. let t = v.type();
|
|---|
| 98 | 3. array-of-t is the type of the bundle you will make by cases:
|
|---|
| 99 | a. is ptr to a variable, or an array element pointer, etc.
|
|---|
| 100 | create the new value of type array-of-t.
|
|---|
| 101 | 4. cast that to type bundleSymbolicType.
|
|---|
| 102 | 5. assign it to lhs.
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 | Consider CIVL-C dropping C's awful pointer-array pun.
|
|---|
| 108 | No automatic conversions. (Just drop them if language is CIVL-C).
|
|---|
| 109 |
|
|---|
| 110 | f(double[] a) : really takes an array of double, not pointer.
|
|---|
| 111 | double[] f(...) : returns an array of double
|
|---|
| 112 |
|
|---|
| 113 | To get the C behavior:
|
|---|
| 114 |
|
|---|
| 115 | f(double *p) {...}
|
|---|
| 116 |
|
|---|
| 117 | to call f: f(&a[0]);
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | How hard would it be to add a new type: $sequence<T>
|
|---|
| 125 | to the language? Like vector or variable length array.
|
|---|
| 126 | Then define functions like $append, $add, $remove,
|
|---|
| 127 | $subseq, blah blah: but these are all generic.
|
|---|
| 128 | Need concept of generic functions. Could make them
|
|---|
| 129 | operations.
|
|---|
| 130 |
|
|---|
| 131 | $buffer $buffer_create(void *ptr, $type element_type, int count);
|
|---|
| 132 |
|
|---|
| 133 | $buffer $buffer_pack(void *ptr, int size);
|
|---|
| 134 |
|
|---|
| 135 | Problem: what if type of ptr is just void*. Won't know statically
|
|---|
| 136 | all the types to form the union type. Without some sort of flow
|
|---|
| 137 | analysis, will have to assume every type is possible.
|
|---|
| 138 |
|
|---|
| 139 | flow analysis: look at occurrences of $buffer_pack
|
|---|
| 140 | if type of expression ptr is void*, look at what goes into that
|
|---|
| 141 | expression. pointer arithmetic: ptr argument, trace back
|
|---|
| 142 | through assignments, function calls. forget it.
|
|---|
| 143 |
|
|---|
| 144 | need union of all types.
|
|---|
| 145 |
|
|---|
| 146 | **** collect all types used in model **** easy
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 | do essentially the same thing, but take different args.
|
|---|
| 151 | If the element type is complete (and hence can use sizeof)
|
|---|
| 152 | the first can be defined as
|
|---|
| 153 | $buffer_pack(ptr, count*sizeof(t))
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 | Messages:
|
|---|
| 158 |
|
|---|
| 159 | $message_pack has to produce a message, but how?
|
|---|
| 160 | Use union type.
|
|---|
| 161 | Union over all types which can occur in message_pack.
|
|---|
| 162 | Inject.
|
|---|
| 163 | Need to extract value from slice of array.
|
|---|
| 164 | Wish I had symbolic operators for that.
|
|---|
| 165 | Could be single variable, entire array, slice of array
|
|---|
| 166 | slice of array: copy elements if concrete bounds, else
|
|---|
| 167 | need array - lambda (not yet implemented)
|
|---|
| 168 |
|
|---|
| 169 | stick in union type.
|
|---|
| 170 |
|
|---|
| 171 | tyedef struct __buffer__ __buffer__;
|
|---|
| 172 | typedef struct __message__ {
|
|---|
| 173 | int source;
|
|---|
| 174 | int dest;
|
|---|
| 175 | int tag;
|
|---|
| 176 | __buffer__ data;
|
|---|
| 177 | int size;
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | Translate __buffer__ to CIVLBufferType.
|
|---|
| 181 | Symbolic type: symbolicBufferType:
|
|---|
| 182 | Union-of-array-of-t_i, where t_i ranges over all types
|
|---|
| 183 | occuring in message pack calls.
|
|---|
| 184 |
|
|---|
| 185 | Implement $message_pack : just to create buffer
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | How about relaxing restriction from C that element types of
|
|---|
| 189 | arrays must be complete? Instead just generate error
|
|---|
| 190 | if you try to take sizeof such a thing.
|
|---|
| 191 | Instead of
|
|---|
| 192 | (double*)$malloc(&h, size)
|
|---|
| 193 | how about
|
|---|
| 194 | $alloc(&h, typeof(double), count);
|
|---|
| 195 |
|
|---|
| 196 | void* $alloc($heap *h, $type type, int count);
|
|---|
| 197 |
|
|---|
| 198 | Add to grammar: "$typeof(sizeable)" just like sizeof, but
|
|---|
| 199 | don't care about completeness.
|
|---|
| 200 | no sizeof required. Type of typeof is $dynamic. Why not "type".
|
|---|
| 201 | ---
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 | Think about moving more stuff into model factory, like pointer value
|
|---|
| 205 | manipulation
|
|---|
| 206 |
|
|---|
| 207 | better printing of model
|
|---|
| 208 |
|
|---|
| 209 | better printing of states during execution
|
|---|