C++ TargetRTS
Loading...
Searching...
No Matches
RTDebugger.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTDebugger_h__
11#define __RTDebugger_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTConfig_h__
18#include <RTConfig.h>
19#endif
20
21#if OTRTSDEBUG != DEBUG_NONE
22
23#ifndef __RTController_h__
24#include <RTController.h>
25#endif
26
27#ifndef __RTDebuggerInput_h__
28#include <RTDebuggerInput.h>
29#endif
30
31#ifndef __RTElasticArray_h__
32#include <RTElasticArray.h>
33#endif
34
35#ifndef __RTTcpSocket_h__
36#include <RTTcpSocket.h>
37#endif
38
39#ifndef __RTTimespec_h__
40#include <RTTimespec.h>
41#endif
42
43#if USE_THREADS && ! defined( __RTinet_h__ )
44#include <RTinet.h>
45#endif
46
47class RTActor;
48class RTActorRef;
49class RTDaemonInfo;
50class RTEventInfo;
51class RTIOMonitor;
52class RTObserver;
53class RTProbe;
54class RTProtocol;
55class RTSequenceOf;
56
57class RTDebugger : public RTJob
58{
59private:
60 enum TraceCategory
61 {
62 TraceComm,
63 TraceException,
64 TraceFrame,
65 TraceLayer,
66 TraceTimer,
67 TraceSystem
68 };
69
70 enum
71 {
72 TraceAll = TraceSystem + 1
73 };
74
75 // if mode is Stepping we stop it after step_count message events
76 enum
77 {
78 Halted,
79 Stepping,
80 Running
81 } mode;
82
83 RTController * tasks;
84
85 RTDebuggerInput input;
86
87 unsigned step_count;
88
89 RTMessage * freeList;
90 unsigned freeListSize;
91
92#if OBSERVABLE
93 RTProbe * getProbe( int );
94 RTElasticArray probes;
95 RTElasticArray parkedProbes;
96 int nrParkedProbes;
97 RTTimespec lastTimestamp;
98 RTTimespec zeroTimeBase;
99
100 RTTcpSocket listener;
101 RTIOMonitor * ioMonitor;
102
103#if USE_THREADS
104 // This is the descriptor of a UDP socket connected to itself, used to
105 // allow another thread to interrupt us while we are executing 'idle'.
106 int _udp;
107 RTinet_port _udp_port;
108
109#ifdef TARGET_PSOS
110 // On pSOS, other tasks cannot simply write a datagram on my UDP socket.
111 // I have to create a 'trigger' task with which I share that socket.
112 // Only it will write datagrams in response to 'wakeup' events that can
113 // be sent by any task. This pointer refers to the object used to manage
114 // that extra task.
115 void * _trigger;
116#endif
117
118 void startupUdp( void );
119 void shutdownUdp( void );
120 void wakeupUdp( void );
121#endif // USE_THREADS
122
123 RTEventInfo * eventHead;
124 RTEventInfo * eventTail;
125
126 RTElasticArray sockets;
127 RTElasticArray observers;
128#endif // OBSERVABLE
129
130 RTMessage * newMsg( void );
131 void freeMsg( RTMessage * );
132
133 unsigned char traceLevel[ TraceAll ];
134
135 enum Command
136 {
137 CmdInvalid, CmdNone
138 , CmdAttach
139 , CmdCont
140 , CmdDetach
141 , CmdExit
142 , CmdGo
143 , CmdHelp
144 , CmdInfo
145 , CmdLog
146 , CmdMessage
147 , CmdQuit
148 , CmdSaps
149 , CmdStats
150 , CmdStep
151 , CmdStop
152 , CmdSystem
153 , CmdTasks
154 };
155
156 RTController * getTask( int );
157
158 void doCmd( void );
159 void doCmdQuit( void );
160 void doCmdSystem( void );
161
162 void printActor( const RTActor * );
163 void printPort( const RTProtocol *, int );
164 void printRef( const RTActor *, const char * );
165
166 int getCommand( void );
167 int getCategory( void );
168 int getLevel( void );
169
170 void printHelp( void );
171 void printStructure( RTActor *, const char *, int );
172 void printActorInfo( RTActor * );
173
174 RTActor * getActor( void );
175
176 RTActor * findActor( const char *, RTActorRef * );
177
178#if USE_THREADS
179 void wakeup( RTController * );
180#endif
181
182 int useEvent( void );
183 void dispatchEvent( RTEventInfo * );
184
185public:
186 RTDebugger( void );
187 virtual ~RTDebugger( void );
188
189
190 void debugIt( const char * cmdLine = nullptr );
191 virtual void mainLoop( void ) override;
192 virtual void kill( void ) override;
193 virtual const char * name( void ) const override;
194
195
196 void doCmdExit( void );
197 void trace( RTController::Primitive,
198 const char * errorDescription,
199 const void * info,
200 const void * detail );
201 void logMessage( const RTMessage * );
202
203 void registerRTS( RTController * );
204 void attach( RTController * );
205 void detach( RTController * );
206 void deregisterRTS( RTController * );
207
208 void printMessage( const RTMessage * );
209
210 RTS_INLINE int controlThreshold( void ) const;
211
212 int step_begin( RTController * );
213 void step_end( RTController * );
214
215 void step( unsigned count = 1U );
216 void proceed( void );
217
218#if ! USE_THREADS
219 RTS_INLINE int isHalted( void ) const;
220#endif
221
222#if OBSERVABLE
223 void actorIncarnated( RTActor * );
224 void actorDestroyed ( RTActor * );
225 int breakPoint( RTController *, RTEventInfo * );
226
227 void setTimestamp( RTMessage *,
228 const RTProtocol * source,
229 int sourceIndex );
230 void getTimestamp( RTTimespec & );
231
232 void checkObservability( void );
233 void closeObservability( void );
234 int mainObserverLoop( void );
235 RTTcpSocket * newConnection( void );
236
237 RTObserver * findObserver( RTTcpSocket *, int obsNr );
238
239 int addProbe( RTSequenceOf * probeInfo );
240 int addProbe( RTDaemonInfo * probeInfo );
241 void probeCreated( int probeId, RTProbe * );
242 void sendProbeSignal( RTActor *, int priority );
243 int deleteProbe( int );
244
245 void getHistory ( int probeNr, int state );
246 void getPresence ( int probeNr, int observerId, int daemonId );
247 void getReference( int probeNr, int observerId );
248
249 int addEvent( RTEventInfo * );
250
251 int evtHistory( int probeNr,
252 int actorIndex,
253 const RTActor * actor,
254 int stateTarget,
255 int histHist,
256 int histCurr );
257 int evtPresence( int probeNr,
258 int actorIndex,
259 const RTActor * actor,
260 int observerId,
261 int daemonId );
262 int evtReference( int probeNr,
263 const RTActor * actor,
264 int compIndex,
265 int nrIncarns,
266 int observerId );
267
268 void evtRtsStatus( int observerId = -1 );
269
270 int evtVariable( int probeNr,
271 int actorIndex,
272 const RTActor * actor,
273 const char * varName,
274 const char * varValue );
275
276 int evtChildren( int probeNr,
277 int actorIndex,
278 const char * actorID,
279 const char * classID,
280 const char * data
281 );
282
283 void evtMsgQueues( void );
284
285 void addFieldValue( const char * variable,
286 const char * value,
287 int probeNr );
288
289 void probeAttention( const RTActor * target );
290
291 int inject( int inwards,
292 const char * signal,
293 int prio,
294 const void * data,
295 const RTObject_class * type,
296 const RTDaemonInfo & daemonInfo );
297
298 int doInject( RTProtocol * port,
299 int index,
300 int signal,
301 int prio,
302 const void * data,
303 const RTObject_class * type );
304
305 int getMessages( const RTDaemonInfo & daemonInfo );
306
307 void addFieldMonitor( int probeNr,
308 const char * variable );
309 void delFieldMonitor( int probeNr,
310 const char * variable );
311#endif // OBSERVABLE
312
313private:
314 // unavailable methods
315 RTDebugger( const RTDebugger & );
316 RTDebugger & operator=( const RTDebugger & );
317}; //lint !e1712
318
319#if RTS_INLINES
320#include <RTDebugger.inl>
321#endif
322
323#endif // OTRTSDEBUG != DEBUG_NONE
324
325#endif // __RTDebugger_h__
An instance of this class represents a capsule instance.
Definition: RTActor.h:44
Represents a capsule part.
Definition: RTActorRef.h:39
A controller manages a group of capsule instances that all run in the same physical thread (i....
Definition: RTController.h:54
Definition: RTDaemonInfo.h:24
Definition: RTDebugger.h:58
Definition: RTDebuggerInput.h:22
Definition: RTElasticArray.h:22
Definition: RTEventInfo.h:26
Definition: RTIOMonitor.h:24
An object associated with a thread which captures its current state and implements its behavior.
Definition: RTJob.h:43
Represents a message used for communication between capsule instances.
Definition: RTMessage.h:33
Definition: RTObserver.h:28
Definition: RTProbe.h:25
Represents a general capsule port typed by a protocol which determines the set of events that can be ...
Definition: RTProtocol.h:50
Definition: RTSequenceOf.h:22
Definition: RTTcpSocket.h:24
A type descriptor providing information about a type.
Definition: RTObject_class.h:64
A time value which can represent either an absolute or relative time.
Definition: RTTimespec.h:29