diff options
author | jackpoz <giacomopoz@gmail.com> | 2019-04-27 18:39:06 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-02 00:39:20 +0100 |
commit | c73fd0e6e30f6dff0d2f721f549aed2c62e52c24 (patch) | |
tree | 68a716a330e96a1ded4b709257d226e349d99ba5 /src | |
parent | dc2fed13c8a98123ff20316428e41eada36c81e9 (diff) |
Scripts/Commands: Add .debug asan commands
Add ".debug asan memoryleak" and ".debug asan outofbounds" commands to trigger Address Sanitizer warnings at runtime (or other dynamic analysis tools)
(cherry picked from commit 71d15ea25be3e86646faaa3266617a0b8177972f)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Accounts/RBAC.h | 2 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index b93d99a9144..b376624a235 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -779,7 +779,7 @@ enum RBACPermissions RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871, RBAC_PERM_COMMAND_SERVER_DEBUG = 872, RBAC_PERM_COMMAND_RELOAD_CREATURE_MOVEMENT_OVERRIDE = 873, - // = 874, // DEPRECATED: DON'T REUSE + RBAC_PERM_COMMAND_DEBUG_ASAN = 874, RBAC_PERM_COMMAND_LOOKUP_MAP_ID = 875, RBAC_PERM_COMMAND_LOOKUP_ITEM_ID = 876, RBAC_PERM_COMMAND_LOOKUP_QUEST_ID = 877, diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 83b70f51c92..ab1aec347ba 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -84,6 +84,11 @@ public: { "spellfail", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SPELLFAIL, false, &HandleDebugSendSpellFailCommand, "" }, { "playerchoice", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE, false, &HandleDebugSendPlayerChoiceCommand, "" }, }; + static std::vector<ChatCommand> debugAsanCommandTable = + { + { "memoryleak", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, &HandleDebugMemoryLeak, "" }, + { "outofbounds", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, &HandleDebugOutOfBounds, "" }, + }; static std::vector<ChatCommand> debugCommandTable = { { "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "" }, @@ -116,6 +121,7 @@ public: { "worldstate" , rbac::RBAC_PERM_COMMAND_DEBUG, false, &HandleDebugWorldStateCommand, "" }, { "wsexpression" , rbac::RBAC_PERM_COMMAND_DEBUG, false, &HandleDebugWSExpressionCommand, "" }, { "dummy", rbac::RBAC_PERM_COMMAND_DEBUG_DUMMY, false, &HandleDebugDummyCommand, "" }, + { "asan", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, nullptr, "", debugAsanCommandTable }, }; static std::vector<ChatCommand> commandTable = { @@ -1699,6 +1705,22 @@ public: return true; }; + static bool HandleDebugOutOfBounds(ChatHandler* handler, CommandArgs* /*args*/) + { + 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]); + return true; + } + + static bool HandleDebugMemoryLeak(ChatHandler* handler, CommandArgs* /*args*/) + { + uint8* leak = new uint8(); + handler->PSendSysMessage("Leaked 1 uint8 object at address %p", leak); + return true; + } + static bool HandleDebugDummyCommand(ChatHandler* handler, CommandArgs* /*args*/) { handler->SendSysMessage("This command does nothing right now. Edit your local core (cs_debug.cpp) to make it do whatever you need for testing."); |