3 * ================================================================
4 * SourcePawn (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ================================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #ifndef _INCLUDE_SOURCEPAWN_VM_ENGINE_H_
16 #define _INCLUDE_SOURCEPAWN_VM_ENGINE_H_
18 #include "sp_vm_api.h"
19 #include "sp_vm_function.h"
31 class CContextTrace : public IContextTrace
34 CContextTrace(TracedCall *pStart, int error, const char *msg, uint32_t native);
37 const char *GetErrorString();
38 bool DebugInfoAvailable();
39 const char *GetCustomErrorString();
40 bool GetTraceInfo(CallStackInfo *trace);
42 const char *GetLastNative(uint32_t *index);
47 TracedCall *m_pIterator;
51 class SourcePawnEngine : public ISourcePawnEngine
56 public: //ISourcePawnEngine
57 sp_plugin_t *LoadFromFilePointer(FILE *fp, int *err);
58 sp_plugin_t *LoadFromMemory(void *base, sp_plugin_t *plugin, int *err);
59 int FreeFromMemory(sp_plugin_t *plugin);
60 IPluginContext *CreateBaseContext(sp_context_t *ctx);
61 void FreeBaseContext(IPluginContext *ctx);
62 void *BaseAlloc(size_t size);
63 void BaseFree(void *memory);
64 void *ExecAlloc(size_t size);
65 void ExecFree(void *address);
66 IDebugListener *SetDebugListener(IDebugListener *pListener);
67 unsigned int GetContextCallCount();
68 public: //Debugger Stuff
70 * @brief Pushes a context onto the top of the call tracer.
72 * @param ctx Plugin context.
74 void PushTracer(sp_context_t *ctx);
77 * @brief Pops a plugin off the call tracer.
79 void PopTracer(int error, const char *msg);
82 * @brief Runs tracer from a debug break.
84 void RunTracer(sp_context_t *ctx, uint32_t frame, uint32_t codeip);
85 public: //Plugin function stuff
86 CFunction *GetFunctionFromPool(funcid_t f, IPluginContext *plugin);
87 void ReleaseFunctionToPool(CFunction *func);
89 TracedCall *MakeTracedCall(bool new_chain);
90 void FreeTracedCall(TracedCall *pCall);
92 IDebugListener *m_pDebugHook;
93 TracedCall *m_FreedCalls;
94 TracedCall *m_CallStack;
95 unsigned int m_CurChain;
96 //CFunction *m_pFreeFuncs;
99 #endif //_INCLUDE_SOURCEPAWN_VM_ENGINE_H_