From 0c6330da38bb04467eaa4d38c659b02222029ae3 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 7 Oct 2014 11:34:53 -0400 Subject: ctest_memcheck: Add support for MemorySanitizer msan --- Help/variable/CTEST_MEMORYCHECK_TYPE.rst | 2 +- Source/CTest/cmCTestMemCheckHandler.cxx | 22 ++++++++++++++++++++++ Source/CTest/cmCTestMemCheckHandler.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst index af759e9..f1087c0 100644 --- a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst +++ b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst @@ -4,4 +4,4 @@ CTEST_MEMORYCHECK_TYPE Specify the CTest ``MemoryCheckType`` setting in a :manual:`ctest(1)` dashboard client script. Valid values are Valgrind, Purify, BoundsChecker, and ThreadSanitizer, -AddressSanitizer, and UndefinedBehaviorSanitizer. +AddressSanitizer, MemorySanitizer, and UndefinedBehaviorSanitizer. diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index cc691aa..4835010 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -376,6 +376,9 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) case cmCTestMemCheckHandler::THREAD_SANITIZER: os << "ThreadSanitizer"; break; + case cmCTestMemCheckHandler::MEMORY_SANITIZER: + os << "MemorySanitizer"; + break; case cmCTestMemCheckHandler::UB_SANITIZER: os << "UndefinedBehaviorSanitizer"; break; @@ -556,6 +559,14 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->LogWithPID = true; // even if we give the log file the pid is added } if ( this->CTest->GetCTestConfiguration("MemoryCheckType") + == "MemorySanitizer") + { + this->MemoryTester + = this->CTest->GetCTestConfiguration("CMakeCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::MEMORY_SANITIZER; + this->LogWithPID = true; // even if we give the log file the pid is added + } + if ( this->CTest->GetCTestConfiguration("MemoryCheckType") == "UndefinedBehaviorSanitizer") { this->MemoryTester @@ -688,6 +699,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() // these are almost the same but the env var used is different case cmCTestMemCheckHandler::ADDRESS_SANITIZER: case cmCTestMemCheckHandler::THREAD_SANITIZER: + case cmCTestMemCheckHandler::MEMORY_SANITIZER: case cmCTestMemCheckHandler::UB_SANITIZER: { // To pass arguments to ThreadSanitizer the environment variable @@ -710,6 +722,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() { envVar = "TSAN_OPTIONS"; } + else if(this->MemoryTesterStyle == + cmCTestMemCheckHandler::MEMORY_SANITIZER) + { + envVar = "MSAN_OPTIONS"; + } else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) { envVar = "UBSAN_OPTIONS"; @@ -753,6 +770,8 @@ ProcessMemCheckOutput(const std::string& str, this->MemoryTesterStyle == cmCTestMemCheckHandler::THREAD_SANITIZER || this->MemoryTesterStyle == + cmCTestMemCheckHandler::MEMORY_SANITIZER || + this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) { return this->ProcessMemCheckSanitizerOutput(str, log, results); @@ -801,6 +820,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( case cmCTestMemCheckHandler::THREAD_SANITIZER: regex = "WARNING: ThreadSanitizer: (.*) \\(pid=.*\\)"; break; + case cmCTestMemCheckHandler::MEMORY_SANITIZER: + regex = "WARNING: MemorySanitizer: (.*)"; + break; case cmCTestMemCheckHandler::UB_SANITIZER: regex = "runtime error: (.*)"; break; diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index f5cc91c..69fdd9f 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -52,6 +52,7 @@ private: // checkers after here do not use the standard error list ADDRESS_SANITIZER, THREAD_SANITIZER, + MEMORY_SANITIZER, UB_SANITIZER }; public: -- cgit v0.12