aboutsummaryrefslogtreecommitdiff
path: root/profiling/client/src/ProfilingConnectionDumpToFileDecorator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'profiling/client/src/ProfilingConnectionDumpToFileDecorator.hpp')
-rw-r--r--profiling/client/src/ProfilingConnectionDumpToFileDecorator.hpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/profiling/client/src/ProfilingConnectionDumpToFileDecorator.hpp b/profiling/client/src/ProfilingConnectionDumpToFileDecorator.hpp
new file mode 100644
index 0000000000..8f4812e9dd
--- /dev/null
+++ b/profiling/client/src/ProfilingConnectionDumpToFileDecorator.hpp
@@ -0,0 +1,62 @@
+//
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "IProfilingConnection.hpp"
+#include "ProfilingUtils.hpp"
+
+#include <client/include/ProfilingOptions.hpp>
+
+#include <fstream>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class ProfilingConnectionDumpToFileDecorator : public IProfilingConnection
+{
+public:
+
+ ProfilingConnectionDumpToFileDecorator(std::unique_ptr<IProfilingConnection> connection,
+ const ProfilingOptions& options,
+ bool ignoreFailures = false);
+
+ ~ProfilingConnectionDumpToFileDecorator();
+
+ bool IsOpen() const override;
+
+ void Close() override;
+
+ bool WritePacket(const unsigned char* buffer, uint32_t length) override;
+
+ arm::pipe::Packet ReadPacket(uint32_t timeout) override;
+
+private:
+ bool OpenIncomingDumpFile();
+
+ bool OpenOutgoingDumpFile();
+
+ void DumpIncomingToFile(const arm::pipe::Packet& packet);
+
+ bool DumpOutgoingToFile(const unsigned char* buffer, uint32_t length);
+
+ void Fail(const std::string& errorMessage);
+
+ std::unique_ptr<IProfilingConnection> m_Connection;
+ ProfilingOptions m_Options;
+ std::ofstream m_IncomingDumpFileStream;
+ std::ofstream m_OutgoingDumpFileStream;
+ bool m_IgnoreFileErrors;
+};
+
+} // namespace pipe
+
+} // namespace arm