Report for ../logger2/logger2_por_seq.c

Generated on 2017-03-18 15:23:52 by CPAchecker 1.6.12-svcomp17

Matches in value-assignements (V): {{numOfValueMatches}}

Matches in edge-description: {{numOfDescriptionMatches}}

-V-
{{line.desc}}

Zoom Factor (%)

Run scripts/report-generator.py to display CFAs.

Zoom Factor (%)

Run scripts/report-generator.py to display ARG.

1
#include <assert.h>  
2
  
3
typedef unsigned int uint32_t;  
4
typedef unsigned short uint16_t;  
5
typedef unsigned char uint8_t;  
6
  
7
#define MAX_RECORDS  64  
8
uint8_t numberOfRecords;  
9
uint16_t records[MAX_RECORDS];  
10
  
11
#define MAX_BUFFER 16  
12
  
13
uint32_t periodCounter;   
14
uint16_t tickCounter;       
15
uint16_t period;       
16
uint32_t startTime;  
17
  
18
#define IDLE 0  
19
#define LOGGING 1  
20
#define SLEEP 2  
21
uint8_t systemState;  
22
  
23
#define CMD_DEC_OK 1  
24
#define CMD_DEC_ERROR 0  
25
#define RSP_SUCCESS 1  
26
#define RSP_ERROR 0  
27
  
28
#define CMD_RESTART 1  
29
#define CMD_STOP 2  
30
#define CMD_READ_STATE 3  
31
#define CMD_READ_DATA 4  
32
  
33
// Lihao  
34
const int __CPROVER_thread_priorities[] = {2, 5, 1};  
35
const char* __CPROVER_threads[] = {"c::task_communicate", "c::task_measure", "c::task_ext_power"};  
36
  
37
//void irq_err(void) {ERROR: goto ERROR;}  
38
void task_communicate(void);  
39
void task_measure(void);  
40
void task_ext_power(void);  
41
  
42
extern _Bool  __VERIFIER_nondet_bool();  
43
extern int __VERIFIER_nondet_int();  
44
extern void __VERIFIER_assume(int);  
45
  
46
extern void __VERIFIER_error() __attribute__ ((__noreturn__));  
47
void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } }  
48
  
49
/*void __VERIFIER_assert(int x)  
50
{  
51
  if(!x)  
52
    ERROR: goto ERROR;  
53
}*/  
54
  
55
// Scheduler  
56
int num_irqs = 3;  
57
int count = 4;  
58
  
59
int irq_enabled[] = {0, 0, 0};   
60
  
61
void enable_irq(int i) {  
62
  irq_enabled[i] = 1;    
63
}  
64
  
65
void disable_irq(int i) {  
66
  irq_enabled[i] = 0;    
67
}  
68
  
69
void schedule_irq(void) {  
70
  int j = count;  
71
  int irq;  
72
  
73
  for (int i = 0; i < j; i++) {  
74
    irq = __VERIFIER_nondet_int();  
75
    __VERIFIER_assume(irq >= 0 && irq < num_irqs);  
76
  
77
    if(irq_enabled[irq] && __VERIFIER_nondet_bool()) {  
78
      count--;  
79
  
80
      switch(irq) {  
81
        case 0:  
82
          task_communicate();  
83
          break;  
84
        case 1:  
85
          task_measure();  
86
          break;  
87
        case 2:  
88
          task_ext_power();  
89
          break;  
90
        default:  
91
          ;  
92
      }  
93
    }  
94
  }  
95
}  
96
  
97
  
98
void restart(uint32_t _startTime,uint16_t _period)  
99
{  
100
schedule_irq();  
101
  if (numberOfRecords+1 >= MAX_RECORDS) { // R-W dependency  
102
schedule_irq();  
103
    systemState = IDLE; // W-W dependency  
104
schedule_irq();  
105
  }  
106
schedule_irq();  
107
  periodCounter = 0; // W-W dependency  
108
schedule_irq();  
109
  tickCounter = 0; // W-W dependency  
110
schedule_irq();  
111
  numberOfRecords = 0; // W-W dependency  
112
schedule_irq();  
113
  startTime = _startTime; // W-W dependency  
114
schedule_irq();  
115
  period = _period; // W-W dependency  
116
schedule_irq();  
117
  systemState = LOGGING; // W-W dependency  
118
schedule_irq();  
119
}  
120
  
121
extern uint16_t read_sensor_value();  
122
extern uint16_t process_value(uint32_t time, uint16_t value);  
123
void task_measure(void) {  
124
disable_irq(0);  
125
disable_irq(1);  
126
disable_irq(2);  
127
  
128
  __VERIFIER_assume(systemState==LOGGING);  
129
  tickCounter++;  
130
  
131
  if (tickCounter == period) {  
132
    uint16_t value = read_sensor_value();  
133
    uint8_t pos = numberOfRecords;  
134
    uint32_t _startTime = startTime;  
135
    uint32_t currentTime = _startTime + period*periodCounter+tickCounter;  
136
   
137
    tickCounter = 0;  
138
    periodCounter++;  
139
      
140
    records[pos] =  process_value(currentTime,value);  
141
    numberOfRecords++;  
142
    //assert(startTime==_startTime);  
143
    __VERIFIER_assert(numberOfRecords==pos+1);  
144
    //assert(numberOfRecords==pos+1);  
145
    //if(numberOfRecords!=pos+1) irq_err();  
146
  }  
147
enable_irq(0);  
148
enable_irq(1);  
149
enable_irq(2);  
150
}  
151
  
152
extern uint8_t get_power_status();  
153
void task_ext_power() {  
154
disable_irq(1);  
155
disable_irq(2);  
156
enable_irq(0);  
157
  
158
  uint8_t power = get_power_status();  
159
  
160
schedule_irq();  
161
  if(power && systemState==SLEEP) { // R-W dependency  
162
schedule_irq();  
163
    systemState = IDLE; // W-W dependency  
164
schedule_irq();  
165
  }  
166
  
167
schedule_irq();  
168
  if(!power && systemState==IDLE) { // R-W dependency  
169
schedule_irq();  
170
    systemState = SLEEP; // W-W dependency  
171
schedule_irq();  
172
  }  
173
  
174
enable_irq(1);  
175
enable_irq(2);  
176
}  
177
  
178
uint8_t get_cmd(uint8_t* buffer, uint8_t* cmd) {  
179
}  
180
  
181
uint16_t get_uint16(uint8_t* buffer, uint8_t pos) {  
182
  return (((uint16_t)buffer[pos])<<8) | (uint16_t)buffer[pos+1];  
183
}  
184
void put_uint16(uint8_t* buffer, uint8_t pos, uint16_t val) {  
185
  buffer[pos] = (uint8_t)(val>>8);  
186
  buffer[pos+1] = (uint8_t)val;  
187
}  
188
uint32_t get_uint32(uint8_t* buffer, uint8_t pos) {  
189
  return (((uint32_t)buffer[pos])<<24) |   
190
         (((uint32_t)buffer[pos+1])<<16) |   
191
         (((uint32_t)buffer[pos+2])<<8) |   
192
         (uint32_t)buffer[pos+3];  
193
}  
194
void put_uint32(uint8_t* buffer, uint8_t pos, uint32_t val) {  
195
  buffer[pos] = (uint8_t)(val>>24);  
196
  buffer[pos+1] = (uint8_t)(val>>16);  
197
  buffer[pos+2] = (uint8_t)(val>>8);  
198
  buffer[pos+3] = (uint8_t)val;  
199
}  
200
extern uint8_t nondet_uint8();  
201
uint8_t receive_cmd(uint8_t* buffer) {  
202
  buffer[0] = nondet_uint8();  
203
  buffer[1] = nondet_uint8();  
204
  buffer[2] = nondet_uint8();  
205
  buffer[3] = nondet_uint8();  
206
  buffer[4] = nondet_uint8();  
207
  buffer[5] = nondet_uint8();  
208
  buffer[6] = nondet_uint8();  
209
}  
210
extern void send_response(uint8_t* buffer, uint8_t len);  
211
uint8_t msgBuffer[MAX_BUFFER];  
212
void task_communicate(void) {  
213
disable_irq(0);  
214
disable_irq(2);  
215
enable_irq(1);  
216
  
217
  __VERIFIER_assume(systemState!=SLEEP);  
218
  uint8_t len = receive_cmd(msgBuffer);  
219
  uint8_t cmd = msgBuffer[0];  
220
  uint8_t decodingStatus = CMD_DEC_ERROR;  
221
  if(cmd==CMD_STOP || cmd==CMD_READ_STATE || cmd==CMD_READ_DATA ||  
222
     cmd==CMD_RESTART) {  
223
    decodingStatus = CMD_DEC_OK;  
224
  }  
225
  if (decodingStatus != CMD_DEC_OK) {  
226
    msgBuffer[0] = RSP_ERROR;  
227
    send_response(msgBuffer,1);  
228
  } else {  
229
    uint8_t rspStatus = RSP_SUCCESS;  
230
    switch(cmd) {  
231
      case CMD_STOP:     
232
        if (systemState != LOGGING) {  
233
          rspStatus = RSP_ERROR;  
234
        } else {  
235
schedule_irq();  
236
          systemState = IDLE; // W-W dependency  
237
schedule_irq();  
238
        }  
239
        msgBuffer[0] = rspStatus;  
240
        if(systemState==SLEEP) {  
241
          return;  
242
        }  
243
        send_response(msgBuffer,1);  
244
        break;  
245
      case CMD_READ_STATE:  
246
        msgBuffer[0] = rspStatus;  
247
        msgBuffer[1] = systemState;  
248
schedule_irq();  
249
        msgBuffer[2] = numberOfRecords; // R-W dependency  
250
        put_uint32(msgBuffer,3,startTime);  
251
        if(systemState==SLEEP) {  
252
          return;  
253
        }  
254
        send_response(msgBuffer,7);  
255
	break;  
256
      case CMD_READ_DATA: {  
257
        uint8_t pos = msgBuffer[1];  
258
schedule_irq();  
259
        if(pos>=numberOfRecords) { // R-W dependency  
260
          msgBuffer[0] = RSP_ERROR;  
261
          if(systemState==SLEEP) {  
262
            return;  
263
          }  
264
          send_response(msgBuffer,1);  
265
  	} else {  
266
          msgBuffer[0] = RSP_SUCCESS;  
267
schedule_irq();  
268
          put_uint16(msgBuffer,1,records[pos]); // R-W dependency  
269
          if(systemState==SLEEP) {  
270
            return;  
271
          }  
272
          send_response(msgBuffer,3);  
273
	}  
274
	break;  
275
      }  
276
      case CMD_RESTART: {  
277
        uint32_t _startTime = get_uint32(msgBuffer,1);  
278
        uint16_t _period = get_uint16(msgBuffer,5);  
279
        restart(_startTime,_period);  
280
        msgBuffer[0] = rspStatus;  
281
        if(systemState==SLEEP) {  
282
          return;  
283
        }  
284
        send_response(msgBuffer,1);  
285
        break;  
286
      }  
287
      default:   
288
        break;  
289
    }  
290
  }  
291
  
292
enable_irq(0);  
293
enable_irq(2);  
294
}  
295
  
296
  
297
void initialize(void) {  
298
  systemState = SLEEP; // W-W dependency  
299
  periodCounter = 0; // W-W dependency  
300
  tickCounter = 0; // W-W dependency  
301
  startTime = 0; // W-W dependency  
302
  numberOfRecords = 0; // W-W dependency  
303
}  
304
  
305
void run(void)  
306
{  
307
// Lihao  
308
enable_irq(0);  
309
enable_irq(1);  
310
enable_irq(2);  
311
schedule_irq();  
312
  
313
  // while(1) {  
314
  /*  
315
    __CPROVER_ASYNC_1:   
316
    task_ext_power();  
317
  
318
    __CPROVER_ASYNC_1:   
319
    task_communicate();  
320
  
321
    __CPROVER_ASYNC_1:   
322
    task_communicate();  
323
  
324
    __CPROVER_ASYNC_1:   
325
    task_measure();  
326
  */  
327
    //  }  
328
}  
329
  
330
void main() {  
331
    initialize();  
332
    run();  
333
}  
2017-03-18 15:23:51:757	INFO	ResourceLimitChecker.fromConfiguration	Using the following resource limits: CPU-time limit of 900s

2017-03-18 15:23:51:789	INFO	CPAchecker.run	CPAchecker 1.6.12-svcomp17 (OpenJDK 64-Bit Server VM 1.8.0_121) started

2017-03-18 15:23:52:652	WARNING	CPAchecker.printConfigurationWarnings	The following configuration options were specified but are not used:
 cpa.callstack.skipVoidRecursion 


2017-03-18 15:23:52:653	INFO	CPAchecker.runAlgorithm	Starting analysis ...

2017-03-18 15:23:52:694	INFO	CPAchecker.runAlgorithm	Stopping analysis ...

    
AutomatonAnalysis (SVCOMP) statistics
-------------------------------------
Number of states:                                  1
Total time for successor computation:                  0.005s
Automaton transfers with branching:                0
Automaton transfer successors:                          275 (count: 275, min: 1, max: 1, avg: 1.00) [1 x 275]

CPA algorithm statistics
------------------------
Number of iterations:            218
Max size of waitlist:            34
Average size of waitlist:        15
Number of computed successors:   275
Max successors for one state:    22
Number of times merged:          0
Number of times stopped:         37
Number of times breaked:         1

Total time for CPA algorithm:         0.040s (Max:     0.040s)
  Time for choose from waitlist:      0.000s
  Time for precision adjustment:      0.017s
  Time for transfer relation:         0.015s
  Time for stop operator:             0.002s
  Time for adding to reached set:     0.002s

Code Coverage
-----------------------------
  Function coverage:      0.588
  Visited lines:          142
  Total lines:            176
  Line coverage:          0.807
  Visited conditions:     45
  Total conditions:       68
  Condition coverage:     0.662

CPAchecker general statistics
-----------------------------
Number of program locations:     306
Number of CFA edges:             373
Number of relevant variables:    30
Number of functions:             17
Number of loops:                 1
Size of reached set:             239
  Number of reached locations:   239 (78%)
    Avg states per location:     1
    Max states per location:     1 (at node N0)
  Number of reached functions:   13 (76%)
  Number of partitions:          239
    Avg size of partitions:      1
    Max size of partitions:      1
  Number of target states:       1
  Size of final wait list        21

Time for analysis setup:          0.852s
  Time for loading CPAs:          0.223s
  Time for loading parser:        0.199s
  Time for CFA construction:      0.404s
    Time for parsing file(s):     0.143s
    Time for AST to CFA:          0.107s
    Time for CFA sanity check:    0.000s
    Time for post-processing:     0.097s
      Time for var class.:        0.064s
    Time for CFA export:          0.096s
Time for Analysis:                0.040s
CPU time for analysis:            0.160s
Time for analyzing result:        0.001s
Total time for CPAchecker:        0.896s
Total CPU time for CPAchecker:    2.860s
Time for statistics:              0.019s

Time for Garbage Collector:       0.000s (in 0 runs)
Garbage Collector(s) used:    PS MarkSweep, PS Scavenge
Used heap memory:                135MB (   129 MiB) max;     88MB (    84 MiB) avg;    139MB (   132 MiB) peak
Used non-heap memory:             27MB (    26 MiB) max;     21MB (    20 MiB) avg;     29MB (    27 MiB) peak
Used in PS Old Gen pool:           0MB (     0 MiB) max;      0MB (     0 MiB) avg;      0MB (     0 MiB) peak
Allocated heap memory:           759MB (   724 MiB) max;    759MB (   724 MiB) avg
Allocated non-heap memory:        28MB (    27 MiB) max;     22MB (    21 MiB) avg
Total process virtual memory:  14231MB ( 13572 MiB) max;  14126MB ( 13471 MiB) avg

    
analysis.entryFunction = main
analysis.programNames = ../logger2/logger2_por_seq.c
cpa.callstack.skipVoidRecursion = false
limits.time.cpu = 900
log.level = INFO
parser.usePreprocessor = true
specification = config/specification/sv-comp-reachability.spc