diff -r bcbc472c0ba8 -r 274e83a5534e targets/Linux/plc_Linux_main.c --- a/targets/Linux/plc_Linux_main.c Sun Dec 06 19:39:24 2009 +0100 +++ b/targets/Linux/plc_Linux_main.c Sun Dec 06 21:03:10 2009 +0100 @@ -85,7 +85,9 @@ sigev.sigev_notify_function = PLC_timer_notify; pthread_mutex_init(&debug_wait_mutex, NULL); + pthread_mutex_init(&debug_mutex, NULL); pthread_mutex_init(&python_wait_mutex, NULL); + pthread_mutex_init(&python_mutex, NULL); pthread_mutex_lock(&debug_wait_mutex); pthread_mutex_lock(&python_wait_mutex); @@ -95,10 +97,7 @@ PLC_SetTimer(Ttick,Ttick); /* install signal handler for manual break */ -// signal(SIGTERM, catch_signal); signal(SIGINT, catch_signal); - - pthread_mutex_trylock(&debug_mutex); }else{ return 1; } @@ -107,7 +106,14 @@ int TryEnterDebugSection(void) { - return pthread_mutex_trylock(&debug_mutex) == 0; + if (pthread_mutex_trylock(&debug_mutex) == 0){ + /* Only enter if debug active */ + if(__DEBUG){ + return 1; + } + } + pthread_mutex_unlock(&debug_mutex); + return 0; } void LeaveDebugSection(void) @@ -149,11 +155,12 @@ pthread_mutex_unlock(&debug_wait_mutex); } -void suspendDebug(void) -{ - __DEBUG = 0; +void suspendDebug(int disable) +{ /* Prevent PLC to enter debug code */ pthread_mutex_lock(&debug_mutex); + /*__DEBUG is protected by this mutex */ + __DEBUG = !disable; } void resumeDebug(void)