core/vm/sp_vm_basecontext.cpp
changeset 762 e82fc0f89dc1
parent 696 d5cc8d0fa899
child 763 bb7c98076764
     1.1 --- a/core/vm/sp_vm_basecontext.cpp	Thu May 10 14:13:50 2007 +0000
     1.2 +++ b/core/vm/sp_vm_basecontext.cpp	Thu May 10 22:51:56 2007 +0000
     1.3 @@ -20,6 +20,10 @@
     1.4  #include "sp_vm_basecontext.h"
     1.5  #include "sp_vm_engine.h"
     1.6  
     1.7 +#ifdef SOURCEMOD_BUILD
     1.8 +#include "Logger.h"
     1.9 +#endif
    1.10 +
    1.11  using namespace SourcePawn;
    1.12  
    1.13  extern SourcePawnEngine g_SourcePawn;
    1.14 @@ -223,11 +227,24 @@
    1.15  	 */
    1.16  	g_SourcePawn.PopTracer(err, m_CustomMsg ? m_MsgCache : NULL);
    1.17  
    1.18 -#if defined _DEBUG
    1.19 +#if 1//defined _DEBUG
    1.20 +	//:TODO: debug code for leak detection, remove before the release?
    1.21  	if (err == SP_ERROR_NONE)
    1.22  	{
    1.23 -		assert(ctx->sp - pushcount * sizeof(cell_t) == save_sp);
    1.24 -		assert(ctx->hp == save_hp);
    1.25 +		if ((ctx->sp - pushcount * sizeof(cell_t)) != save_sp)
    1.26 +		{
    1.27 +			const char *name;
    1.28 +			ctx->context->GetDebugInfo()->LookupFunction(code_addr, &name);
    1.29 +			g_Logger.LogError("Stack leak detected: sp:%d should be %d on function %s", ctx->sp, save_sp, name);
    1.30 +		}
    1.31 +		if (ctx->hp != save_hp)
    1.32 +		{
    1.33 +			const char *name;
    1.34 +			ctx->context->GetDebugInfo()->LookupFunction(code_addr, &name);
    1.35 +			g_Logger.LogError("Heap leak detected: hp:%d should be %d on function %s", ctx->hp, save_hp, name);
    1.36 +		}
    1.37 +		//assert(ctx->sp - pushcount * sizeof(cell_t) == save_sp);
    1.38 +		//assert(ctx->hp == save_hp);
    1.39  	}
    1.40  #endif
    1.41  	if (err != SP_ERROR_NONE)