diff -r 8ce461a40855 -r eba2bbb2dd9a targets/plc_debug.c --- a/targets/plc_debug.c Sun Jan 06 02:00:07 2019 +0300 +++ b/targets/plc_debug.c Sun Jan 06 03:11:39 2019 +0300 @@ -10,8 +10,7 @@ * * * */ - -#ifdef TARGET_DEBUG_DISABLE +#ifdef TARGET_DEBUG_AND_RETAIN_DISABLE void __init_debug (void){} void __cleanup_debug (void){} @@ -26,6 +25,7 @@ #include #include +#ifndef TARGET_ONLINE_DEBUG_DISABLE #define BUFFER_SIZE %(buffer_size)d /* Atomically accessed variable for buffer state */ @@ -38,6 +38,8 @@ /* Buffer's cursor*/ static char* buffer_cursor = debug_buffer; +#endif + static unsigned int retain_offset = 0; /*** * Declare programs @@ -126,9 +128,12 @@ void __init_debug(void) { /* init local static vars */ +#ifndef TARGET_ONLINE_DEBUG_DISABLE buffer_cursor = debug_buffer; + buffer_state = BUFFER_FREE; +#endif + retain_offset = 0; - buffer_state = BUFFER_FREE; InitRetain(); /* Iterate over all variables to fill debug buffer */ if(CheckRetainBuffer()){ @@ -147,8 +152,11 @@ void __cleanup_debug(void) { +#ifndef TARGET_ONLINE_DEBUG_DISABLE buffer_cursor = debug_buffer; InitiateDebugTransfer(); +#endif + CleanupRetain(); } @@ -169,6 +177,8 @@ if(flags & ( __IEC_DEBUG_FLAG | __IEC_RETAIN_FLAG)){ USINT size = __get_type_enum_size(dsc->type); + +#ifndef TARGET_ONLINE_DEBUG_DISABLE if(flags & __IEC_DEBUG_FLAG){ /* copy visible variable to buffer */; if(do_debug){ @@ -192,6 +202,8 @@ memcpy(real_value_p, visible_value_p, size); } } +#endif + if(flags & __IEC_RETAIN_FLAG){ /* compute next cursor positon*/ unsigned int next_retain_offset = retain_offset + size; @@ -248,6 +260,8 @@ { retain_offset = 0; InValidateRetainBuffer(); + +#ifndef TARGET_ONLINE_DEBUG_DISABLE /* Check there is no running debugger re-configuration */ if(TryEnterDebugSection()){ /* Lock buffer */ @@ -273,13 +287,16 @@ __for_each_variable_do(RetainIterator); } LeaveDebugSection(); - }else{ + }else +#endif + { /* when not debugging, do only retain */ __for_each_variable_do(RetainIterator); } ValidateRetainBuffer(); } +#ifndef TARGET_ONLINE_DEBUG_DISABLE #define __RegisterDebugVariable_case_t(TYPENAME) \ case TYPENAME##_ENUM :\ ((__IEC_##TYPENAME##_t *)varp)->flags |= flags;\ @@ -362,6 +379,6 @@ } return wait_error; } - -#endif - +#endif +#endif +