added amb256 - (nice number), profiler complete with gui to show files
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401914
This commit is contained in:
@@ -41,10 +41,10 @@
|
||||
#include "sp_vm_types.h"
|
||||
|
||||
/** SourcePawn Engine API Version */
|
||||
#define SOURCEPAWN_ENGINE_API_VERSION 2
|
||||
#define SOURCEPAWN_ENGINE_API_VERSION 3
|
||||
|
||||
/** SourcePawn VM API Version */
|
||||
#define SOURCEPAWN_VM_API_VERSION 5
|
||||
#define SOURCEPAWN_VM_API_VERSION 6
|
||||
|
||||
#if !defined SOURCEMOD_BUILD
|
||||
#define SOURCEMOD_BUILD
|
||||
@@ -688,6 +688,63 @@ namespace SourcePawn
|
||||
virtual void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Represents a code profiler for plugins.
|
||||
*/
|
||||
class IProfiler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Invoked by the JIT to notify that a native is being started.
|
||||
*
|
||||
* @param pContext Plugin context.
|
||||
* @param native Native information.
|
||||
*/
|
||||
virtual void OnNativeBegin(IPluginContext *pContext, sp_native_t *native) =0;
|
||||
|
||||
/**
|
||||
* @brief Invoked by the JIT to notify that the last native on the stack
|
||||
* is no longer being executed.
|
||||
*/
|
||||
virtual void OnNativeEnd() =0;
|
||||
|
||||
/**
|
||||
* @brief Invoked by the JIT to notify that a function call is starting.
|
||||
*
|
||||
* @param pContext Plugin context.
|
||||
* @param name Function name, or NULL if not known.
|
||||
* @param code_addr P-Code address.
|
||||
*/
|
||||
virtual void OnFunctionBegin(IPluginContext *pContext, const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Invoked by the JIT to notify that the last function call has
|
||||
* concluded. In the case of an error inside a function, this will not
|
||||
* be called. Instead, the VM will call OnCallbackEnd() and the profiler
|
||||
* stack must be unwound.
|
||||
*/
|
||||
virtual void OnFunctionEnd() =0;
|
||||
|
||||
/**
|
||||
* @brief Invoked by the VM to notify that a forward/callback is starting.
|
||||
*
|
||||
* @param pContext Plugin context.
|
||||
* @param pubfunc Public function information.
|
||||
* @return Unique number to pass to OnFunctionEnd().
|
||||
*/
|
||||
virtual int OnCallbackBegin(IPluginContext *pContext, sp_public_t *pubfunc) =0;
|
||||
|
||||
/**
|
||||
* @brief Invoked by the JIT to notify that a callback has ended.
|
||||
*
|
||||
* As noted in OnFunctionEnd(), this my be called with a misaligned
|
||||
* profiler stack. To correct this, the stack should be unwound
|
||||
* (discarding data as appropriate) to a matching serial number.
|
||||
*
|
||||
* @param serial Unique number from OnCallbackBegin().
|
||||
*/
|
||||
virtual void OnCallbackEnd(int serial) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Contains helper functions used by VMs and the host app
|
||||
|
||||
@@ -47,6 +47,13 @@ typedef uint32_t funcid_t; /**< Function index code */
|
||||
|
||||
#define SP_MAX_EXEC_PARAMS 32 /**< Maximum number of parameters in a function */
|
||||
|
||||
#define SP_JITCONF_DEBUG "debug" /**< Configuration option for debugging. */
|
||||
#define SP_JITCONF_PROFILE "profile" /**< Configuration option for profiling. */
|
||||
|
||||
#define SP_PROF_NATIVES (1<<0) /**< Profile natives. */
|
||||
#define SP_PROF_CALLBACKS (1<<1) /**< Profile callbacks. */
|
||||
#define SP_PROF_FUNCTIONS (1<<2) /**< Profile functions. */
|
||||
|
||||
/**
|
||||
* @brief Error codes for SourcePawn routines.
|
||||
*/
|
||||
@@ -139,6 +146,7 @@ namespace SourcePawn
|
||||
{
|
||||
class IPluginContext;
|
||||
class IVirtualMachine;
|
||||
class IProfiler;
|
||||
};
|
||||
|
||||
struct sp_context_s;
|
||||
@@ -285,6 +293,8 @@ typedef struct sp_context_s
|
||||
sp_debug_file_t *files; /**< Files */
|
||||
sp_debug_line_t *lines; /**< Lines */
|
||||
sp_debug_symbol_t *symbols; /**< Symbols */
|
||||
SourcePawn::IProfiler *profiler; /**< Pointer to IProfiler */
|
||||
uint32_t prof_flags; /**< Profiling flags */
|
||||
} sp_context_t;
|
||||
|
||||
#endif //_INCLUDE_SOURCEPAWN_VM_TYPES_H
|
||||
|
||||
Reference in New Issue
Block a user