targets/plc_debug.c
changeset 580 9dd978e6537c
parent 579 554ba6df4ee0
child 581 57605e8e89f0
equal deleted inserted replaced
579:554ba6df4ee0 580:9dd978e6537c
    99         /* increment cursor according size*/
    99         /* increment cursor according size*/
   100         retain_offset = next_retain_offset;
   100         retain_offset = next_retain_offset;
   101     }
   101     }
   102 }
   102 }
   103 
   103 
   104 int CheckRetainBuffer(void);
   104 extern int CheckRetainBuffer(void);
   105 
   105 
   106 void __init_debug(void)
   106 void __init_debug(void)
   107 {
   107 {
   108     /* init local static vars */
   108     /* init local static vars */
   109     buffer_cursor = debug_buffer;
   109     buffer_cursor = debug_buffer;
   185 }
   185 }
   186 
   186 
   187 extern int TryEnterDebugSection(void);
   187 extern int TryEnterDebugSection(void);
   188 extern long AtomicCompareExchange(long*, long, long);
   188 extern long AtomicCompareExchange(long*, long, long);
   189 extern void LeaveDebugSection(void);
   189 extern void LeaveDebugSection(void);
       
   190 extern void ValidateRetainBuffer(void);
       
   191 extern void InValidateRetainBuffer(void);
   190 
   192 
   191 void __publish_debug(void)
   193 void __publish_debug(void)
   192 {
   194 {
   193     retain_offset = 0;
   195     retain_offset = 0;
       
   196     InValidateRetainBuffer();
   194     /* Check there is no running debugger re-configuration */
   197     /* Check there is no running debugger re-configuration */
   195     if(TryEnterDebugSection()){
   198     if(TryEnterDebugSection()){
   196         /* Lock buffer */
   199         /* Lock buffer */
   197         long latest_state = AtomicCompareExchange(
   200         long latest_state = AtomicCompareExchange(
   198             &buffer_state,
   201             &buffer_state,
   215         LeaveDebugSection();
   218         LeaveDebugSection();
   216     }else{
   219     }else{
   217         /* when not debugging, do only retain */
   220         /* when not debugging, do only retain */
   218         __for_each_variable_do(RetainIterator);
   221         __for_each_variable_do(RetainIterator);
   219     }
   222     }
       
   223     ValidateRetainBuffer();
   220 }
   224 }
   221 
   225 
   222 #define __RegisterDebugVariable_case_t(TYPENAME) \
   226 #define __RegisterDebugVariable_case_t(TYPENAME) \
   223         case TYPENAME##_ENUM :\
   227         case TYPENAME##_ENUM :\
   224             ((__IEC_##TYPENAME##_t *)varp)->flags |= flags;\
   228             ((__IEC_##TYPENAME##_t *)varp)->flags |= flags;\