#include #include #include "../util/record-utility.h" #include "record-manager.h" #include "../../core/slang-io.h" namespace SlangRecord { RecordManager::RecordManager(uint64_t globalSessionHandle) : m_recorder(&m_memoryStream) { std::stringstream ss; ss << "gs-"<< globalSessionHandle <<"-t-"<( reinterpret_cast(m_memoryStream.getData())); pHeader->dataSizeInBytes = m_memoryStream.getSizeInBytes() - sizeof(FunctionHeader); std::hash hasher; pHeader->threadId = hasher(std::this_thread::get_id()); // write record data to file m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes()); // take effect of the write m_fileStream->flush(); // clear the memory stream m_memoryStream.flush(); clearWithTailer(); return &m_recorder; } void RecordManager::apendOutput() { FunctionTailer* pTailer = const_cast( reinterpret_cast(m_memoryStream.getData())); pTailer->dataSizeInBytes = (uint32_t)(m_memoryStream.getSizeInBytes() - sizeof(FunctionTailer)); // write record data to file m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes()); // take effect of the write m_fileStream->flush(); // clear the memory stream m_memoryStream.flush(); } }