diff options
-rw-r--r-- | agent/tcf/services/runctrl.c | 20 | ||||
-rw-r--r-- | agent/tcf/services/runctrl.h | 9 |
2 files changed, 27 insertions, 2 deletions
diff --git a/agent/tcf/services/runctrl.c b/agent/tcf/services/runctrl.c index 64143719..06432cb2 100644 --- a/agent/tcf/services/runctrl.c +++ b/agent/tcf/services/runctrl.c @@ -138,6 +138,7 @@ static int run_ctrl_lock_cnt = 0; static int stop_all_timer_cnt = 0; static int stop_all_timer_posted = 0; static int run_safe_events_posted = 0; +static int sync_run_state_event_posted = 0; static AbstractCache safe_events_cache; @@ -2382,7 +2383,9 @@ static void sync_run_state(void) { static void sync_run_state_cache_client(void * args) { sync_run_state(); cache_exit(); - if (run_safe_events_posted || run_ctrl_lock_cnt > 0) return; + assert(sync_run_state_event_posted > 0); + sync_run_state_event_posted--; + if (run_safe_events_posted || sync_run_state_event_posted > 0 || run_ctrl_lock_cnt > 0) return; send_event_context_suspended(); } @@ -2422,6 +2425,7 @@ static void run_safe_events(void * arg) { if (run_safe_events_posted > 0) return; if (run_ctrl_lock_cnt == 0) { + sync_run_state_event_posted++; post_event(sync_run_state_event, NULL); return; } @@ -2638,6 +2642,20 @@ void set_context_state_name(Context * ctx, const char * name) { } } +int is_run_ctrl_idle(void) { + if (safe_event_list == NULL && run_ctrl_lock_cnt == 0 && + run_safe_events_posted == 0 && sync_run_state_event_posted == 0) { + LINK * l = context_root.next; + while (l != &context_root) { + ContextExtensionRC * ext = EXT(ctxl2ctxp(l)); + if (ext->run_ctrl_ctx_lock_cnt > 0) return 0; + l = l->next; + } + return 1; + } + return 0; +} + void add_run_control_event_listener(RunControlEventListener * listener, void * args) { if (listener_cnt >= listener_max) { listener_max += 8; diff --git a/agent/tcf/services/runctrl.h b/agent/tcf/services/runctrl.h index 018ab379..528e0fdd 100644 --- a/agent/tcf/services/runctrl.h +++ b/agent/tcf/services/runctrl.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -187,6 +187,13 @@ extern int get_stepping_mode(Context * ctx); */ extern void set_context_state_name(Context * ctx, const char * name); +/** + * Check that no safe events are pending, run control is not locked, + * and no temporary suspended contexts are waiting to be resumed. + * Clients might want to delay disconnecting from a target until run control is idle. + */ +extern int is_run_ctrl_idle(void); + /* RunControl event listener */ typedef struct RunControlEventListener { void (*context_intercepted)(Context * ctx, void * args); |