From 986256ffb92ab7c8fc7cf9f2c424919a439a824f Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:45:26 -0500 Subject: Feature/capture (#4625) * Add decoder * Add a replay executable to consume the decoded content Add file-processor.cpp/h where we implement the logic to process the captured file block by block. Each block is: function header + parameter buffer + function tailer + function output[optional]. After reading one block, the block of data is sent to decoder module to dispatch the corresponding API. Add slang-decoder.cpp/h where we implement the logic to dispatch the slang API according to the input block data. - Rename api_callId.h to capture-format.h - Renmae capture_utility.cpp to capture-utility.cpp - Renmae capture_utility.h to capture-utility.h - Change the #include file name accordingly. * Reorganize source files structure Move all the capture logic code into `capture` directory. - the capture code will be build with slang dll. Move all the replay logic code into `relay` directoy. - the replay code is not part of slang dll, it will be built as a stand alone binary and link against slang dll. Change the #include file names accordingly. Add tools/slang-replay/main.cpp for the slang-replay stand alone binary place holder. Will implement it later. Update premake5.lua accordingly. * Update cmake files Update cmake files to change the build process for capture and relay system. - capture component should be build with slang dll, so we should not include replay component. - replay component should be a separate executable tool, which should not include capture component. - In order to easy use our current cmake infrastructure, move the shared files to a `util` folder - change the header include path * Redesgin the interfaces of consumers Fix some issues in capture Finish implementing all slang-decoder functions * Fix the AppleClang build issue * Address few comments - Fix the weird indent issues. - Correct the function name for CreateGlobalSession() - Rename file-processor to captureFile-processor to be more specific. - Use Slang::List instead of std::vector * record/replay: name refactor change Refactor the naming. Change the name "encoder/capture" to "record". --- source/slang-capture-replay/capture_utility.cpp | 82 ------------------------- 1 file changed, 82 deletions(-) delete mode 100644 source/slang-capture-replay/capture_utility.cpp (limited to 'source/slang-capture-replay/capture_utility.cpp') diff --git a/source/slang-capture-replay/capture_utility.cpp b/source/slang-capture-replay/capture_utility.cpp deleted file mode 100644 index 550edb64f..000000000 --- a/source/slang-capture-replay/capture_utility.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -#include -#include -#include -#include -#include - -#include "capture_utility.h" - -constexpr const char* kCaptureLayerEnvVar = "SLANG_CAPTURE_LAYER"; -constexpr const char* kCaptureLayerLogLevel = "SLANG_CAPTURE_LOG_LEVEL"; - -namespace SlangCapture -{ - static thread_local unsigned int g_logLevel = LogLevel::Silent; - - static bool getEnvironmentVariable(const char* name, std::string& out) - { -#ifdef _WIN32 - char* envVar = nullptr; - size_t sz = 0; - if (_dupenv_s(&envVar, &sz, name) == 0 && envVar != nullptr) - { - out = envVar; - free(envVar); - } -#else - if (const char* envVar = std::getenv(name)) - { - out = envVar; - } -#endif - return out.empty() == false; - } - - bool isCaptureLayerEnabled() - { - std::string envVarStr; - if(getEnvironmentVariable(kCaptureLayerEnvVar, envVarStr)) - { - if (envVarStr == "1") - { - return true; - } - } - return false; - } - - void setLogLevel() - { - // We only want to set the log level once - if (g_logLevel != LogLevel::Silent) - { - return; - } - - std::string envVarStr; - if (getEnvironmentVariable(kCaptureLayerLogLevel, envVarStr)) - { - char* end = nullptr; - unsigned int logLevel = std::strtol(envVarStr.c_str(), &end, 10); - if (end && (*end == 0)) - { - g_logLevel = std::min((unsigned int)(LogLevel::Verbose), logLevel); - return; - } - } - } - - void slangCaptureLog(LogLevel logLevel, const char* fmt, ...) - { - if (logLevel > g_logLevel) - { - return; - } - - va_list args; - va_start(args, fmt); - vfprintf(stdout, fmt, args); - va_end(args); - } -} -- cgit v1.2.3