author | Edouard Tisserant |
Wed, 01 Dec 2021 09:54:02 +0100 | |
branch | RuntimeLists |
changeset 3394 | 9ea29ac18837 |
parent 2710 | aaa1dc426213 |
child 3395 | 93ad018fb602 |
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 |
* */ |
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
13 |
#ifdef TARGET_DEBUG_AND_RETAIN_DISABLE |
1800
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
14 |
|
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
15 |
void __init_debug (void){} |
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
16 |
void __cleanup_debug (void){} |
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
17 |
void __retrieve_debug(void){} |
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
18 |
void __publish_debug (void){} |
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
19 |
|
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
20 |
#else |
1711339585ce
make possible to turn off at compile time online debugging, logging
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1677
diff
changeset
|
21 |
|
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
22 |
#include "iec_types_all.h" |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
23 |
#include "POUS.h" |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
24 |
/*for memcpy*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
25 |
#include <string.h> |
335
c5f3f71e7260
fixed bug : buffer overflow when debugging PLC with python blocks
greg
parents:
280
diff
changeset
|
26 |
#include <stdio.h> |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
27 |
|
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
28 |
#ifndef TARGET_ONLINE_DEBUG_DISABLE |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
29 |
#define TRACE_BUFFER_SIZE 4096 |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
30 |
#define TRACE_LIST_SIZE 1024 |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
31 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
32 |
/* Atomically accessed variable for buffer state */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
33 |
#define BUFFER_FREE 0 |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
34 |
#define BUFFER_BUSY 1 |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
35 |
static long trace_buffer_state = BUFFER_FREE; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
36 |
|
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
37 |
typedef unsigned int dbgvardsc_index_t; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
38 |
typedef unsigned short trace_buf_offset_t; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
39 |
|
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
40 |
typedef struct trace_item_s { |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
41 |
dbgvardsc_index_t dbgvardsc_index; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
42 |
} trace_item_t; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
43 |
|
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
44 |
trace_item_t trace_list[TRACE_LIST_SIZE]; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
45 |
char trace_buffer[TRACE_BUFFER_SIZE]; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
46 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
47 |
/* Buffer's cursor*/ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
48 |
static trace_item_t *trace_list_collect_cursor = trace_list; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
49 |
static trace_item_t *trace_list_addvar_cursor = trace_list; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
50 |
static const trace_item_t *trace_list_end = |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
51 |
&trace_list[TRACE_LIST_SIZE-1]; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
52 |
static char *trace_buffer_cursor = trace_buffer; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
53 |
static const char *trace_buffer_end = trace_buffer + TRACE_BUFFER_SIZE; |
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
54 |
#endif |
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
55 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
56 |
static unsigned int retain_offset = 0; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
57 |
/*** |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
58 |
* Declare programs |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
59 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
60 |
%(programs_declarations)s |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
61 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
62 |
/*** |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
63 |
* Declare global variables from resources and conf |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
64 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
65 |
%(extern_variables_declarations)s |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
66 |
|
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
67 |
typedef const struct { |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
68 |
void *ptr; |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
69 |
__IEC_types_enum type; |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
70 |
} dbgvardsc_t; |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
71 |
|
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
72 |
static dbgvardsc_t dbgvardsc[] = { |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
73 |
%(variable_decl_array)s |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
74 |
}; |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
75 |
|
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
76 |
typedef void(*__for_each_variable_do_fp)(dbgvardsc_t*); |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
77 |
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
|
78 |
{ |
2190
b7d803fc44db
Fix compilation warning/error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2172
diff
changeset
|
79 |
unsigned int i; |
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
80 |
for(i = 0; i < sizeof(dbgvardsc)/sizeof(dbgvardsc_t); i++){ |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
81 |
dbgvardsc_t *dsc = &dbgvardsc[i]; |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
82 |
if(dsc->type != UNKNOWN_ENUM) |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
83 |
(*fp)(dsc); |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
84 |
} |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
85 |
} |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
86 |
|
2632
534387caf43d
variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
2501
diff
changeset
|
87 |
#define __Unpack_desc_type dbgvardsc_t |
534387caf43d
variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
2501
diff
changeset
|
88 |
|
534387caf43d
variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
2501
diff
changeset
|
89 |
%(var_access_code)s |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
90 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
91 |
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
|
92 |
|
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
93 |
void RemindIterator(dbgvardsc_t *dsc) |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
94 |
{ |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
95 |
void *real_value_p = NULL; |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
96 |
char flags = 0; |
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
97 |
UnpackVar(dsc, &real_value_p, &flags); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
98 |
|
507 | 99 |
if(flags & __IEC_RETAIN_FLAG){ |
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
100 |
USINT size = __get_type_enum_size(dsc->type); |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
101 |
/* compute next cursor positon*/ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
102 |
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
|
103 |
/* if buffer not full */ |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
104 |
Remind(retain_offset, size, real_value_p); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
105 |
/* increment cursor according size*/ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
106 |
retain_offset = next_retain_offset; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
107 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
108 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
109 |
|
580 | 110 |
extern int CheckRetainBuffer(void); |
1457
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1432
diff
changeset
|
111 |
extern void InitRetain(void); |
521
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
511
diff
changeset
|
112 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
113 |
void __init_debug(void) |
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 |
/* init local static vars */ |
2710
aaa1dc426213
plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2632
diff
changeset
|
116 |
#ifndef TARGET_ONLINE_DEBUG_DISABLE |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
117 |
trace_buffer_cursor = trace_buffer; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
118 |
trace_list_addvar_cursor = trace_list; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
119 |
trace_list_collect_cursor = trace_list; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
120 |
trace_buffer_state = BUFFER_FREE; |
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
121 |
#endif |
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
122 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
123 |
retain_offset = 0; |
1457
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1432
diff
changeset
|
124 |
InitRetain(); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
125 |
/* Iterate over all variables to fill debug buffer */ |
1459
c9065fb5de0a
Added log message when RETAIN memory not valid
Edouard Tisserant
parents:
1457
diff
changeset
|
126 |
if(CheckRetainBuffer()){ |
2710
aaa1dc426213
plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2632
diff
changeset
|
127 |
__for_each_variable_do(RemindIterator); |
1459
c9065fb5de0a
Added log message when RETAIN memory not valid
Edouard Tisserant
parents:
1457
diff
changeset
|
128 |
}else{ |
2710
aaa1dc426213
plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2632
diff
changeset
|
129 |
char mstr[] = "RETAIN memory invalid - defaults used"; |
1459
c9065fb5de0a
Added log message when RETAIN memory not valid
Edouard Tisserant
parents:
1457
diff
changeset
|
130 |
LogMessage(LOG_WARNING, mstr, sizeof(mstr)); |
c9065fb5de0a
Added log message when RETAIN memory not valid
Edouard Tisserant
parents:
1457
diff
changeset
|
131 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
132 |
retain_offset = 0; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
133 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
134 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
135 |
extern void InitiateDebugTransfer(void); |
1457
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1432
diff
changeset
|
136 |
extern void CleanupRetain(void); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
137 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
138 |
extern unsigned long __tick; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
139 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
140 |
void __cleanup_debug(void) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
141 |
{ |
2710
aaa1dc426213
plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2632
diff
changeset
|
142 |
#ifndef TARGET_ONLINE_DEBUG_DISABLE |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
143 |
trace_buffer_cursor = trace_buffer; |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
144 |
InitiateDebugTransfer(); |
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
145 |
#endif |
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
146 |
|
1457
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1432
diff
changeset
|
147 |
CleanupRetain(); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
148 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
149 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
150 |
void __retrieve_debug(void) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
151 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
152 |
} |
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 Retain(unsigned int offset, unsigned int count, void * p); |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
156 |
|
1479
8f41aa88aa46
fix many compilation warnings about static variables used by non-static functions
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1459
diff
changeset
|
157 |
static inline void BufferIterator(dbgvardsc_t *dsc, int do_debug) |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
158 |
{ |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
159 |
void *real_value_p = NULL; |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
160 |
void *visible_value_p = NULL; |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
161 |
char flags = 0; |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
162 |
|
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
163 |
visible_value_p = UnpackVar(dsc, &real_value_p, &flags); |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
164 |
|
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
165 |
if(flags & __IEC_RETAIN_FLAG || |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
166 |
((flags & __IEC_FORCE_FLAG) && (flags & __IEC_OUTPUT_FLAG))){ |
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
167 |
USINT size = __get_type_enum_size(dsc->type); |
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
168 |
|
2710
aaa1dc426213
plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2632
diff
changeset
|
169 |
#ifndef TARGET_ONLINE_DEBUG_DISABLE |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
170 |
if((flags & __IEC_FORCE_FLAG) && (flags & __IEC_OUTPUT_FLAG)){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
171 |
if(__Is_a_string(dsc)){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
172 |
/* optimization for strings */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
173 |
size = ((STRING*)visible_value_p)->len + 1; |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
174 |
} |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
175 |
/* re-force real value of outputs (M and Q)*/ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
176 |
memcpy(real_value_p, visible_value_p, size); |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
177 |
} |
2710
aaa1dc426213
plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2632
diff
changeset
|
178 |
#endif |
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
179 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
180 |
if(flags & __IEC_RETAIN_FLAG){ |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
181 |
/* compute next cursor positon*/ |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
182 |
unsigned int next_retain_offset = retain_offset + size; |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
183 |
/* if buffer not full */ |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
184 |
Retain(retain_offset, size, real_value_p); |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
185 |
/* increment cursor according size*/ |
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
186 |
retain_offset = next_retain_offset; |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
187 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
188 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
189 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
190 |
|
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
191 |
void DebugIterator(dbgvardsc_t *dsc){ |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
192 |
BufferIterator(dsc, 1); |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
193 |
} |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
194 |
|
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
195 |
void RetainIterator(dbgvardsc_t *dsc){ |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
196 |
BufferIterator(dsc, 0); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
197 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
198 |
|
2172
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
199 |
|
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
200 |
unsigned int retain_size = 0; |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
201 |
|
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
202 |
/* GetRetainSizeIterator */ |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
203 |
void GetRetainSizeIterator(dbgvardsc_t *dsc) |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
204 |
{ |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
205 |
void *real_value_p = NULL; |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
206 |
char flags = 0; |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
207 |
UnpackVar(dsc, &real_value_p, &flags); |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
208 |
|
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
209 |
if(flags & __IEC_RETAIN_FLAG){ |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
210 |
USINT size = __get_type_enum_size(dsc->type); |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
211 |
/* Calc retain buffer size */ |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
212 |
retain_size += size; |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
213 |
} |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
214 |
} |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
215 |
|
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
216 |
/* Return size of all retain variables */ |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
217 |
unsigned int GetRetainSize(void) |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
218 |
{ |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
219 |
__for_each_variable_do(GetRetainSizeIterator); |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
220 |
return retain_size; |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
221 |
} |
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
222 |
|
9fa5be79bb77
Add helper function GetRetainSize()
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1800
diff
changeset
|
223 |
|
969 | 224 |
extern void PLC_GetTime(IEC_TIME*); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
225 |
extern int TryEnterDebugSection(void); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
226 |
extern long AtomicCompareExchange(long*, long, long); |
954 | 227 |
extern long long AtomicCompareExchange64(long long* , long long , long long); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
228 |
extern void LeaveDebugSection(void); |
580 | 229 |
extern void ValidateRetainBuffer(void); |
230 |
extern void InValidateRetainBuffer(void); |
|
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
231 |
|
423 | 232 |
void __publish_debug(void) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
233 |
{ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
477
diff
changeset
|
234 |
retain_offset = 0; |
580 | 235 |
InValidateRetainBuffer(); |
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
236 |
|
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
237 |
#ifndef TARGET_ONLINE_DEBUG_DISABLE |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
238 |
/* Check there is no running debugger re-configuration */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
239 |
if(TryEnterDebugSection()){ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
240 |
/* Lock buffer */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
241 |
long latest_state = AtomicCompareExchange( |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
242 |
&trace_buffer_state, |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
243 |
BUFFER_FREE, |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
244 |
BUFFER_BUSY); |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
245 |
|
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
246 |
/* If buffer was free */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
247 |
if(latest_state == BUFFER_FREE) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
248 |
{ |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
249 |
/* Reset buffer cursor */ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
250 |
trace_buffer_cursor = trace_buffer; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
251 |
/* Reset trace list cursor */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
252 |
trace_list_collect_cursor = trace_list; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
253 |
/* Iterate over all variables to fill debug buffer */ |
605
2250ed42e306
debugger : forcing %M and %Q variables on each cycle, and rework of code for optimization and concision
Edouard Tisserant
parents:
582
diff
changeset
|
254 |
__for_each_variable_do(DebugIterator); |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
255 |
while(trace_list_collect_cursor < trace_list_addvar_cursor){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
256 |
void *real_value_p = NULL; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
257 |
void *visible_value_p = NULL; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
258 |
char flags = 0; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
259 |
USINT size; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
260 |
char* next_cursor; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
261 |
|
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
262 |
dbgvardsc_t *dsc = &dbgvardsc[ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
263 |
trace_list_collect_cursor->dbgvardsc_index]; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
264 |
|
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
265 |
visible_value_p = UnpackVar(dsc, &real_value_p, &flags); |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
266 |
|
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
267 |
/* copy visible variable to buffer */; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
268 |
if(__Is_a_string(dsc)){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
269 |
/* optimization for strings */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
270 |
/* assume NULL terminated strings */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
271 |
size = ((STRING*)visible_value_p)->len + 1; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
272 |
}else{ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
273 |
size = __get_type_enum_size(dsc->type); |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
274 |
} |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
275 |
|
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
276 |
/* compute next cursor positon.*/ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
277 |
next_cursor = trace_buffer_cursor + size; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
278 |
/* check for buffer overflow */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
279 |
if(next_cursor < trace_buffer_end) |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
280 |
/* copy data to the buffer */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
281 |
memcpy(trace_buffer_cursor, visible_value_p, size); |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
282 |
else |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
283 |
/* stop looping in case of overflow */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
284 |
break; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
285 |
/* increment cursor according size*/ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
286 |
trace_buffer_cursor = next_cursor; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
287 |
trace_list_collect_cursor++; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
288 |
} |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
289 |
|
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
290 |
/* Leave debug section, |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
291 |
* Trigger asynchronous transmission |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
292 |
* (returns immediately) */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
293 |
InitiateDebugTransfer(); /* size */ |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
294 |
} |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
295 |
LeaveDebugSection(); |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
296 |
} |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
297 |
#endif |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
298 |
/* when not debugging, do only retain */ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
299 |
__for_each_variable_do(RetainIterator); |
580 | 300 |
ValidateRetainBuffer(); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
301 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
302 |
|
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
303 |
#ifndef TARGET_ONLINE_DEBUG_DISABLE |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
304 |
#define __RegisterDebugVariable_case_t(TYPENAME) \ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
305 |
case TYPENAME##_ENUM :\ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
306 |
((__IEC_##TYPENAME##_t *)varp)->flags |= __IEC_FORCE_FLAG;\ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
307 |
((__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
|
308 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
309 |
#define __RegisterDebugVariable_case_p(TYPENAME)\ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
310 |
case TYPENAME##_P_ENUM :\ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
311 |
((__IEC_##TYPENAME##_p *)varp)->flags |= __IEC_FORCE_FLAG;\ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
312 |
((__IEC_##TYPENAME##_p *)varp)->fvalue = *((TYPENAME *)force);\ |
511 | 313 |
break;\ |
314 |
case TYPENAME##_O_ENUM :\ |
|
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
315 |
((__IEC_##TYPENAME##_p *)varp)->flags |= __IEC_FORCE_FLAG;\ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
316 |
((__IEC_##TYPENAME##_p *)varp)->fvalue = *((TYPENAME *)force);\ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
317 |
*(((__IEC_##TYPENAME##_p *)varp)->value) = *((TYPENAME *)force);\ |
477
f66a092b6e74
Arbitrary variable forcing
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
458
diff
changeset
|
318 |
break; |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
319 |
void RegisterDebugVariable(dbgvardsc_index_t idx, void* force) |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
320 |
{ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
321 |
if(idx < sizeof(dbgvardsc)/sizeof(dbgvardsc_t)){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
322 |
/* add to trace_list, inc tracelist_addvar_cursor*/ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
323 |
if(trace_list_addvar_cursor <= trace_list_end){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
324 |
trace_list_addvar_cursor->dbgvardsc_index = idx; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
325 |
trace_list_addvar_cursor++; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
326 |
} |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
327 |
if(force){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
328 |
dbgvardsc_t *dsc = &dbgvardsc[idx]; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
329 |
void *varp = dsc->ptr; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
330 |
switch(dsc->type){ |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
331 |
__ANY(__RegisterDebugVariable_case_t) |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
332 |
__ANY(__RegisterDebugVariable_case_p) |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
333 |
default: |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
334 |
break; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
335 |
} |
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
336 |
} |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
337 |
} |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
338 |
} |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
339 |
|
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
340 |
#define __ResetDebugVariablesIterator_case_t(TYPENAME) \ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
341 |
case TYPENAME##_ENUM :\ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
342 |
((__IEC_##TYPENAME##_t *)varp)->flags &= ~(__IEC_FORCE_FLAG);\ |
458
dfc6164e4022
Debugger still doesn't work crash less...
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
452
diff
changeset
|
343 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
344 |
|
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
345 |
#define __ResetDebugVariablesIterator_case_p(TYPENAME)\ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
346 |
case TYPENAME##_P_ENUM :\ |
582
bb5d0367bf32
Fix typo in plc_debug.c
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
581
diff
changeset
|
347 |
case TYPENAME##_O_ENUM :\ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
348 |
((__IEC_##TYPENAME##_p *)varp)->flags &= ~(__IEC_FORCE_FLAG);\ |
458
dfc6164e4022
Debugger still doesn't work crash less...
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
452
diff
changeset
|
349 |
break; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
350 |
|
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
351 |
void ResetDebugVariablesIterator(dbgvardsc_t *dsc) |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
352 |
{ |
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
353 |
/* force debug flag to 0*/ |
1432
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
354 |
void *varp = dsc->ptr; |
8872223a675b
Optimized plc_debug.c generated code. Should produce smaller code size. Added statically initialized array for PLC tracable variable description.
Edouard Tisserant
parents:
1403
diff
changeset
|
355 |
switch(dsc->type){ |
611 | 356 |
__ANY(__ResetDebugVariablesIterator_case_t) |
357 |
__ANY(__ResetDebugVariablesIterator_case_p) |
|
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
358 |
default: |
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
359 |
break; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
360 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
361 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
362 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
363 |
void ResetDebugVariables(void) |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
364 |
{ |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
365 |
trace_list_addvar_cursor = trace_list; |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
366 |
__for_each_variable_do(ResetDebugVariablesIterator); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
367 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
368 |
|
423 | 369 |
void FreeDebugData(void) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
370 |
{ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
371 |
/* atomically mark buffer as free */ |
1403 | 372 |
AtomicCompareExchange( |
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
373 |
&trace_buffer_state, |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
374 |
BUFFER_BUSY, |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
375 |
BUFFER_FREE); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
376 |
} |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
450
diff
changeset
|
377 |
int WaitDebugData(unsigned long *tick); |
450
18583d13f0fa
Preliminary accessor support for debug
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
423
diff
changeset
|
378 |
/* 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
|
379 |
int GetDebugData(unsigned long *tick, unsigned long *size, void **buffer){ |
504 | 380 |
int wait_error = WaitDebugData(tick); |
381 |
if(!wait_error){ |
|
3394
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
382 |
*size = trace_buffer_cursor - trace_buffer; |
9ea29ac18837
RUNTIME: Variable trace now uses limited list and buffer instead of flags in instance tree that was requiring systematical instance tree traversal, and worst size buffer. Forcing and retain still use tree traversal.
Edouard Tisserant
parents:
2710
diff
changeset
|
383 |
*buffer = trace_buffer; |
502 | 384 |
} |
504 | 385 |
return wait_error; |
386 |
} |
|
2501
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
387 |
#endif |
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
388 |
#endif |
eba2bbb2dd9a
Make online debug optional
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2190
diff
changeset
|
389 |