1.1 --- a/core/vm/sp_vm_basecontext.cpp Wed Aug 15 18:26:15 2007 +0000
1.2 +++ b/core/vm/sp_vm_basecontext.cpp Wed Aug 15 20:18:15 2007 +0000
1.3 @@ -39,6 +39,7 @@
1.4
1.5 #ifdef SOURCEMOD_BUILD
1.6 #include "Logger.h"
1.7 +#include "DebugReporter.h"
1.8 #endif
1.9
1.10 using namespace SourcePawn;
1.11 @@ -149,7 +150,7 @@
1.12 {
1.13 continue;
1.14 }
1.15 - m_pub_funcs[i]->Set(pub->code_offs, this);
1.16 + m_pub_funcs[i]->Set(pub->code_offs, this, pub->funcid);
1.17 }
1.18 }
1.19
1.20 @@ -221,6 +222,10 @@
1.21
1.22 IPluginDebugInfo *BaseContext::GetDebugInfo()
1.23 {
1.24 + if (!IsDebugging())
1.25 + {
1.26 + return NULL;
1.27 + }
1.28 return this;
1.29 }
1.30
1.31 @@ -243,7 +248,13 @@
1.32 uint32_t pushcount = ctx->pushcount;
1.33 int err;
1.34
1.35 - PushCell(pushcount++);
1.36 + if ((err = PushCell(pushcount++)) != SP_ERROR_NONE)
1.37 + {
1.38 +#if defined SOURCEMOD_BUILD
1.39 + g_DbgReporter.GenerateCodeError(this, code_addr, err, "Stack error; cannot complete execution!");
1.40 +#endif
1.41 + return SP_ERROR_NOT_RUNNABLE;
1.42 + }
1.43 ctx->pushcount = 0;
1.44
1.45 cell_t save_sp = ctx->sp;
1.46 @@ -271,26 +282,30 @@
1.47 */
1.48 g_SourcePawn.PopTracer(err, m_CustomMsg ? m_MsgCache : NULL);
1.49
1.50 -#if 1//defined _DEBUG
1.51 - //:TODO: debug code for leak detection, remove before the release?
1.52 +#if defined SOURCEMOD_BUILD
1.53 if (err == SP_ERROR_NONE)
1.54 {
1.55 if ((ctx->sp - (cell_t)(pushcount * sizeof(cell_t))) != save_sp)
1.56 {
1.57 - const char *name;
1.58 - ctx->context->GetDebugInfo()->LookupFunction(code_addr, &name);
1.59 - g_Logger.LogError("Stack leak detected: sp:%d should be %d on function %s", ctx->sp, save_sp, name);
1.60 + g_DbgReporter.GenerateCodeError(this,
1.61 + code_addr,
1.62 + SP_ERROR_STACKLEAK,
1.63 + "Stack leak detected: sp:%d should be %d!",
1.64 + ctx->sp,
1.65 + save_sp);
1.66 }
1.67 if (ctx->hp != save_hp)
1.68 {
1.69 - const char *name;
1.70 - ctx->context->GetDebugInfo()->LookupFunction(code_addr, &name);
1.71 - g_Logger.LogError("Heap leak detected: hp:%d should be %d on function %s", ctx->hp, save_hp, name);
1.72 + g_DbgReporter.GenerateCodeError(this,
1.73 + code_addr,
1.74 + SP_ERROR_HEAPLEAK,
1.75 + "Heap leak detected: sp:%d should be %d!",
1.76 + ctx->hp,
1.77 + save_hp);
1.78 }
1.79 - //assert(ctx->sp - pushcount * sizeof(cell_t) == save_sp);
1.80 - //assert(ctx->hp == save_hp);
1.81 }
1.82 #endif
1.83 +
1.84 if (err != SP_ERROR_NONE)
1.85 {
1.86 ctx->sp = save_sp;
1.87 @@ -958,10 +973,10 @@
1.88 pFunc = m_pub_funcs[func_id];
1.89 if (!pFunc)
1.90 {
1.91 - m_pub_funcs[func_id] = new CFunction(ctx->publics[func_id].code_offs, this);
1.92 + m_pub_funcs[func_id] = new CFunction(ctx->publics[func_id].code_offs, this, ctx->publics[func_id].funcid);
1.93 pFunc = m_pub_funcs[func_id];
1.94 } else if (pFunc->IsInvalidated()) {
1.95 - pFunc->Set(ctx->publics[func_id].code_offs, this);
1.96 + pFunc->Set(ctx->publics[func_id].code_offs, this, ctx->publics[func_id].funcid);
1.97 }
1.98 } else {
1.99 /* :TODO: currently not used */
1.100 @@ -1001,7 +1016,7 @@
1.101 GetPublicByIndex(index, &pub);
1.102 if (pub)
1.103 {
1.104 - m_pub_funcs[index] = new CFunction(pub->code_offs, this);
1.105 + m_pub_funcs[index] = new CFunction(pub->code_offs, this, pub->funcid);
1.106 }
1.107 pFunc = m_pub_funcs[index];
1.108 } else if (pFunc->IsInvalidated()) {
1.109 @@ -1009,7 +1024,7 @@
1.110 GetPublicByIndex(index, &pub);
1.111 if (pub)
1.112 {
1.113 - pFunc->Set(pub->code_offs, this);
1.114 + pFunc->Set(pub->code_offs, this, pub->funcid);
1.115 } else {
1.116 pFunc = NULL;
1.117 }