2019-12-26 15:32:37 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-06-03 15:32:00 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Containers/Array.h"
|
|
|
|
|
#include "Trace/Analysis.h"
|
|
|
|
|
#include "Trace/Analyzer.h"
|
|
|
|
|
|
|
|
|
|
namespace Trace
|
|
|
|
|
{
|
|
|
|
|
|
2019-11-25 12:03:09 -05:00
|
|
|
class FStreamReader;
|
|
|
|
|
|
2019-06-03 15:32:00 -04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
class FAnalysisEngine
|
|
|
|
|
: public IAnalyzer
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-10-03 16:26:48 -04:00
|
|
|
struct FDispatch;
|
2019-12-13 11:07:03 -05:00
|
|
|
struct FAuxDataCollector;
|
2019-10-03 16:26:48 -04:00
|
|
|
struct FEventDataInfo;
|
2019-06-03 15:32:00 -04:00
|
|
|
FAnalysisEngine(TArray<IAnalyzer*>&& InAnalyzers);
|
|
|
|
|
~FAnalysisEngine();
|
2019-11-25 12:03:09 -05:00
|
|
|
bool OnData(FStreamReader& Reader);
|
2020-01-29 08:18:18 -05:00
|
|
|
void End();
|
2019-06-03 15:32:00 -04:00
|
|
|
|
|
|
|
|
private:
|
2019-11-25 12:03:09 -05:00
|
|
|
typedef bool (FAnalysisEngine::*ProtocolHandlerType)();
|
|
|
|
|
|
2019-06-03 15:32:00 -04:00
|
|
|
struct FRoute
|
|
|
|
|
{
|
2019-10-03 16:26:48 -04:00
|
|
|
uint32 Hash;
|
2019-06-03 15:32:00 -04:00
|
|
|
int16 Count;
|
|
|
|
|
uint16 Id;
|
|
|
|
|
uint16 AnalyzerIndex;
|
2019-10-03 16:26:48 -04:00
|
|
|
uint16 _Unused0;
|
2019-06-03 15:32:00 -04:00
|
|
|
};
|
|
|
|
|
|
2019-11-25 12:03:09 -05:00
|
|
|
class FDispatchBuilder;
|
2019-10-03 16:26:48 -04:00
|
|
|
virtual bool OnEvent(uint16 RouteId, const FOnEventContext& Context) override;
|
2019-06-03 15:32:00 -04:00
|
|
|
void OnNewTrace(const FOnEventContext& Context);
|
|
|
|
|
void OnTiming(const FOnEventContext& Context);
|
2019-10-03 16:26:48 -04:00
|
|
|
void OnNewEventInternal(const FOnEventContext& Context);
|
2019-11-25 12:03:09 -05:00
|
|
|
void OnNewEventProtocol0(FDispatchBuilder& Builder, const void* EventData);
|
|
|
|
|
void OnNewEventProtocol1(FDispatchBuilder& Builder, const void* EventData);
|
2020-01-13 07:16:09 -05:00
|
|
|
void OnChannelAnnounceInternal(const FOnEventContext& Context);
|
|
|
|
|
void OnChannelToggleInternal(const FOnEventContext& Context);
|
2019-11-25 12:03:09 -05:00
|
|
|
|
|
|
|
|
bool EstablishTransport(FStreamReader& Reader);
|
|
|
|
|
bool OnDataProtocol0();
|
2019-12-13 11:07:03 -05:00
|
|
|
bool OnDataProtocol2();
|
|
|
|
|
int32 OnDataProtocol2(uint32 ThreadId, FStreamReader& Reader);
|
|
|
|
|
int32 OnDataProtocol2Aux(FStreamReader& Reader, FAuxDataCollector& Collector);
|
2019-11-25 12:03:09 -05:00
|
|
|
bool AddDispatch(FDispatch* Dispatch);
|
|
|
|
|
template <typename ImplType>
|
|
|
|
|
void ForEachRoute(const FDispatch* Dispatch, ImplType&& Impl);
|
|
|
|
|
void AddRoute(uint16 AnalyzerIndex, uint16 Id, const ANSICHAR* Logger, const ANSICHAR* Event);
|
|
|
|
|
void AddRoute(uint16 AnalyzerIndex, uint16 Id, uint32 Hash);
|
|
|
|
|
void RetireAnalyzer(IAnalyzer* Analyzer);
|
2019-06-03 15:32:00 -04:00
|
|
|
FSessionContext SessionContext;
|
|
|
|
|
TArray<FRoute> Routes;
|
|
|
|
|
TArray<IAnalyzer*> Analyzers;
|
|
|
|
|
TArray<FDispatch*> Dispatches;
|
2019-10-03 16:26:48 -04:00
|
|
|
class FTransport* Transport = nullptr;
|
2019-11-25 12:03:09 -05:00
|
|
|
ProtocolHandlerType ProtocolHandler = nullptr;
|
2019-12-13 11:07:03 -05:00
|
|
|
uint32 NextLogSerial = 0;
|
2019-11-25 12:03:09 -05:00
|
|
|
uint8 ProtocolVersion = 0;
|
2019-06-03 15:32:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Trace
|