From f0d40ad5e1d0a0dec39fe8a141d3f81d88fc576a Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:02:12 -0700 Subject: capture/replay: implement infrastructure for capture (#4372) * Define api call ID for each being captured methods * Add parameter encoder interface * Add outputStream and capture manager Add infrastructure for output stream This is the interface to record the method and parameter, and also provide functionality to write all the serialized data into file. Add capture manager: Capture manager is associated to global session object, it will provide the functionality to actual record all the APIs. Implement some of parameter encoder functions. * Fix some Windows & cmake build error * remove unused headers --- source/slang-capture-replay/slang-global-session.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/slang-capture-replay/slang-global-session.cpp') diff --git a/source/slang-capture-replay/slang-global-session.cpp b/source/slang-capture-replay/slang-global-session.cpp index 05a2b93ec..45ea0b58d 100644 --- a/source/slang-capture-replay/slang-global-session.cpp +++ b/source/slang-capture-replay/slang-global-session.cpp @@ -1,5 +1,3 @@ - -#include #include "slang-global-session.h" #include "slang-session.h" #include "slang-filesystem.h" @@ -8,10 +6,21 @@ namespace SlangCapture { + // constructor is called in slang_createGlobalSession GlobalSessionCapture::GlobalSessionCapture(slang::IGlobalSession* session): m_actualGlobalSession(session) { SLANG_CAPTURE_ASSERT(m_actualGlobalSession != nullptr); + + m_thisHandle = reinterpret_cast(this); + m_captureManager = std::make_unique(m_thisHandle); + + // We will use the address of the global session as the filename for the capture manager + // to make it unique for each global session. + // capture slang::createGlobalSession + ParameterEncoder* encoder = m_captureManager->beginMethodCapture(ApiCallId::ICreateGlobalSession, g_globalFunctionHandle); + encoder->encodeAddress(m_actualGlobalSession); + m_captureManager->endMethodCapture(); } GlobalSessionCapture::~GlobalSessionCapture() -- cgit v1.2.3