158 lines
4.4 KiB
C++
158 lines
4.4 KiB
C++
#ifndef DEBUGSERVICE_H
|
|
#define DEBUGSERVICE_H
|
|
|
|
#include "BasicTCPSocket.h"
|
|
#include "BasicUDPSocket.h"
|
|
#include "ConfigurationDatabase.h"
|
|
#include "DebugCore.h"
|
|
#include "EmbeddedServiceMethodBinderI.h"
|
|
#include "MessageI.h"
|
|
#include "Object.h"
|
|
#include "ReferenceContainer.h"
|
|
#include "SingleThreadService.h"
|
|
#include "StreamString.h"
|
|
#include "Vec.h"
|
|
|
|
namespace MARTe {
|
|
|
|
class MemoryMapBroker;
|
|
class DataSourceI;
|
|
|
|
struct SignalAlias {
|
|
StreamString name;
|
|
uint32 signalIndex;
|
|
};
|
|
|
|
struct BrokerInfo {
|
|
DebugSignalInfo **signalPointers;
|
|
uint32 numSignals;
|
|
MemoryMapBroker *broker;
|
|
volatile bool *anyActiveFlag;
|
|
Vec<uint32> *activeIndices;
|
|
Vec<uint32> *activeSizes;
|
|
FastPollingMutexSem *activeMutex;
|
|
};
|
|
|
|
class DebugService : public ReferenceContainer,
|
|
public MessageI,
|
|
public EmbeddedServiceMethodBinderI {
|
|
public:
|
|
friend class DebugServiceTest;
|
|
CLASS_REGISTER_DECLARATION()
|
|
|
|
DebugService();
|
|
virtual ~DebugService();
|
|
|
|
virtual bool Initialise(StructuredDataI &data);
|
|
|
|
DebugSignalInfo *RegisterSignal(void *memoryAddress, TypeDescriptor type,
|
|
const char8 *name, uint8 numberOfDimensions = 0,
|
|
uint32 numberOfElements = 1);
|
|
void ProcessSignal(DebugSignalInfo *signalInfo, uint32 size,
|
|
uint64 timestamp);
|
|
|
|
void RegisterBroker(DebugSignalInfo **signalPointers, uint32 numSignals,
|
|
MemoryMapBroker *broker, volatile bool *anyActiveFlag,
|
|
Vec<uint32> *activeIndices, Vec<uint32> *activeSizes,
|
|
FastPollingMutexSem *activeMutex);
|
|
|
|
virtual ErrorManagement::ErrorType Execute(ExecutionInfo &info);
|
|
|
|
bool IsPaused() const { return isPaused; }
|
|
void SetPaused(bool paused) { isPaused = paused; }
|
|
|
|
static bool GetFullObjectName(const Object &obj, StreamString &fullPath);
|
|
|
|
uint32 ForceSignal(const char8 *name, const char8 *valueStr);
|
|
uint32 UnforceSignal(const char8 *name);
|
|
uint32 TraceSignal(const char8 *name, bool enable, uint32 decimation = 1);
|
|
bool IsInstrumented(const char8 *fullPath, bool &traceable, bool &forcable);
|
|
void Discover(BasicTCPSocket *client);
|
|
void InfoNode(const char8 *path, BasicTCPSocket *client);
|
|
void ListNodes(const char8 *path, BasicTCPSocket *client);
|
|
void ServeConfig(BasicTCPSocket *client);
|
|
void SetFullConfig(ConfigurationDatabase &config);
|
|
|
|
struct MonitoredSignal {
|
|
ReferenceT<DataSourceI> dataSource;
|
|
uint32 signalIdx;
|
|
uint32 internalID;
|
|
uint32 periodMs;
|
|
uint64 lastPollTime;
|
|
uint32 size;
|
|
StreamString path;
|
|
};
|
|
|
|
uint32 RegisterMonitorSignal(const char8 *path, uint32 periodMs);
|
|
uint32 UnmonitorSignal(const char8 *path);
|
|
|
|
private:
|
|
void HandleCommand(StreamString cmd, BasicTCPSocket *client);
|
|
void UpdateBrokersActiveStatus();
|
|
|
|
uint32 ExportTree(ReferenceContainer *container, StreamString &json, const char8 *pathPrefix);
|
|
void PatchRegistry();
|
|
|
|
void EnrichWithConfig(const char8 *path, StreamString &json);
|
|
static void JsonifyDatabase(ConfigurationDatabase &db, StreamString &json);
|
|
|
|
ErrorManagement::ErrorType Server(ExecutionInfo &info);
|
|
ErrorManagement::ErrorType Streamer(ExecutionInfo &info);
|
|
|
|
uint16 controlPort;
|
|
uint16 streamPort;
|
|
uint16 logPort;
|
|
StreamString streamIP;
|
|
bool isServer;
|
|
bool suppressTimeoutLogs;
|
|
volatile bool isPaused;
|
|
|
|
BasicTCPSocket tcpServer;
|
|
BasicUDPSocket udpSocket;
|
|
|
|
class ServiceBinder : public EmbeddedServiceMethodBinderI {
|
|
public:
|
|
enum ServiceType { ServerType, StreamerType };
|
|
ServiceBinder(DebugService *parent, ServiceType type)
|
|
: parent(parent), type(type) {}
|
|
virtual ErrorManagement::ErrorType Execute(ExecutionInfo &info) {
|
|
if (type == StreamerType) {
|
|
return parent->Streamer(info);
|
|
}
|
|
printf("serve TCP\n");
|
|
return parent->Server(info);
|
|
}
|
|
|
|
private:
|
|
DebugService *parent;
|
|
ServiceType type;
|
|
};
|
|
|
|
ServiceBinder binderServer;
|
|
ServiceBinder binderStreamer;
|
|
|
|
SingleThreadService threadService;
|
|
SingleThreadService streamerService;
|
|
|
|
ThreadIdentifier serverThreadId;
|
|
ThreadIdentifier streamerThreadId;
|
|
|
|
Vec<DebugSignalInfo *> signals;
|
|
Vec<SignalAlias> aliases;
|
|
Vec<BrokerInfo> brokers;
|
|
Vec<MonitoredSignal> monitoredSignals;
|
|
|
|
FastPollingMutexSem mutex;
|
|
TraceRingBuffer traceBuffer;
|
|
|
|
BasicTCPSocket *activeClient;
|
|
|
|
ConfigurationDatabase fullConfig;
|
|
|
|
static DebugService *instance;
|
|
};
|
|
|
|
} // namespace MARTe
|
|
|
|
#endif
|