@@ -475,7 +475,7 @@ static bool onestep(
475
475
}
476
476
477
477
// Weight of this step
478
- int weight = (node -> to_parent != NULL && ctx == node -> to_parent -> after ) ? 0 : 1 ;
478
+ int weight = (node -> to_parent == NULL || ctx == node -> to_parent -> after ) ? 0 : 1 ;
479
479
480
480
// Allocate edge now
481
481
struct edge * edge = walloc (w , sizeof (struct edge ) + step -> nlog * sizeof (hvalue_t ), false);
@@ -1190,6 +1190,7 @@ void path_dump(
1190
1190
struct state * oldstate ,
1191
1191
struct context * oldctx
1192
1192
) {
1193
+ static unsigned int oldpid = 0 ;
1193
1194
struct node * node = e -> dst ;
1194
1195
struct node * parent = e -> src ;
1195
1196
@@ -1205,14 +1206,21 @@ void path_dump(
1205
1206
fprintf (file , " \"id\": \"%d\",\n" , node -> id );
1206
1207
fprintf (file , " \"len\": \"%d\",\n" , node -> len );
1207
1208
1208
- /* Find the starting context in the list of processes.
1209
+ /* Find the starting context in the list of processes. Prefer
1210
+ * sticking with the same pid if possible.
1209
1211
*/
1210
1212
hvalue_t ctx = e -> ctx ;
1211
1213
unsigned int pid ;
1212
- for (pid = 0 ; pid < global -> nprocesses ; pid ++ ) {
1213
- if (global -> processes [pid ] == ctx ) {
1214
- break ;
1214
+ if (global -> processes [oldpid ] == ctx ) {
1215
+ pid = oldpid ;
1216
+ }
1217
+ else {
1218
+ for (pid = 0 ; pid < global -> nprocesses ; pid ++ ) {
1219
+ if (global -> processes [pid ] == ctx ) {
1220
+ break ;
1221
+ }
1215
1222
}
1223
+ oldpid = pid ;
1216
1224
}
1217
1225
assert (pid < global -> nprocesses );
1218
1226
// fprintf(file, " \"OLDPID\": \"%d\",\n", pid);
@@ -2269,7 +2277,7 @@ int main(int argc, char **argv){
2269
2277
}
2270
2278
2271
2279
#ifdef OBSOLETE
2272
- if (false ) {
2280
+ if (true ) {
2273
2281
FILE * df = fopen ("charm.dump" , "w" );
2274
2282
assert (df != NULL );
2275
2283
for (unsigned int i = 0 ; i < global -> graph .size ; i ++ ) {
@@ -2278,40 +2286,60 @@ int main(int argc, char **argv){
2278
2286
fprintf (df , "\nNode %d:\n" , node -> id );
2279
2287
fprintf (df , " component: %d\n" , node -> component );
2280
2288
if (node -> to_parent != NULL ) {
2281
- fprintf (df , " parent: %d\n" , node -> to_parent -> src -> id );
2289
+ fprintf (df , " ancestors:" );
2290
+ for (struct node * n = node -> to_parent -> src ;; n = n -> to_parent -> src ) {
2291
+ fprintf (df , " %u" , n -> id );
2292
+ if (n -> to_parent == NULL ) {
2293
+ break ;
2294
+ }
2295
+ }
2296
+ fprintf (df , "\n" );
2282
2297
}
2283
2298
fprintf (df , " vars: %s\n" , value_string (node -> state -> vars ));
2299
+ fprintf (df , " len: %u %u\n" , node -> len , node -> steps );
2284
2300
fprintf (df , " fwd:\n" );
2285
2301
int eno = 0 ;
2286
2302
for (struct edge * edge = node -> fwd ; edge != NULL ; edge = edge -> fwdnext , eno ++ ) {
2287
2303
fprintf (df , " %d:\n" , eno );
2288
2304
struct context * ctx = value_get (edge -> ctx , NULL );
2289
- // fprintf(df, " context: %s %s %d\n", value_string(ctx->name), value_string(ctx->arg), ctx->pc);
2290
- fprintf (df , " choice: %s\n" , value_string (edge -> choice ));
2291
2305
fprintf (df , " node: %d (%d)\n" , edge -> dst -> id , edge -> dst -> component );
2292
- fprintf (df , " log:" );
2293
- for (unsigned int j = 0 ; j < edge -> nlog ; j ++ ) {
2294
- char * p = value_string (edge -> log [j ]);
2295
- fprintf (df , " %s" , p );
2296
- free (p );
2306
+ fprintf (df , " context before: %" PRIx64 " %d\n" , edge -> ctx , ctx -> pc );
2307
+ ctx = value_get (edge -> after , NULL );
2308
+ fprintf (df , " context after: %" PRIx64 " %d\n" , edge -> after , ctx -> pc );
2309
+ if (edge -> choice != 0 ) {
2310
+ fprintf (df , " choice: %s\n" , value_string (edge -> choice ));
2311
+ }
2312
+ if (edge -> nlog > 0 ) {
2313
+ fprintf (df , " log:" );
2314
+ for (unsigned int j = 0 ; j < edge -> nlog ; j ++ ) {
2315
+ char * p = value_string (edge -> log [j ]);
2316
+ fprintf (df , " %s" , p );
2317
+ free (p );
2318
+ }
2319
+ fprintf (df , "\n" );
2297
2320
}
2298
- fprintf (df , "\n" );
2299
2321
}
2300
2322
fprintf (df , " bwd:\n" );
2301
2323
eno = 0 ;
2302
2324
for (struct edge * edge = node -> bwd ; edge != NULL ; edge = edge -> bwdnext , eno ++ ) {
2303
2325
fprintf (df , " %d:\n" , eno );
2304
- struct context * ctx = value_get (edge -> ctx , NULL );
2305
- // fprintf(df, " context: %s %s %d\n", value_string(ctx->name), value_string(ctx->arg), ctx->pc);
2306
- fprintf (df , " choice: %s\n" , value_string (edge -> choice ));
2307
2326
fprintf (df , " node: %d (%d)\n" , edge -> src -> id , edge -> src -> component );
2308
- fprintf (df , " log:" );
2309
- for (int j = 0 ; j < edge -> nlog ; j ++ ) {
2310
- char * p = value_string (edge -> log [j ]);
2311
- fprintf (df , " %s" , p );
2312
- free (p );
2327
+ struct context * ctx = value_get (edge -> ctx , NULL );
2328
+ fprintf (df , " context before: %" PRIx64 " %d\n" , edge -> ctx , ctx -> pc );
2329
+ ctx = value_get (edge -> after , NULL );
2330
+ fprintf (df , " context after: %" PRIx64 " %d\n" , edge -> after , ctx -> pc );
2331
+ if (edge -> choice != 0 ) {
2332
+ fprintf (df , " choice: %s\n" , value_string (edge -> choice ));
2333
+ }
2334
+ if (edge -> nlog > 0 ) {
2335
+ fprintf (df , " log:" );
2336
+ for (int j = 0 ; j < edge -> nlog ; j ++ ) {
2337
+ char * p = value_string (edge -> log [j ]);
2338
+ fprintf (df , " %s" , p );
2339
+ free (p );
2340
+ }
2341
+ fprintf (df , "\n" );
2313
2342
}
2314
- fprintf (df , "\n" );
2315
2343
}
2316
2344
}
2317
2345
fclose (df );
@@ -2443,6 +2471,9 @@ int main(int argc, char **argv){
2443
2471
bad = minheap_getmin (global -> failures );
2444
2472
}
2445
2473
2474
+ // printf("BAD: %d %"PRIx64" %"PRIx64"\n", bad->edge->dst->id,
2475
+ // bad->edge->ctx, bad->edge->after);
2476
+
2446
2477
switch (bad -> type ) {
2447
2478
case FAIL_SAFETY :
2448
2479
printf ("Safety Violation\n" );
0 commit comments