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;
56class RTDiagStream;
57
58class RTDebugger : public RTJob
59{
60private:
61 enum TraceCategory
62 {
63 TraceComm,
64 TraceException,
65 TraceFrame,
66 TraceLayer,
67 TraceTimer,
68 TraceSystem
69 };
70
71 enum
72 {
73 TraceAll = TraceSystem + 1
74 };
75
76 // if mode is Stepping we stop it after step_count message events
77 enum
78 {
79 Halted,
80 Stepping,
81 Running
82 } mode;
83
84 RTController * tasks;
85
86 RTDebuggerInput input;
87
88 unsigned step_count;
89
90 RTMessage * freeList;
91 unsigned freeListSize;
92
93#if OBSERVABLE
94 RTProbe * getProbe( int );
95 RTElasticArray probes;
96 RTElasticArray parkedProbes;
97 int nrParkedProbes;
98 RTTimespec lastTimestamp;
99 RTTimespec zeroTimeBase;
100
101 RTTcpSocket listener;
102 RTIOMonitor * ioMonitor;
103
104#if USE_THREADS
105 // This is the descriptor of a UDP socket connected to itself, used to
106 // allow another thread to interrupt us while we are executing 'idle'.
107 int _udp;
108 RTinet_port _udp_port;
109
110#ifdef TARGET_PSOS
111 // On pSOS, other tasks cannot simply write a datagram on my UDP socket.
112 // I have to create a 'trigger' task with which I share that socket.
113 // Only it will write datagrams in response to 'wakeup' events that can
114 // be sent by any task. This pointer refers to the object used to manage
115 // that extra task.
116 void * _trigger;
117#endif
118
119 void startupUdp( void );
120 void shutdownUdp( void );
121 void wakeupUdp( void );
122#endif // USE_THREADS
123
124 RTEventInfo * eventHead;
125 RTEventInfo * eventTail;
126
127 RTElasticArray sockets;
128 RTElasticArray observers;
129#endif // OBSERVABLE
130
131 RTMessage * newMsg( void );
132 void freeMsg( RTMessage * );
133
134 unsigned char traceLevel[ TraceAll ];
135
136 enum Command
137 {
138 CmdInvalid, CmdNone
139 , CmdAttach
140 , CmdCont
141 , CmdDetach
142 , CmdExit
143 , CmdGo
144 , CmdHelp
145 , CmdInfo
146 , CmdLog
147 , CmdMessage
148 , CmdQuit
149 , CmdSaps
150 , CmdStats
151 , CmdStep
152 , CmdStop
153 , CmdSystem
154 , CmdTasks
155 , CmdTrace
156 };
157
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 void traceHelper( RTDiagStream& out,
167 const char* prim_name,
168 int info_type,
169 const char* errorDescription,
170 const void* info,
171 const void* detail );
172
173 int getCommand( void );
174 int getCategory( void );
175 int getLevel( void );
176
177 void printHelp( void );
178 void printStructure( RTActor *, const char *, int );
179 void printActorInfo( RTActor * );
180
181 RTActor * getActor( void );
182
183 RTActor * findActor( const char *, RTActorRef * );
184
185#if USE_THREADS
186 void wakeup( RTController * );
187#endif
188
189 int useEvent( void );
190 void dispatchEvent( RTEventInfo * );
191
192public:
193 RTDebugger( void );
194 virtual ~RTDebugger( void );
195
196 RTController * getTask(int);
197 void debugIt( const char * cmdLine = nullptr );
198 virtual void mainLoop( void ) override;
199 virtual void kill( void ) override;
200 virtual const char * name( void ) const override;
201
202
203 void doCmdExit( void );
204 void trace( RTController::Primitive,
205 const char * errorDescription,
206 const void * info,
207 const void * detail );
208 void logMessage( const RTMessage * );
209
210 void registerRTS( RTController * );
211 void attach( RTController * );
212 void detach( RTController * );
213 void deregisterRTS( RTController * );
214
215 void printMessage( const RTMessage * );
216
217 RTS_INLINE int controlThreshold( void ) const;
218
219 int step_begin( RTController * );
220 void step_end( RTController * );
221
222 void step( unsigned count = 1U );
223 void proceed( void );
224
225#if ! USE_THREADS
226 RTS_INLINE int isHalted( void ) const;
227#endif
228
229#if OBSERVABLE
230 void actorIncarnated( RTActor * );
231 void actorDestroyed ( RTActor * );
232 int breakPoint( RTController *, RTEventInfo * );
233
234 void setTimestamp( RTMessage *,
235 const RTProtocol * source,
236 int sourceIndex );
237 void getTimestamp( RTTimespec & );
238
239 void checkObservability( void );
240 void closeObservability( void );
241 int mainObserverLoop( void );
242 RTTcpSocket * newConnection( void );
243
244 RTObserver * findObserver( RTTcpSocket *, int obsNr );
245
246 int addProbe( RTSequenceOf * probeInfo );
247 int addProbe( RTDaemonInfo * probeInfo );
248 void probeCreated( int probeId, RTProbe * );
249 void sendProbeSignal( RTActor *, int priority );
250 int deleteProbe( int );
251
252 void getHistory ( int probeNr, int state );
253 void getPresence ( int probeNr, int observerId, int daemonId );
254 void getReference( int probeNr, int observerId );
255
256 int addEvent( RTEventInfo * );
257
258 int evtHistory( int probeNr,
259 int actorIndex,
260 const RTActor * actor,
261 int stateTarget,
262 int histHist,
263 int histCurr );
264 int evtPresence( int probeNr,
265 int actorIndex,
266 const RTActor * actor,
267 int observerId,
268 int daemonId );
269 int evtReference( int probeNr,
270 const RTActor * actor,
271 int compIndex,
272 int nrIncarns,
273 int observerId );
274
275 void evtRtsStatus( int observerId = -1 );
276
277 int evtVariable( int probeNr,
278 int actorIndex,
279 const RTActor * actor,
280 const char * varName,
281 const char * varValue );
282
283 int evtChildren( int probeNr,
284 int actorIndex,
285 const char * actorID,
286 const char * classID,
287 const char * data
288 );
289
290 void evtMsgQueues( void );
291
292 void addFieldValue( const char * variable,
293 const char * value,
294 int probeNr );
295
296 void probeAttention( const RTActor * target );
297
298 int inject( int inwards,
299 const char * signal,
300 int prio,
301 const void * data,
302 const RTObject_class * type,
303 const RTDaemonInfo & daemonInfo );
304
305 int doInject( RTProtocol * port,
306 int index,
307 int signal,
308 int prio,
309 const void * data,
310 const RTObject_class * type );
311
312 int getMessages( const RTDaemonInfo & daemonInfo );
313
314 void addFieldMonitor( int probeNr,
315 const char * variable );
316 void delFieldMonitor( int probeNr,
317 const char * variable );
318#endif // OBSERVABLE
319
320private:
321 // unavailable methods
322 RTDebugger( const RTDebugger & );
323 RTDebugger & operator=( const RTDebugger & );
324}; //lint !e1712
325
326#if RTS_INLINES
327#include <RTDebugger.inl>
328#endif
329
330#endif // OTRTSDEBUG != DEBUG_NONE
331
332#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:56
Definition: RTDaemonInfo.h:24
Definition: RTDebugger.h:59
Definition: RTDebuggerInput.h:22
Definition: RTDiagStream.h:40
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