diff options
author | jackpoz <giacomopoz@gmail.com> | 2019-04-27 18:39:06 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2019-04-27 20:11:48 +0200 |
commit | 71d15ea25be3e86646faaa3266617a0b8177972f (patch) | |
tree | 3f002c168984609eae62c0287b535984ec1fff31 /src | |
parent | 0d1ff7446dce7b0641f49ac55a008669838612cd (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)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Accounts/RBAC.h | 1 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index 935d5b179ac..72951e0f77c 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -771,6 +771,7 @@ enum RBACPermissions RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871, RBAC_PERM_COMMAND_SERVER_DEBUG = 872, RBAC_PERM_COMMAND_RELOAD_CREATURE_MOVEMENT_OVERRIDE = 873, + RBAC_PERM_COMMAND_DEBUG_ASAN = 874, // // IF YOU ADD NEW PERMISSIONS, ADD THEM IN MASTER BRANCH AS WELL! // diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 66838978fc1..9e54c1986e7 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -73,6 +73,11 @@ public: { "setphaseshift", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SETPHASESHIFT, false, &HandleDebugSendSetPhaseShiftCommand, "" }, { "spellfail", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SPELLFAIL, false, &HandleDebugSendSpellFailCommand, "" }, }; + 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 = { { "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" }, @@ -108,6 +113,7 @@ public: { "neargraveyard", rbac::RBAC_PERM_COMMAND_NEARGRAVEYARD, false, &HandleDebugNearGraveyard, "" }, { "instancespawn", rbac::RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN, false, &HandleDebugInstanceSpawns, "" }, { "dummy", rbac::RBAC_PERM_COMMAND_DEBUG_DUMMY, false, &HandleDebugDummyCommand, "" }, + { "asan", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, nullptr, "", debugAsanCommandTable }, }; static std::vector<ChatCommand> commandTable = { @@ -1844,6 +1850,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."); |