aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-08-22 12:56:13 +0200
committerShauren <shauren.trinity@gmail.com>2023-08-23 14:23:56 +0200
commitca03ecf3e6aa62070676487eb413abb563322f86 (patch)
tree3b7a97aa386450ef3702acb562883f5440a93fd7
parent6a304a82b11d0be767dd9c5ef9e207df9f7f7173 (diff)
Build: Support ASAN on msvc
(cherry picked from commit 0a0b420d866f070d4b1208bb3c4451398797c6ef)
-rw-r--r--cmake/compiler/msvc/settings.cmake13
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp4
2 files changed, 15 insertions, 2 deletions
diff --git a/cmake/compiler/msvc/settings.cmake b/cmake/compiler/msvc/settings.cmake
index f6947d6eaad..96b79ac2683 100644
--- a/cmake/compiler/msvc/settings.cmake
+++ b/cmake/compiler/msvc/settings.cmake
@@ -151,6 +151,19 @@ target_compile_options(trinity-compile-option-interface
/we4263
/we4264)
+if(ASAN)
+ target_compile_definitions(trinity-compile-option-interface
+ INTERFACE
+ -D_DISABLE_STRING_ANNOTATION
+ -D_DISABLE_VECTOR_ANNOTATION)
+
+ target_compile_options(trinity-compile-option-interface
+ INTERFACE
+ /fsanitize=address)
+
+ message(STATUS "MSVC: Enabled Address Sanitizer ASan")
+endif()
+
# Disable incremental linking in debug builds.
# To prevent linking getting stuck (which might be fixed in a later VS version).
macro(DisableIncrementalLinking variable)
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index e6f44cc4762..6706173cc00 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -1682,7 +1682,7 @@ public:
uint8 stack_array[10] = {};
int size = 10;
- handler->PSendSysMessage("Triggered an array out of bounds read at address %p, value %u", stack_array + size, stack_array[size]);
+ handler->PSendSysMessage("Triggered an array out of bounds read at address %p, value %u", static_cast<void*>(stack_array + size), stack_array[size]);
#endif
return true;
}
@@ -1691,7 +1691,7 @@ public:
{
#ifdef ASAN
uint8* leak = new uint8();
- handler->PSendSysMessage("Leaked 1 uint8 object at address %p", leak);
+ handler->PSendSysMessage("Leaked 1 uint8 object at address %p", static_cast<void*>(leak));
#endif
return true;
}