summaryrefslogtreecommitdiff
path: root/source/slang-capture-replay/capture-manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang-capture-replay/capture-manager.cpp')
-rw-r--r--source/slang-capture-replay/capture-manager.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/source/slang-capture-replay/capture-manager.cpp b/source/slang-capture-replay/capture-manager.cpp
index be5615e00..2d04b077a 100644
--- a/source/slang-capture-replay/capture-manager.cpp
+++ b/source/slang-capture-replay/capture-manager.cpp
@@ -10,14 +10,14 @@ namespace SlangCapture
: m_encoder(&m_memoryStream)
{
std::stringstream ss;
- ss << "gs-"<< globalSessionHandle <<"t-"<<std::this_thread::get_id() << ".cap";
+ ss << "gs-"<< globalSessionHandle <<"-t-"<<std::this_thread::get_id() << ".cap";
m_fileStream = std::make_unique<FileOutputStream>(ss.str());
}
void CaptureManager::clearWithHeader(const ApiCallId& callId, uint64_t handleId)
{
m_memoryStream.flush();
- FunctionHeader header {};
+ FunctionHeader header;
header.callId = callId;
header.handleId = handleId;
@@ -25,13 +25,22 @@ namespace SlangCapture
m_memoryStream.write(&header, sizeof(FunctionHeader));
}
+ void CaptureManager::clearWithTailer()
+ {
+ m_memoryStream.flush();
+ FunctionTailer tailer;
+
+ // write header to memory stream
+ m_memoryStream.write(&tailer, sizeof(FunctionTailer));
+ }
+
ParameterEncoder* CaptureManager::beginMethodCapture(const ApiCallId& callId, uint64_t handleId)
{
clearWithHeader(callId, handleId);
return &m_encoder;
}
- void CaptureManager::endMethodCapture()
+ ParameterEncoder* CaptureManager::endMethodCapture()
{
FunctionHeader* pHeader = const_cast<FunctionHeader*>(
reinterpret_cast<const FunctionHeader*>(m_memoryStream.getData()));
@@ -49,5 +58,25 @@ namespace SlangCapture
// clear the memory stream
m_memoryStream.flush();
+
+ clearWithTailer();
+ return &m_encoder;
+ }
+
+ void CaptureManager::endMethodCaptureAppendOutput()
+ {
+ FunctionTailer* pTailer = const_cast<FunctionTailer*>(
+ reinterpret_cast<const FunctionTailer*>(m_memoryStream.getData()));
+
+ pTailer->dataSizeInBytes = (uint32_t)(m_memoryStream.getSizeInBytes() - sizeof(FunctionTailer));
+
+ // write capture 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();
}
}