C++ TargetRTS
All Classes Functions Variables Enumerations Enumerator Pages
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 , CmdTrace
155 };
156
157 RTController * getTask( int );
158
159 void doCmd( void );
160 void doCmdQuit( void );
161 void doCmdSystem( void );
162
163 void printActor( const RTActor * );
164 void printPort( const RTProtocol *, int );
165 void printRef( const RTActor *, const char * );
166
167 int getCommand( void );
168 int getCategory( void );
169 int getLevel( void );
170
171 void printHelp( void );
172 void printStructure( RTActor *, const char *, int );
173 void printActorInfo( RTActor * );
174
175 RTActor * getActor( void );
176
177 RTActor * findActor( const char *, RTActorRef * );
178
179#if USE_THREADS
180 void wakeup( RTController * );
181#endif
182
183 int useEvent( void );
184 void dispatchEvent( RTEventInfo * );
185
186public:
187 RTDebugger( void );
188 virtual ~RTDebugger( void );
189
190
191 void debugIt( const char * cmdLine = nullptr );
192 virtual void mainLoop( void ) override;
193 virtual void kill( void ) override;
194 virtual const char * name( void ) const override;
195
196
197 void doCmdExit( void );
198 void trace( RTController::Primitive,
199 const char * errorDescription,
200 const void * info,
201 const void * detail );
202 void logMessage( const RTMessage * );
203
204 void registerRTS( RTController * );
205 void attach( RTController * );
206 void detach( RTController * );
207 void deregisterRTS( RTController * );
208
209 void printMessage( const RTMessage * );
210
211 RTS_INLINE int controlThreshold( void ) const;
212
213 int step_begin( RTController * );
214 void step_end( RTController * );
215
216 void step( unsigned count = 1U );
217 void proceed( void );
218
219#if ! USE_THREADS
220 RTS_INLINE int isHalted( void ) const;
221#endif
222
223#if OBSERVABLE
224 void actorIncarnated( RTActor * );
225 void actorDestroyed ( RTActor * );
226 int breakPoint( RTController *, RTEventInfo * );
227
228 void setTimestamp( RTMessage *,
229 const RTProtocol * source,
230 int sourceIndex );
231 void getTimestamp( RTTimespec & );
232
233 void checkObservability( void );
234 void closeObservability( void );
235 int mainObserverLoop( void );
236 RTTcpSocket * newConnection( void );
237
238 RTObserver * findObserver( RTTcpSocket *, int obsNr );
239
240 int addProbe( RTSequenceOf * probeInfo );
241 int addProbe( RTDaemonInfo * probeInfo );
242 void probeCreated( int probeId, RTProbe * );
243 void sendProbeSignal( RTActor *, int priority );
244 int deleteProbe( int );
245
246 void getHistory ( int probeNr, int state );
247 void getPresence ( int probeNr, int observerId, int daemonId );
248 void getReference( int probeNr, int observerId );
249
250 int addEvent( RTEventInfo * );
251
252 int evtHistory( int probeNr,
253 int actorIndex,
254 const RTActor * actor,
255 int stateTarget,
256 int histHist,
257 int histCurr );
258 int evtPresence( int probeNr,
259 int actorIndex,
260 const RTActor * actor,
261 int observerId,
262 int daemonId );
263 int evtReference( int probeNr,
264 const RTActor * actor,
265 int compIndex,
266 int nrIncarns,
267 int observerId );
268
269 void evtRtsStatus( int observerId = -1 );
270
271 int evtVariable( int probeNr,
272 int actorIndex,
273 const RTActor * actor,
274 const char * varName,
275 const char * varValue );
276
277 int evtChildren( int probeNr,
278 int actorIndex,
279 const char * actorID,
280 const char * classID,
281 const char * data
282 );
283
284 void evtMsgQueues( void );
285
286 void addFieldValue( const char * variable,
287 const char * value,
288 int probeNr );
289
290 void probeAttention( const RTActor * target );
291
292 int inject( int inwards,
293 const char * signal,
294 int prio,
295 const void * data,
296 const RTObject_class * type,
297 const RTDaemonInfo & daemonInfo );
298
299 int doInject( RTProtocol * port,
300 int index,
301 int signal,
302 int prio,
303 const void * data,
304 const RTObject_class * type );
305
306 int getMessages( const RTDaemonInfo & daemonInfo );
307
308 void addFieldMonitor( int probeNr,
309 const char * variable );
310 void delFieldMonitor( int probeNr,
311 const char * variable );
312#endif // OBSERVABLE
313
314private:
315 // unavailable methods
316 RTDebugger( const RTDebugger & );
317 RTDebugger & operator=( const RTDebugger & );
318}; //lint !e1712
319
320#if RTS_INLINES
321#include <RTDebugger.inl>
322#endif
323
324#endif // OTRTSDEBUG != DEBUG_NONE
325
326#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