Propagated new runtime changes to win32 target
authoredouard
Mon, 07 Dec 2009 13:55:13 +0100
changeset 469 a6a9b59636d8
parent 467 11638e373a65
child 470 337cb5041eda
Propagated new runtime changes to win32 target
targets/Win32/plc_Win32_main.c
--- a/targets/Win32/plc_Win32_main.c	Mon Dec 07 10:08:12 2009 +0100
+++ b/targets/Win32/plc_Win32_main.c	Mon Dec 07 13:55:13 2009 +0100
@@ -147,7 +147,14 @@
 int TryEnterDebugSection(void)
 {
 	//printf("TryEnterDebugSection\n");
-	return WaitForSingleObject(debug_sem, 0) == WAIT_OBJECT_0;
+    if(WaitForSingleObject(debug_sem, 0) == WAIT_OBJECT_0){
+        /* Only enter if debug active */
+        if(__DEBUG){
+            return 1;
+        }
+    ReleaseSemaphore(debug_sem, 1, NULL);
+    return 0;
+    }
 }
 
 void LeaveDebugSection(void)
@@ -171,7 +178,6 @@
 
 /* from plc_debugger.c */
 int WaitDebugData(unsigned long *tick)
-unsigned long WaitDebugData()
 {
     *tick = __debug_tick;
     /* Wait signal from PLC thread */
@@ -188,11 +194,12 @@
     ReleaseSemaphore(debug_wait_sem, 1, NULL);
 }
 
-void suspendDebug()
-{
-	__DEBUG = 0;
+void suspendDebug(int disable)
+{
     /* Prevent PLC to enter debug code */
 	WaitForSingleObject(debug_sem, INFINITE);
+    /*__DEBUG is protected by this mutex */
+    __DEBUG = !disable;
 }
 
 void resumeDebug()