Skip to content

Commit 26856bd

Browse files
author
Robbert van Renesse
committed
Shortened traces
1 parent 34e3d3a commit 26856bd

File tree

2 files changed

+55
-27
lines changed

2 files changed

+55
-27
lines changed

harmony_model_checker/charm/charm.c

+55-24
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static bool onestep(
475475
}
476476

477477
// 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;
479479

480480
// Allocate edge now
481481
struct edge *edge = walloc(w, sizeof(struct edge) + step->nlog * sizeof(hvalue_t), false);
@@ -1190,6 +1190,7 @@ void path_dump(
11901190
struct state *oldstate,
11911191
struct context *oldctx
11921192
) {
1193+
static unsigned int oldpid = 0;
11931194
struct node *node = e->dst;
11941195
struct node *parent = e->src;
11951196

@@ -1205,14 +1206,21 @@ void path_dump(
12051206
fprintf(file, " \"id\": \"%d\",\n", node->id);
12061207
fprintf(file, " \"len\": \"%d\",\n", node->len);
12071208

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.
12091211
*/
12101212
hvalue_t ctx = e->ctx;
12111213
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+
}
12151222
}
1223+
oldpid = pid;
12161224
}
12171225
assert(pid < global->nprocesses);
12181226
// fprintf(file, " \"OLDPID\": \"%d\",\n", pid);
@@ -2269,7 +2277,7 @@ int main(int argc, char **argv){
22692277
}
22702278

22712279
#ifdef OBSOLETE
2272-
if (false) {
2280+
if (true) {
22732281
FILE *df = fopen("charm.dump", "w");
22742282
assert(df != NULL);
22752283
for (unsigned int i = 0; i < global->graph.size; i++) {
@@ -2278,40 +2286,60 @@ int main(int argc, char **argv){
22782286
fprintf(df, "\nNode %d:\n", node->id);
22792287
fprintf(df, " component: %d\n", node->component);
22802288
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");
22822297
}
22832298
fprintf(df, " vars: %s\n", value_string(node->state->vars));
2299+
fprintf(df, " len: %u %u\n", node->len, node->steps);
22842300
fprintf(df, " fwd:\n");
22852301
int eno = 0;
22862302
for (struct edge *edge = node->fwd; edge != NULL; edge = edge->fwdnext, eno++) {
22872303
fprintf(df, " %d:\n", eno);
22882304
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));
22912305
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");
22972320
}
2298-
fprintf(df, "\n");
22992321
}
23002322
fprintf(df, " bwd:\n");
23012323
eno = 0;
23022324
for (struct edge *edge = node->bwd; edge != NULL; edge = edge->bwdnext, eno++) {
23032325
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));
23072326
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");
23132342
}
2314-
fprintf(df, "\n");
23152343
}
23162344
}
23172345
fclose(df);
@@ -2443,6 +2471,9 @@ int main(int argc, char **argv){
24432471
bad = minheap_getmin(global->failures);
24442472
}
24452473

2474+
// printf("BAD: %d %"PRIx64" %"PRIx64"\n", bad->edge->dst->id,
2475+
// bad->edge->ctx, bad->edge->after);
2476+
24462477
switch (bad->type) {
24472478
case FAIL_SAFETY:
24482479
printf("Safety Violation\n");

harmony_model_checker/charm/graph.h

-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ enum fail_type {
4848
FAIL_RACE
4949
};
5050

51-
// TODO: node->state should be equivalent to ((struct state *) node) - 1
52-
// This would save a little more memory.
5351
struct node {
5452
struct node *next; // for linked list
5553

@@ -66,7 +64,6 @@ struct node {
6664
bool final : 1; // only eternal threads left (TODO: need this?)
6765
bool visited : 1; // for busy wait detection
6866

69-
// TODO. Allocate the rest after model checking, or use union?
7067
// NFA compression
7168
bool reachable : 1;
7269
};

0 commit comments

Comments
 (0)