Browse Source

Add support for Visual Leak Detector, since valgrind doesn't support MSVC

Michael Hansen 12 years ago
parent
commit
9f276e2c57
  1. 7
      CMakeLists.txt
  2. 4
      Sources/Plasma/Apps/plClient/CMakeLists.txt
  3. 4
      Sources/Plasma/Apps/plClient/winmain.cpp
  4. 4
      Sources/Plasma/Apps/plClientPatcher/CMakeLists.txt
  5. 24
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp
  6. 4
      Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt
  7. 4
      Sources/Plasma/Apps/plFileEncrypt/CMakeLists.txt
  8. 4
      Sources/Plasma/Apps/plFileSecure/CMakeLists.txt
  9. 4
      Sources/Plasma/Apps/plMD5/CMakeLists.txt
  10. 4
      Sources/Plasma/Apps/plPageInfo/CMakeLists.txt
  11. 4
      Sources/Plasma/Apps/plPythonPack/CMakeLists.txt
  12. 4
      Sources/Plasma/Apps/plSHA/CMakeLists.txt
  13. 4
      Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
  14. 7
      Sources/Plasma/Apps/plUruLauncher/Main.cpp
  15. 5
      Sources/Plasma/CoreLib/HeadSpin.h
  16. 5
      Sources/Plasma/CoreLib/hsThread_Win.cpp
  17. 1
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp
  18. 5
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceThread.cpp
  19. 3
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  20. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  21. 4
      Sources/Tools/MaxMain/CMakeLists.txt
  22. 4
      Sources/Tools/MaxPlasmaLights/CMakeLists.txt
  23. 4
      Sources/Tools/plFontConverter/CMakeLists.txt
  24. 4
      Sources/Tools/plLocalizationEditor/CMakeLists.txt
  25. 4
      Sources/Tools/plResBrowser/CMakeLists.txt
  26. 23
      cmake/FindVLD.cmake

7
CMakeLists.txt

@ -72,6 +72,13 @@ if(PLASMA_TARGETS STREQUAL "Ethereal")
add_definitions(-DSTREAM_LOGGER) add_definitions(-DSTREAM_LOGGER)
endif(PLASMA_TARGETS STREQUAL "Ethereal") endif(PLASMA_TARGETS STREQUAL "Ethereal")
option(USE_VLD "Build and link with Visual Leak Detector (MSVC only)" OFF)
if(USE_VLD)
add_definitions(-DUSE_VLD)
find_package(VLD REQUIRED)
include_directories(${VLD_INCLUDE_DIR})
endif(USE_VLD)
include(TestBigEndian) include(TestBigEndian)
test_big_endian(BIG_ENDIAN) test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN) if(BIG_ENDIAN)

4
Sources/Plasma/Apps/plClient/CMakeLists.txt

@ -178,6 +178,10 @@ if(Bink_SDK_AVAILABLE)
target_link_libraries(plClient ${Bink_LIBRARIES}) target_link_libraries(plClient ${Bink_LIBRARIES})
endif() endif()
if(USE_VLD)
target_link_libraries(plClient ${VLD_LIBRARY})
endif()
if (WIN32) if (WIN32)
target_link_libraries(plClient Rpcrt4) target_link_libraries(plClient Rpcrt4)
target_link_libraries(plClient Version) target_link_libraries(plClient Version)

4
Sources/Plasma/Apps/plClient/winmain.cpp

@ -945,6 +945,10 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *param)
void StatusCallback(void *param) void StatusCallback(void *param)
{ {
#ifdef USE_VLD
VLDEnable();
#endif
HWND hwnd = (HWND)param; HWND hwnd = (HWND)param;
const char *statusUrl = GetServerStatusUrl(); const char *statusUrl = GetServerStatusUrl();

4
Sources/Plasma/Apps/plClientPatcher/CMakeLists.txt

@ -20,5 +20,9 @@ set(plClientPatcher_SOURCES
add_library(plClientPatcher STATIC ${plClientPatcher_HEADERS} ${plClientPatcher_SOURCES}) add_library(plClientPatcher STATIC ${plClientPatcher_HEADERS} ${plClientPatcher_SOURCES})
target_link_libraries(plClientPatcher CoreLib plAudioCore plStatusLog) target_link_libraries(plClientPatcher CoreLib plAudioCore plStatusLog)
if(USE_VLD)
target_link_libraries(plClientPatcher ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${plClientPatcher_HEADERS}) source_group("Header Files" FILES ${plClientPatcher_HEADERS})
source_group("Source Files" FILES ${plClientPatcher_SOURCES}) source_group("Source Files" FILES ${plClientPatcher_SOURCES})

24
Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp

@ -264,6 +264,10 @@ static void NetErrorHandler (ENetProtocol protocol, ENetError error) {
/* /*
//============================================================================ //============================================================================
static void WaitUruExitProc (void * param) { static void WaitUruExitProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
WaitForSingleObject(s_pi.hProcess, INFINITE); WaitForSingleObject(s_pi.hProcess, INFINITE);
DWORD exitcode; DWORD exitcode;
@ -539,6 +543,10 @@ static void ProcessManifestEntry (void * param, ENetError error) {
//============================================================================ //============================================================================
static void ProcessManifest (void * param) { static void ProcessManifest (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
wchar_t basePath[MAX_PATH]; wchar_t basePath[MAX_PATH];
char path[MAX_PATH]; char path[MAX_PATH];
AtomicAdd(&s_perf[kPerfThreadTaskCount], 1); AtomicAdd(&s_perf[kPerfThreadTaskCount], 1);
@ -885,6 +893,10 @@ void ShutdownAsyncCore () {
//============================================================================ //============================================================================
// param = URU_PreparationRequest // param = URU_PreparationRequest
void UruPrepProc (void * param) { void UruPrepProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = true; s_running = true;
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
@ -952,6 +964,10 @@ void UruPrepProc (void * param) {
//============================================================================ //============================================================================
void PlayerStopProc (void * param) { void PlayerStopProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = false; s_running = false;
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
//TerminateProcess(s_pi.hProcess, kExitCodeTerminated); //TerminateProcess(s_pi.hProcess, kExitCodeTerminated);
@ -960,6 +976,10 @@ void PlayerStopProc (void * param) {
//============================================================================ //============================================================================
void PlayerTerminateProc (void * param) { void PlayerTerminateProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = false; s_running = false;
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
ShutdownAsyncCore(); ShutdownAsyncCore();
@ -968,6 +988,10 @@ void PlayerTerminateProc (void * param) {
//============================================================================ //============================================================================
void UruStartProc (void * param) { void UruStartProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
if(!s_running) if(!s_running)
return; return;

4
Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt

@ -15,6 +15,10 @@ target_link_libraries(plCrashHandler pfCrashHandler)
target_link_libraries(plCrashHandler plFile) target_link_libraries(plCrashHandler plFile)
target_link_libraries(plCrashHandler pnProduct) target_link_libraries(plCrashHandler pnProduct)
if(USE_VLD)
target_link_libraries(plCrashHandler ${VLD_LIBRARY})
endif()
# Platform specific libs # Platform specific libs
if(WIN32) if(WIN32)
target_link_libraries(plCrashHandler Dbghelp) target_link_libraries(plCrashHandler Dbghelp)

4
Sources/Plasma/Apps/plFileEncrypt/CMakeLists.txt

@ -14,4 +14,8 @@ set(plFileEncrypt_SOURCES
add_executable(plFileEncrypt ${plFileEncrypt_SOURCES}) add_executable(plFileEncrypt ${plFileEncrypt_SOURCES})
target_link_libraries(plFileEncrypt CoreLib pnProduct plFile) target_link_libraries(plFileEncrypt CoreLib pnProduct plFile)
if(USE_VLD)
target_link_libraries(plFileEncrypt ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFileEncrypt_SOURCES}) source_group("Source Files" FILES ${plFileEncrypt_SOURCES})

4
Sources/Plasma/Apps/plFileSecure/CMakeLists.txt

@ -14,4 +14,8 @@ set(plFileSecure_SOURCES
add_executable(plFileSecure ${plFileSecure_SOURCES}) add_executable(plFileSecure ${plFileSecure_SOURCES})
target_link_libraries(plFileSecure CoreLib pnProduct plFile) target_link_libraries(plFileSecure CoreLib pnProduct plFile)
if(USE_VLD)
target_link_libraries(plFileSecure ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFileSecure_SOURCES}) source_group("Source Files" FILES ${plFileSecure_SOURCES})

4
Sources/Plasma/Apps/plMD5/CMakeLists.txt

@ -16,4 +16,8 @@ add_executable(plMD5 ${plMD5_SOURCES})
target_link_libraries(plMD5 CoreLib pnUtils pnProduct pnEncryption) target_link_libraries(plMD5 CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plMD5 ${OPENSSL_LIBRARIES}) target_link_libraries(plMD5 ${OPENSSL_LIBRARIES})
if(USE_VLD)
target_link_libraries(plMD5 ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plMD5_SOURCES}) source_group("Source Files" FILES ${plMD5_SOURCES})

4
Sources/Plasma/Apps/plPageInfo/CMakeLists.txt

@ -15,4 +15,8 @@ set(plPageInfo_SOURCES
add_executable(plPageInfo ${plPageInfo_SOURCES}) add_executable(plPageInfo ${plPageInfo_SOURCES})
target_link_libraries(plPageInfo CoreLib pnProduct plResMgr plAudioCore) target_link_libraries(plPageInfo CoreLib pnProduct plResMgr plAudioCore)
if(USE_VLD)
target_link_libraries(plPageInfo ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plPageInfo_SOURCES}) source_group("Source Files" FILES ${plPageInfo_SOURCES})

4
Sources/Plasma/Apps/plPythonPack/CMakeLists.txt

@ -22,5 +22,9 @@ else()
target_link_libraries(plPythonPack ${PYTHON_LIBRARY}) target_link_libraries(plPythonPack ${PYTHON_LIBRARY})
endif() endif()
if(USE_VLD)
target_link_libraries(plPythonPack ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plPythonPack_SOURCES}) source_group("Source Files" FILES ${plPythonPack_SOURCES})
source_group("Header Files" FILES ${plPythonPack_HEADERS}) source_group("Header Files" FILES ${plPythonPack_HEADERS})

4
Sources/Plasma/Apps/plSHA/CMakeLists.txt

@ -16,4 +16,8 @@ add_executable(plSHA ${plSHA_SOURCES})
target_link_libraries(plSHA CoreLib pnUtils pnProduct pnEncryption) target_link_libraries(plSHA CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plSHA ${OPENSSL_LIBRARIES}) target_link_libraries(plSHA ${OPENSSL_LIBRARIES})
if(USE_VLD)
target_link_libraries(plSHA ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plSHA_SOURCES}) source_group("Source Files" FILES ${plSHA_SOURCES})

4
Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt

@ -65,6 +65,10 @@ target_link_libraries(plUruLauncher ws2_32)
target_link_libraries(plUruLauncher rpcrt4) target_link_libraries(plUruLauncher rpcrt4)
target_link_libraries(plUruLauncher comctl32) target_link_libraries(plUruLauncher comctl32)
if(USE_VLD)
target_link_libraries(plUruLauncher ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plUruLauncher_SOURCES}) source_group("Source Files" FILES ${plUruLauncher_SOURCES})
source_group("Header Files" FILES ${plUruLauncher_HEADERS}) source_group("Header Files" FILES ${plUruLauncher_HEADERS})
source_group("Resource Files" FILES ${plUruLauncher_RESOURCES}) source_group("Resource Files" FILES ${plUruLauncher_RESOURCES})

7
Sources/Plasma/Apps/plUruLauncher/Main.cpp

@ -431,6 +431,9 @@ BOOL CALLBACK SplashDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
//============================================================================ //============================================================================
static void WindowThreadProc(void *) { static void WindowThreadProc(void *) {
#ifdef USE_VLD
VLDEnable();
#endif
InitCommonControls(); InitCommonControls();
s_event = CreateEvent( s_event = CreateEvent(
@ -476,6 +479,10 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *)
//============================================================================ //============================================================================
static void StatusCallback(void *) static void StatusCallback(void *)
{ {
#ifdef USE_VLD
VLDEnable();
#endif
const char *serverUrl = GetServerStatusUrl(); const char *serverUrl = GetServerStatusUrl();
CURL * hCurl = curl_easy_init(); CURL * hCurl = curl_easy_init();

5
Sources/Plasma/CoreLib/HeadSpin.h

@ -81,6 +81,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
# endif # endif
# include <Windows.h> # include <Windows.h>
// This needs to be after #include <windows.h>, since it also includes windows.h
# ifdef USE_VLD
# include <vld.h>
# endif
// Just some fun typedefs... // Just some fun typedefs...
typedef HWND hsWindowHndl; typedef HWND hsWindowHndl;
typedef HINSTANCE hsWindowInst; typedef HINSTANCE hsWindowInst;

5
Sources/Plasma/CoreLib/hsThread_Win.cpp

@ -58,6 +58,11 @@ struct WinThreadParam
static unsigned int __stdcall gEntryPointBT(void* param) static unsigned int __stdcall gEntryPointBT(void* param)
{ {
#ifdef USE_VLD
// Needs to be enabled for each thread except the WinMain
VLDEnable();
#endif
WinThreadParam* wtp = (WinThreadParam*)param; WinThreadParam* wtp = (WinThreadParam*)param;
unsigned int result = wtp->fThread->Run(); unsigned int result = wtp->fThread->Run();
::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit ::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit

1
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp

@ -395,7 +395,6 @@ pfConsoleCmd::~pfConsoleCmd()
for( i = 0; i < fSigLabels.GetCount(); i++ ) for( i = 0; i < fSigLabels.GetCount(); i++ )
{ {
if( fSigLabels[ i ] != nil )
delete [] fSigLabels[ i ]; delete [] fSigLabels[ i ];
} }
Unregister(); Unregister();

5
Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceThread.cpp

@ -65,6 +65,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//=========================================================================== //===========================================================================
static unsigned CALLBACK CreateThreadProc (LPVOID param) { static unsigned CALLBACK CreateThreadProc (LPVOID param) {
#ifdef USE_VLD
VLDEnable();
#endif
PerfAddCounter(kAsyncPerfThreadsTotal, 1); PerfAddCounter(kAsyncPerfThreadsTotal, 1);
PerfAddCounter(kAsyncPerfThreadsCurr, 1); PerfAddCounter(kAsyncPerfThreadsCurr, 1);

3
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -598,11 +598,10 @@ static void INetCliAuthAgeRequestCallback (
s_age.ageVaultId = ageVaultId; s_age.ageVaultId = ageVaultId;
wchar_t ageInstIdStr[64]; wchar_t ageInstIdStr[64];
plString gameAddrStr = gameAddr.GetHostString();
LogMsg( LogMsg(
kLogPerf, kLogPerf,
L"Connecting to game server %s, ageInstId %s", L"Connecting to game server %s, ageInstId %s",
gameAddrStr.c_str(), gameAddr.GetHostString().ToWchar().GetData(),
GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr)) GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr))
); );
NetCliGameDisconnect(); NetCliGameDisconnect();

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -2196,9 +2196,7 @@ static bool Recv_ServerAddr (
s_active->token = msg.token; s_active->token = msg.token;
s_active->addr.SetHost(msg.srvAddr); s_active->addr.SetHost(msg.srvAddr);
plString logmsg = "SrvAuth addr: "; LogMsg(kLogPerf, "SrvAuth addr: %s", s_active->addr.GetHostString().c_str());
logmsg += s_active->addr.GetHostString();
LogMsg(kLogPerf, L"SrvAuth addr: %s", logmsg.c_str());
} }
} }
s_critsect.Leave(); s_critsect.Leave();

4
Sources/Tools/MaxMain/CMakeLists.txt

@ -202,6 +202,10 @@ if (WIN32)
target_link_libraries(MaxMain winmm) target_link_libraries(MaxMain winmm)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(MaxMain ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${MaxMain_HEADERS}) source_group("Header Files" FILES ${MaxMain_HEADERS})
source_group("Resource Files" FILES ${MaxMain_RESOURCES}) source_group("Resource Files" FILES ${MaxMain_RESOURCES})
source_group("Source Files" FILES ${MaxMain_SOURCES}) source_group("Source Files" FILES ${MaxMain_SOURCES})

4
Sources/Tools/MaxPlasmaLights/CMakeLists.txt

@ -130,6 +130,10 @@ if (WIN32)
target_link_libraries(MaxPlasmaLights Ws2_32) target_link_libraries(MaxPlasmaLights Ws2_32)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(MaxPlasmaLights ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${MaxPlasmaLights_HEADERS}) source_group("Header Files" FILES ${MaxPlasmaLights_HEADERS})
source_group("Resource Files" FILES ${MaxPlasmaLights_RESOURCES}) source_group("Resource Files" FILES ${MaxPlasmaLights_RESOURCES})
source_group("Source Files" FILES ${MaxPlasmaLights_SOURCES}) source_group("Source Files" FILES ${MaxPlasmaLights_SOURCES})

4
Sources/Tools/plFontConverter/CMakeLists.txt

@ -45,6 +45,10 @@ if (WIN32)
target_link_libraries(plFontConverter shlwapi) target_link_libraries(plFontConverter shlwapi)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(plFontConverter ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFontConverter_SOURCES}) source_group("Source Files" FILES ${plFontConverter_SOURCES})
source_group("Header Files" FILES ${plFontConverter_HEADERS}) source_group("Header Files" FILES ${plFontConverter_HEADERS})
source_group("Resource Files" FILES ${plFontConverter_RESOURCES}) source_group("Resource Files" FILES ${plFontConverter_RESOURCES})

4
Sources/Tools/plLocalizationEditor/CMakeLists.txt

@ -35,6 +35,10 @@ target_link_libraries(plLocalizationEditor pfLocalizationMgr)
target_link_libraries(plLocalizationEditor ${EXPAT_LIBRARY}) target_link_libraries(plLocalizationEditor ${EXPAT_LIBRARY})
target_link_libraries(plLocalizationEditor comctl32) target_link_libraries(plLocalizationEditor comctl32)
if(USE_VLD)
target_link_libraries(plLocalizationEditor ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plLocalizationEditor_SOURCES}) source_group("Source Files" FILES ${plLocalizationEditor_SOURCES})
source_group("Header Files" FILES ${plLocalizationEditor_HEADERS}) source_group("Header Files" FILES ${plLocalizationEditor_HEADERS})
source_group("Resource Files" FILES ${plLocalizationEditor_RESOURCES}) source_group("Resource Files" FILES ${plLocalizationEditor_RESOURCES})

4
Sources/Tools/plResBrowser/CMakeLists.txt

@ -62,6 +62,10 @@ if (WIN32)
target_link_libraries(plResBrowser shlwapi) target_link_libraries(plResBrowser shlwapi)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(plResBrowser ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plResBrowser_SOURCES}) source_group("Source Files" FILES ${plResBrowser_SOURCES})
source_group("Header Files" FILES ${plResBrowser_HEADERS}) source_group("Header Files" FILES ${plResBrowser_HEADERS})
source_group("Resource Files" FILES ${plResBrowser_RESOURCES}) source_group("Resource Files" FILES ${plResBrowser_RESOURCES})

23
cmake/FindVLD.cmake

@ -0,0 +1,23 @@
if(VLD_INCLUDE_DIR AND VLD_LIBRARY)
set(VLD_FIND_QUIETLY TRUE)
endif()
find_path(VLD_INCLUDE_DIR vld.h)
find_library(VLD_LIBRARY NAMES vld)
set(VLD_LIBRARIES ${VLD_LIBRARY})
if(VLD_INCLUDE_DIR AND VLD_LIBRARY)
set(VLD_FOUND TRUE)
endif()
if (VLD_FOUND)
if(NOT VLD_FIND_QUIETLY)
message(STATUS "Found Visual Leak Detector: ${VLD_INCLUDE_DIR}")
endif()
else()
if(VLD_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Visual Leak Detector")
endif()
endif()
Loading…
Cancel
Save