author | laurent |
Sat, 12 Dec 2009 20:49:07 +0100 | |
changeset 509 | aa5645a25d64 |
parent 507 | bf6f623d7450 |
child 511 | 518c30f2a507 |
permissions | -rw-r--r-- |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
1 |
/* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
2 |
* DEBUGGER code |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
3 |
* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
4 |
* On "publish", when buffer is free, debugger stores arbitrary variables |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
5 |
* content into, and mark this buffer as filled |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
6 |
* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
7 |
* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
8 |
* Buffer content is read asynchronously, (from non real time part), |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
9 |
* and then buffer marked free again. |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
10 |
* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
11 |
* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
12 |
* */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
13 |
#include "iec_types_all.h" |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
14 |
#include "POUS.h" |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
15 |
/*for memcpy*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
16 |
#include <string.h> |
335
c5f3f71e7260
fixed bug : buffer overflow when debugging PLC with python blocks
greg
parents:
280
diff
changeset
|
17 |
#include <stdio.h> |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
18 |
|
335
c5f3f71e7260
fixed bug : buffer overflow when debugging PLC with python blocks
greg
parents:
280
diff
changeset
|
19 |
#define BUFFER_SIZE %(buffer_size)d |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
20 |
#define MAX_SUBSCRIBTION %(subscription_table_count)d |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
21 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
22 |
/* Atomically accessed variable for buffer state */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
23 |
#define BUFFER_FREE 0 |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
24 |
#define BUFFER_BUSY 1 |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
25 |
static long buffer_state = BUFFER_FREE; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
26 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
27 |
/* The buffer itself */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
28 |
char debug_buffer[BUFFER_SIZE]; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
29 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
30 |
/* Buffer's cursor*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
31 |
static char* buffer_cursor = debug_buffer; |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
32 |
static unsigned int retain_offset = 0; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
33 |
/*** |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
34 |
* Declare programs |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
35 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
36 |
%(programs_declarations)s |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
37 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
38 |
/*** |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
39 |
* Declare global variables from resources and conf |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
40 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
41 |
%(extern_variables_declarations)s |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
42 |
|
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
43 |
typedef void(*__for_each_variable_do_fp)(void*, __IEC_types_enum); |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
44 |
void __for_each_variable_do(__for_each_variable_do_fp fp) |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
45 |
{ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
46 |
%(for_each_variable_do_code)s |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
47 |
} |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
48 |
|
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
49 |
__IEC_types_enum __find_variable(unsigned int varindex, void ** varp) |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
50 |
{ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
51 |
switch(varindex){ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
52 |
%(find_variable_case_code)s |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
53 |
default: |
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
54 |
*varp = NULL; |
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
55 |
return UNKNOWN_ENUM; |
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
56 |
} |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
57 |
} |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
58 |
|
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
59 |
#define __BufferDebugDataIterator_case_t(TYPENAME) \ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
60 |
case TYPENAME##_ENUM :\ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
61 |
*flags = ((__IEC_##TYPENAME##_t *)varp)->flags;\ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
62 |
*ptrvalue = &((__IEC_##TYPENAME##_t *)varp)->value;\ |
458
dfc6164e4022
Debugger still doesn't work crash less...
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
452
diff
changeset
|
63 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
64 |
|
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
65 |
#define __BufferDebugDataIterator_case_p(TYPENAME)\ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
66 |
case TYPENAME##_P_ENUM :\ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
67 |
*flags = ((__IEC_##TYPENAME##_p *)varp)->flags;\ |
507 | 68 |
if (*flags & __IEC_FORCE_FLAG)\ |
491
28afed8b1af5
Error in value send when debugging forced external or located variable fixed
laurent
parents:
483
diff
changeset
|
69 |
*ptrvalue = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\ |
28afed8b1af5
Error in value send when debugging forced external or located variable fixed
laurent
parents:
483
diff
changeset
|
70 |
else\ |
28afed8b1af5
Error in value send when debugging forced external or located variable fixed
laurent
parents:
483
diff
changeset
|
71 |
*ptrvalue = ((__IEC_##TYPENAME##_p *)varp)->value;\ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
72 |
break; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
73 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
74 |
void UnpackVar(void* varp, __IEC_types_enum vartype, void **ptrvalue, char *flags) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
75 |
{ |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
76 |
/* find data to copy*/ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
77 |
switch(vartype){ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
78 |
ANY(__BufferDebugDataIterator_case_t) |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
79 |
ANY(__BufferDebugDataIterator_case_p) |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
80 |
default: |
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
81 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
82 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
83 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
84 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
85 |
void Remind(unsigned int offset, unsigned int count, void * p); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
86 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
87 |
void RemindIterator(void* varp, __IEC_types_enum vartype) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
88 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
89 |
void *ptrvalue = NULL; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
90 |
char flags = 0; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
91 |
UnpackVar(varp, vartype, &ptrvalue, &flags); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
92 |
|
507 | 93 |
if(flags & __IEC_RETAIN_FLAG){ |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
94 |
USINT size = __get_type_enum_size(vartype); |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
95 |
/* compute next cursor positon*/ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
96 |
unsigned int next_retain_offset = retain_offset + size; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
97 |
/* if buffer not full */ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
98 |
Remind(retain_offset, size, ptrvalue); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
99 |
/* increment cursor according size*/ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
100 |
retain_offset = next_retain_offset; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
101 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
102 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
103 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
104 |
void __init_debug(void) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
105 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
106 |
/* init local static vars */ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
107 |
buffer_cursor = debug_buffer; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
108 |
retain_offset = 0; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
109 |
buffer_state = BUFFER_FREE; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
110 |
/* Iterate over all variables to fill debug buffer */ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
111 |
__for_each_variable_do(RemindIterator); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
112 |
retain_offset = 0; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
113 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
114 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
115 |
extern void InitiateDebugTransfer(void); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
116 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
117 |
extern unsigned long __tick; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
118 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
119 |
void __cleanup_debug(void) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
120 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
121 |
buffer_cursor = debug_buffer; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
122 |
InitiateDebugTransfer(); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
123 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
124 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
125 |
void __retrieve_debug(void) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
126 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
127 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
128 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
129 |
void DoDebug(void *ptrvalue, char flags, USINT size) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
130 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
131 |
/* compute next cursor positon*/ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
132 |
char* next_cursor = buffer_cursor + size; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
133 |
/* if buffer not full */ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
134 |
if(next_cursor <= debug_buffer + BUFFER_SIZE) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
135 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
136 |
/* copy data to the buffer */ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
137 |
memcpy(buffer_cursor, ptrvalue, size); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
138 |
/* increment cursor according size*/ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
139 |
buffer_cursor = next_cursor; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
140 |
}else{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
141 |
/*TODO : signal overflow*/ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
142 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
143 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
144 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
145 |
void Retain(unsigned int offset, unsigned int count, void * p); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
146 |
void DoRetain(void *ptrvalue, char flags, USINT size){ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
147 |
/* compute next cursor positon*/ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
148 |
unsigned int next_retain_offset = retain_offset + size; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
149 |
/* if buffer not full */ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
150 |
Retain(retain_offset, size, ptrvalue); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
151 |
/* increment cursor according size*/ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
152 |
retain_offset = next_retain_offset; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
153 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
154 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
155 |
void BufferDebugDataIterator(void* varp, __IEC_types_enum vartype) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
156 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
157 |
void *ptrvalue = NULL; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
158 |
char flags = 0; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
159 |
UnpackVar(varp, vartype, &ptrvalue, &flags); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
160 |
/* For optimization purpose we do retain and debug in the same pass */ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
161 |
if(flags & (__IEC_DEBUG_FLAG | __IEC_RETAIN_FLAG)){ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
162 |
USINT size = __get_type_enum_size(vartype); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
163 |
if(flags & __IEC_DEBUG_FLAG){ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
164 |
DoDebug(ptrvalue, flags, size); |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
165 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
166 |
if(flags & __IEC_RETAIN_FLAG){ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
167 |
DoRetain(ptrvalue, flags, size); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
168 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
169 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
170 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
171 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
172 |
void RetainIterator(void* varp, __IEC_types_enum vartype) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
173 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
174 |
void *ptrvalue = NULL; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
175 |
char flags = 0; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
176 |
UnpackVar(varp, vartype, &ptrvalue, &flags); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
177 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
178 |
if(flags & __IEC_RETAIN_FLAG){ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
179 |
USINT size = __get_type_enum_size(vartype); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
180 |
DoRetain(ptrvalue, flags, size); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
181 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
182 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
183 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
184 |
extern int TryEnterDebugSection(void); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
185 |
extern long AtomicCompareExchange(long*, long, long); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
186 |
extern void LeaveDebugSection(void); |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
187 |
|
423 | 188 |
void __publish_debug(void) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
189 |
{ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
190 |
retain_offset = 0; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
191 |
/* Check there is no running debugger re-configuration */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
192 |
if(TryEnterDebugSection()){ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
193 |
/* Lock buffer */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
194 |
long latest_state = AtomicCompareExchange( |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
195 |
&buffer_state, |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
196 |
BUFFER_FREE, |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
197 |
BUFFER_BUSY); |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
198 |
|
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
199 |
/* If buffer was free */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
200 |
if(latest_state == BUFFER_FREE) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
201 |
{ |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
202 |
/* Reset buffer cursor */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
203 |
buffer_cursor = debug_buffer; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
204 |
/* Iterate over all variables to fill debug buffer */ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
205 |
__for_each_variable_do(BufferDebugDataIterator); |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
206 |
|
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
207 |
/* Leave debug section, |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
208 |
* Trigger asynchronous transmission |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
209 |
* (returns immediately) */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
210 |
InitiateDebugTransfer(); /* size */ |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
211 |
} |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
212 |
LeaveDebugSection(); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
213 |
}else{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
214 |
/* when not debugging, do only retain */ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
215 |
__for_each_variable_do(RetainIterator); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
216 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
217 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
218 |
|
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
219 |
#define __RegisterDebugVariable_case_t(TYPENAME) \ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
220 |
case TYPENAME##_ENUM :\ |
477
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
221 |
((__IEC_##TYPENAME##_t *)varp)->flags |= flags;\ |
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
222 |
if(force)\ |
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
223 |
((__IEC_##TYPENAME##_t *)varp)->value = *((TYPENAME *)force);\ |
458
dfc6164e4022
Debugger still doesn't work crash less...
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
452
diff
changeset
|
224 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
225 |
#define __RegisterDebugVariable_case_p(TYPENAME)\ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
226 |
case TYPENAME##_P_ENUM :\ |
477
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
227 |
((__IEC_##TYPENAME##_p *)varp)->flags |= flags;\ |
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
228 |
if(force)\ |
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
229 |
((__IEC_##TYPENAME##_p *)varp)->fvalue = *((TYPENAME *)force);\ |
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
230 |
break; |
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
231 |
void RegisterDebugVariable(int idx, void* force) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
232 |
{ |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
233 |
void *varp = NULL; |
477
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
234 |
unsigned char flags = force ? __IEC_DEBUG_FLAG | __IEC_FORCE_FLAG : __IEC_DEBUG_FLAG; |
458
dfc6164e4022
Debugger still doesn't work crash less...
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
452
diff
changeset
|
235 |
switch(__find_variable(idx, &varp)){ |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
236 |
ANY(__RegisterDebugVariable_case_t) |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
237 |
ANY(__RegisterDebugVariable_case_p) |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
238 |
default: |
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
239 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
240 |
} |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
241 |
} |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
242 |
|
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
243 |
#define __ResetDebugVariablesIterator_case_t(TYPENAME) \ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
244 |
case TYPENAME##_ENUM :\ |
477
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
245 |
((__IEC_##TYPENAME##_t *)varp)->flags &= ~(__IEC_DEBUG_FLAG|__IEC_FORCE_FLAG);\ |
458
dfc6164e4022
Debugger still doesn't work crash less...
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
452
diff
changeset
|
246 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
247 |
|
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
248 |
#define __ResetDebugVariablesIterator_case_p(TYPENAME)\ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
249 |
case TYPENAME##_P_ENUM :\ |
477
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
250 |
((__IEC_##TYPENAME##_p *)varp)->flags &= ~(__IEC_DEBUG_FLAG|__IEC_FORCE_FLAG);\ |
458
dfc6164e4022
Debugger still doesn't work crash less...
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
452
diff
changeset
|
251 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
252 |
|
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
253 |
void ResetDebugVariablesIterator(void* varp, __IEC_types_enum vartype) |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
254 |
{ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
255 |
/* force debug flag to 0*/ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
256 |
switch(vartype){ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
257 |
ANY(__ResetDebugVariablesIterator_case_t) |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
258 |
ANY(__ResetDebugVariablesIterator_case_p) |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
259 |
default: |
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
260 |
break; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
261 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
262 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
263 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
264 |
void ResetDebugVariables(void) |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
265 |
{ |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
266 |
__for_each_variable_do(ResetDebugVariablesIterator); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
267 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
268 |
|
423 | 269 |
void FreeDebugData(void) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
270 |
{ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
271 |
/* atomically mark buffer as free */ |
423 | 272 |
long latest_state; |
273 |
latest_state = AtomicCompareExchange( |
|
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
274 |
&buffer_state, |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
275 |
BUFFER_BUSY, |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
276 |
BUFFER_FREE); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
277 |
} |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
278 |
int WaitDebugData(unsigned long *tick); |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
279 |
/* Wait until debug data ready and return pointer to it */ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
280 |
int GetDebugData(unsigned long *tick, unsigned long *size, void **buffer){ |
504 | 281 |
int wait_error = WaitDebugData(tick); |
282 |
if(!wait_error){ |
|
502 | 283 |
*size = buffer_cursor - debug_buffer; |
284 |
*buffer = debug_buffer; |
|
285 |
} |
|
504 | 286 |
return wait_error; |
287 |
} |
|
288 |