mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Add support for Visual Leak Detector, since valgrind doesn't support MSVC
This commit is contained in:
@ -72,6 +72,13 @@ if(PLASMA_TARGETS STREQUAL "Ethereal")
|
||||
add_definitions(-DSTREAM_LOGGER)
|
||||
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)
|
||||
test_big_endian(BIG_ENDIAN)
|
||||
if(BIG_ENDIAN)
|
||||
|
@ -178,6 +178,10 @@ if(Bink_SDK_AVAILABLE)
|
||||
target_link_libraries(plClient ${Bink_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plClient ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(plClient Rpcrt4)
|
||||
target_link_libraries(plClient Version)
|
||||
|
@ -945,6 +945,10 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *param)
|
||||
|
||||
void StatusCallback(void *param)
|
||||
{
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
HWND hwnd = (HWND)param;
|
||||
|
||||
const char *statusUrl = GetServerStatusUrl();
|
||||
|
@ -20,5 +20,9 @@ set(plClientPatcher_SOURCES
|
||||
add_library(plClientPatcher STATIC ${plClientPatcher_HEADERS} ${plClientPatcher_SOURCES})
|
||||
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("Source Files" FILES ${plClientPatcher_SOURCES})
|
||||
|
@ -264,6 +264,10 @@ static void NetErrorHandler (ENetProtocol protocol, ENetError error) {
|
||||
/*
|
||||
//============================================================================
|
||||
static void WaitUruExitProc (void * param) {
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
plLauncherInfo *info = (plLauncherInfo *) param;
|
||||
WaitForSingleObject(s_pi.hProcess, INFINITE);
|
||||
DWORD exitcode;
|
||||
@ -539,6 +543,10 @@ static void ProcessManifestEntry (void * param, ENetError error) {
|
||||
|
||||
//============================================================================
|
||||
static void ProcessManifest (void * param) {
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
wchar_t basePath[MAX_PATH];
|
||||
char path[MAX_PATH];
|
||||
AtomicAdd(&s_perf[kPerfThreadTaskCount], 1);
|
||||
@ -885,6 +893,10 @@ void ShutdownAsyncCore () {
|
||||
//============================================================================
|
||||
// param = URU_PreparationRequest
|
||||
void UruPrepProc (void * param) {
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
s_running = true;
|
||||
|
||||
plLauncherInfo *info = (plLauncherInfo *) param;
|
||||
@ -952,6 +964,10 @@ void UruPrepProc (void * param) {
|
||||
|
||||
//============================================================================
|
||||
void PlayerStopProc (void * param) {
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
s_running = false;
|
||||
plLauncherInfo *info = (plLauncherInfo *) param;
|
||||
//TerminateProcess(s_pi.hProcess, kExitCodeTerminated);
|
||||
@ -960,6 +976,10 @@ void PlayerStopProc (void * param) {
|
||||
|
||||
//============================================================================
|
||||
void PlayerTerminateProc (void * param) {
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
s_running = false;
|
||||
plLauncherInfo *info = (plLauncherInfo *) param;
|
||||
ShutdownAsyncCore();
|
||||
@ -968,6 +988,10 @@ void PlayerTerminateProc (void * param) {
|
||||
|
||||
//============================================================================
|
||||
void UruStartProc (void * param) {
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
if(!s_running)
|
||||
return;
|
||||
|
||||
|
@ -15,7 +15,11 @@ target_link_libraries(plCrashHandler pfCrashHandler)
|
||||
target_link_libraries(plCrashHandler plFile)
|
||||
target_link_libraries(plCrashHandler pnProduct)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plCrashHandler ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Platform specific libs
|
||||
if(WIN32)
|
||||
target_link_libraries(plCrashHandler Dbghelp)
|
||||
target_link_libraries(plCrashHandler Dbghelp)
|
||||
endif(WIN32)
|
||||
|
@ -14,4 +14,8 @@ set(plFileEncrypt_SOURCES
|
||||
add_executable(plFileEncrypt ${plFileEncrypt_SOURCES})
|
||||
target_link_libraries(plFileEncrypt CoreLib pnProduct plFile)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plFileEncrypt ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plFileEncrypt_SOURCES})
|
||||
|
@ -14,4 +14,8 @@ set(plFileSecure_SOURCES
|
||||
add_executable(plFileSecure ${plFileSecure_SOURCES})
|
||||
target_link_libraries(plFileSecure CoreLib pnProduct plFile)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plFileSecure ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plFileSecure_SOURCES})
|
||||
|
@ -16,4 +16,8 @@ add_executable(plMD5 ${plMD5_SOURCES})
|
||||
target_link_libraries(plMD5 CoreLib pnUtils pnProduct pnEncryption)
|
||||
target_link_libraries(plMD5 ${OPENSSL_LIBRARIES})
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plMD5 ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plMD5_SOURCES})
|
||||
|
@ -15,4 +15,8 @@ set(plPageInfo_SOURCES
|
||||
add_executable(plPageInfo ${plPageInfo_SOURCES})
|
||||
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})
|
||||
|
@ -22,5 +22,9 @@ else()
|
||||
target_link_libraries(plPythonPack ${PYTHON_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plPythonPack ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plPythonPack_SOURCES})
|
||||
source_group("Header Files" FILES ${plPythonPack_HEADERS})
|
||||
|
@ -16,4 +16,8 @@ add_executable(plSHA ${plSHA_SOURCES})
|
||||
target_link_libraries(plSHA CoreLib pnUtils pnProduct pnEncryption)
|
||||
target_link_libraries(plSHA ${OPENSSL_LIBRARIES})
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plSHA ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plSHA_SOURCES})
|
||||
|
@ -65,6 +65,10 @@ target_link_libraries(plUruLauncher ws2_32)
|
||||
target_link_libraries(plUruLauncher rpcrt4)
|
||||
target_link_libraries(plUruLauncher comctl32)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plUruLauncher ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plUruLauncher_SOURCES})
|
||||
source_group("Header Files" FILES ${plUruLauncher_HEADERS})
|
||||
source_group("Resource Files" FILES ${plUruLauncher_RESOURCES})
|
||||
|
@ -431,6 +431,9 @@ BOOL CALLBACK SplashDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
|
||||
//============================================================================
|
||||
static void WindowThreadProc(void *) {
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
InitCommonControls();
|
||||
s_event = CreateEvent(
|
||||
@ -476,6 +479,10 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *)
|
||||
//============================================================================
|
||||
static void StatusCallback(void *)
|
||||
{
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
const char *serverUrl = GetServerStatusUrl();
|
||||
|
||||
CURL * hCurl = curl_easy_init();
|
||||
|
@ -81,6 +81,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
# endif
|
||||
# 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...
|
||||
typedef HWND hsWindowHndl;
|
||||
typedef HINSTANCE hsWindowInst;
|
||||
|
@ -58,6 +58,11 @@ struct WinThreadParam
|
||||
|
||||
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;
|
||||
unsigned int result = wtp->fThread->Run();
|
||||
::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit
|
||||
|
@ -395,8 +395,7 @@ pfConsoleCmd::~pfConsoleCmd()
|
||||
|
||||
for( i = 0; i < fSigLabels.GetCount(); i++ )
|
||||
{
|
||||
if( fSigLabels[ i ] != nil )
|
||||
delete [] fSigLabels[ i ];
|
||||
delete [] fSigLabels[ i ];
|
||||
}
|
||||
Unregister();
|
||||
|
||||
|
@ -65,6 +65,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//===========================================================================
|
||||
static unsigned CALLBACK CreateThreadProc (LPVOID param) {
|
||||
|
||||
#ifdef USE_VLD
|
||||
VLDEnable();
|
||||
#endif
|
||||
|
||||
PerfAddCounter(kAsyncPerfThreadsTotal, 1);
|
||||
PerfAddCounter(kAsyncPerfThreadsCurr, 1);
|
||||
|
||||
|
@ -598,11 +598,10 @@ static void INetCliAuthAgeRequestCallback (
|
||||
s_age.ageVaultId = ageVaultId;
|
||||
|
||||
wchar_t ageInstIdStr[64];
|
||||
plString gameAddrStr = gameAddr.GetHostString();
|
||||
LogMsg(
|
||||
kLogPerf,
|
||||
L"Connecting to game server %s, ageInstId %s",
|
||||
gameAddrStr.c_str(),
|
||||
gameAddr.GetHostString().ToWchar().GetData(),
|
||||
GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr))
|
||||
);
|
||||
NetCliGameDisconnect();
|
||||
|
@ -2196,9 +2196,7 @@ static bool Recv_ServerAddr (
|
||||
s_active->token = msg.token;
|
||||
s_active->addr.SetHost(msg.srvAddr);
|
||||
|
||||
plString logmsg = "SrvAuth addr: ";
|
||||
logmsg += s_active->addr.GetHostString();
|
||||
LogMsg(kLogPerf, L"SrvAuth addr: %s", logmsg.c_str());
|
||||
LogMsg(kLogPerf, "SrvAuth addr: %s", s_active->addr.GetHostString().c_str());
|
||||
}
|
||||
}
|
||||
s_critsect.Leave();
|
||||
|
@ -202,6 +202,10 @@ if (WIN32)
|
||||
target_link_libraries(MaxMain winmm)
|
||||
endif(WIN32)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(MaxMain ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Header Files" FILES ${MaxMain_HEADERS})
|
||||
source_group("Resource Files" FILES ${MaxMain_RESOURCES})
|
||||
source_group("Source Files" FILES ${MaxMain_SOURCES})
|
||||
|
@ -130,6 +130,10 @@ if (WIN32)
|
||||
target_link_libraries(MaxPlasmaLights Ws2_32)
|
||||
endif(WIN32)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(MaxPlasmaLights ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Header Files" FILES ${MaxPlasmaLights_HEADERS})
|
||||
source_group("Resource Files" FILES ${MaxPlasmaLights_RESOURCES})
|
||||
source_group("Source Files" FILES ${MaxPlasmaLights_SOURCES})
|
||||
|
@ -45,6 +45,10 @@ if (WIN32)
|
||||
target_link_libraries(plFontConverter shlwapi)
|
||||
endif(WIN32)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plFontConverter ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plFontConverter_SOURCES})
|
||||
source_group("Header Files" FILES ${plFontConverter_HEADERS})
|
||||
source_group("Resource Files" FILES ${plFontConverter_RESOURCES})
|
||||
|
@ -35,6 +35,10 @@ target_link_libraries(plLocalizationEditor pfLocalizationMgr)
|
||||
target_link_libraries(plLocalizationEditor ${EXPAT_LIBRARY})
|
||||
target_link_libraries(plLocalizationEditor comctl32)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plLocalizationEditor ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plLocalizationEditor_SOURCES})
|
||||
source_group("Header Files" FILES ${plLocalizationEditor_HEADERS})
|
||||
source_group("Resource Files" FILES ${plLocalizationEditor_RESOURCES})
|
||||
|
@ -58,10 +58,14 @@ if (WIN32)
|
||||
target_link_libraries(plResBrowser Ws2_32)
|
||||
target_link_libraries(plResBrowser winmm)
|
||||
target_link_libraries(plResBrowser strmiids)
|
||||
target_link_libraries(plResBrowser comctl32)
|
||||
target_link_libraries(plResBrowser shlwapi)
|
||||
target_link_libraries(plResBrowser comctl32)
|
||||
target_link_libraries(plResBrowser shlwapi)
|
||||
endif(WIN32)
|
||||
|
||||
if(USE_VLD)
|
||||
target_link_libraries(plResBrowser ${VLD_LIBRARY})
|
||||
endif()
|
||||
|
||||
source_group("Source Files" FILES ${plResBrowser_SOURCES})
|
||||
source_group("Header Files" FILES ${plResBrowser_HEADERS})
|
||||
source_group("Resource Files" FILES ${plResBrowser_RESOURCES})
|
||||
|
23
cmake/FindVLD.cmake
Normal file
23
cmake/FindVLD.cmake
Normal file
@ -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()
|
Reference in New Issue
Block a user