TCF Agent: changed assert(is_all_stopped(ctx)) to print offending contexts before failing the assertion
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c
index 9c404fa..59fee9b 100644
--- a/agent/tcf/services/breakpoints.c
+++ b/agent/tcf/services/breakpoints.c
@@ -289,23 +289,6 @@
return access_types;
}
-#ifndef NDEBUG
-static int print_not_stopped_contexts(Context * ctx) {
- LINK * l;
- Context * grp;
- if (is_all_stopped(ctx)) return 1;
- grp = context_get_group(ctx, CONTEXT_GROUP_STOP);
- fprintf(stderr, "Context group '%s':\n", grp->name ? grp->name : grp->id);
- for (l = context_root.next; l != &context_root; l = l->next) {
- Context * c = ctxl2ctxp(l);
- if (context_get_group(c, CONTEXT_GROUP_STOP) != grp) continue;
- fprintf(stderr, " ID %s, stopped %d, exiting %d, exited %d, signal %d\n",
- c->id, c->stopped, c->exiting, c->exited, c->signal);
- }
- return 0;
-}
-#endif
-
static int select_sw_breakpoint_isa(BreakInstruction * sw, uint8_t ** bp_encoding, size_t * bp_size) {
/* Software breakpoint should be rejected if opcode is unknown or ambiguous */
size_t size = 0;
@@ -354,7 +337,7 @@
assert(bi->valid);
assert(bi->ref_cnt > 0);
assert(bi->address_error == NULL);
- assert(print_not_stopped_contexts(bi->cb.ctx));
+ assert_all_stopped(bi->cb.ctx);
bi->saved_size = 0;
bi->unsupported = 0;
@@ -430,7 +413,7 @@
assert(bi->planted);
assert(bi->planting_error == NULL);
assert(bi->address_error == NULL);
- assert(print_not_stopped_contexts(bi->cb.ctx));
+ assert_all_stopped(bi->cb.ctx);
if (bi->saved_size) {
if (!bi->cb.ctx->exited) {
int r = 0;
@@ -506,7 +489,7 @@
static void clear_instruction_refs(Context * ctx, BreakpointInfo * bp) {
LINK * l = instructions.next;
- assert(print_not_stopped_contexts(ctx));
+ assert_all_stopped(ctx);
while (l != &instructions) {
unsigned i;
BreakInstruction * bi = link_all2bi(l);
diff --git a/agent/tcf/services/runctrl.c b/agent/tcf/services/runctrl.c
index 3845f02..3093d37 100644
--- a/agent/tcf/services/runctrl.c
+++ b/agent/tcf/services/runctrl.c
@@ -2241,6 +2241,23 @@
}
#endif
+#ifndef NDEBUG
+extern int print_not_stopped_contexts(Context * ctx) {
+ LINK * l;
+ Context * grp;
+ if (is_all_stopped(ctx)) return 1;
+ grp = context_get_group(ctx, CONTEXT_GROUP_STOP);
+ fprintf(stderr, "Context group '%s':\n", grp->name ? grp->name : grp->id);
+ for (l = context_root.next; l != &context_root; l = l->next) {
+ Context * c = ctxl2ctxp(l);
+ if (context_get_group(c, CONTEXT_GROUP_STOP) != grp) continue;
+ fprintf(stderr, " ID %s, stopped %d, exiting %d, exited %d, signal %d\n",
+ c->id, c->stopped, c->exiting, c->exited, c->signal);
+ }
+ return 0;
+}
+#endif
+
static void sync_run_state(void) {
int err_cnt = 0;
LINK * l;
@@ -2266,7 +2283,7 @@
}
else if (ext->step_mode == RM_TERMINATE || ext->step_mode == RM_DETACH) {
int md = ext->step_mode;
- assert(is_all_stopped(ctx));
+ assert_all_stopped(ctx);
if (context_resume(ctx, md, 0, 0) < 0) {
if (cache_miss_count() > 0) return;
resume_error(ctx, errno);
@@ -2502,7 +2519,7 @@
}
break;
}
- assert(is_all_stopped(i->ctx));
+ assert_all_stopped(i->ctx);
safe_event_list = i->next;
if (safe_event_list == NULL) safe_event_last = NULL;
if (i->done != NULL) {
diff --git a/agent/tcf/services/runctrl.h b/agent/tcf/services/runctrl.h
index 7229e21..c1f1aba 100644
--- a/agent/tcf/services/runctrl.h
+++ b/agent/tcf/services/runctrl.h
@@ -113,6 +113,13 @@
*/
extern void check_all_stopped(Context * ctx);
+#ifdef NDEBUG
+# define assert_all_stopped(ctx) ((void)0)
+#else
+# define assert_all_stopped(ctx) assert(print_not_stopped_contexts(ctx))
+extern int print_not_stopped_contexts(Context * ctx);
+#endif
+
/*
* Suspend current ACPM transaction until pending safe events are precessed.
*/