Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--agent/tcf/services/breakpoints.c23
-rw-r--r--agent/tcf/services/runctrl.c21
-rw-r--r--agent/tcf/services/runctrl.h7
3 files changed, 29 insertions, 22 deletions
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c
index 9c404fa2..59fee9b9 100644
--- a/agent/tcf/services/breakpoints.c
+++ b/agent/tcf/services/breakpoints.c
@@ -289,23 +289,6 @@ static unsigned get_bp_access_types(BreakpointInfo * bp, int virtual_addr) {
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 @@ static void plant_instruction(BreakInstruction * bi) {
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 @@ static int remove_instruction(BreakInstruction * bi) {
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 BreakInstruction * add_instruction(Context * ctx, int virtual_addr,
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 3845f025..3093d37f 100644
--- a/agent/tcf/services/runctrl.c
+++ b/agent/tcf/services/runctrl.c
@@ -2241,6 +2241,23 @@ static Channel * select_skip_prologue_channel(void) {
}
#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 @@ static void sync_run_state(void) {
}
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 @@ static void run_safe_events(void * arg) {
}
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 7229e210..c1f1abab 100644
--- a/agent/tcf/services/runctrl.h
+++ b/agent/tcf/services/runctrl.h
@@ -113,6 +113,13 @@ extern int safe_context_single_step(Context * ctx);
*/
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.
*/

Back to the top