Deduplicate entries in witness error message
This commit is contained in:
parent
f1f8a75496
commit
0295aa38a2
@ -14,15 +14,42 @@ witness_init(witness_t *witness, const char *name, witness_rank_t rank,
|
||||
witness->opaque = opaque;
|
||||
}
|
||||
|
||||
static void
|
||||
witness_print_witness(witness_t *w, unsigned n) {
|
||||
assert(n > 0);
|
||||
if (n == 1) {
|
||||
malloc_printf(" %s(%u)", w->name, w->rank);
|
||||
} else {
|
||||
malloc_printf(" %s(%u)X%u", w->name, w->rank, n);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
witness_print_witnesses(const witness_list_t *witnesses) {
|
||||
witness_t *w, *last = NULL;
|
||||
unsigned n = 0;
|
||||
ql_foreach(w, witnesses, link) {
|
||||
if (last != NULL && w->rank > last->rank) {
|
||||
assert(w->name != last->name);
|
||||
witness_print_witness(last, n);
|
||||
n = 0;
|
||||
} else if (last != NULL) {
|
||||
assert(w->rank == last->rank);
|
||||
assert(w->name == last->name);
|
||||
}
|
||||
last = w;
|
||||
++n;
|
||||
}
|
||||
if (last != NULL) {
|
||||
witness_print_witness(last, n);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
witness_lock_error_impl(const witness_list_t *witnesses,
|
||||
const witness_t *witness) {
|
||||
witness_t *w;
|
||||
|
||||
malloc_printf("<jemalloc>: Lock rank order reversal:");
|
||||
ql_foreach(w, witnesses, link) {
|
||||
malloc_printf(" %s(%u)", w->name, w->rank);
|
||||
}
|
||||
witness_print_witnesses(witnesses);
|
||||
malloc_printf(" %s(%u)\n", witness->name, witness->rank);
|
||||
abort();
|
||||
}
|
||||
@ -49,13 +76,9 @@ witness_not_owner_error_t *JET_MUTABLE witness_not_owner_error =
|
||||
static void
|
||||
witness_depth_error_impl(const witness_list_t *witnesses,
|
||||
witness_rank_t rank_inclusive, unsigned depth) {
|
||||
witness_t *w;
|
||||
|
||||
malloc_printf("<jemalloc>: Should own %u lock%s of rank >= %u:", depth,
|
||||
(depth != 1) ? "s" : "", rank_inclusive);
|
||||
ql_foreach(w, witnesses, link) {
|
||||
malloc_printf(" %s(%u)", w->name, w->rank);
|
||||
}
|
||||
witness_print_witnesses(witnesses);
|
||||
malloc_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user