mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
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 71d15ea25b)
This commit is contained in:
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user