Added new debugger logger
Added format errors Paused plugins now have their forwards blocked Fixed bug where pausing a plugin wouldnt make any effect --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40293
This commit is contained in:
parent
b50bb2bdca
commit
eea576cb52
6
TODO.txt
6
TODO.txt
@ -2,10 +2,10 @@ things to do for a release, in priority
|
|||||||
X finish plugin unloading
|
X finish plugin unloading
|
||||||
X URGENT: fix compiler's sizeof(), add cellsof
|
X URGENT: fix compiler's sizeof(), add cellsof
|
||||||
- do module api
|
- do module api
|
||||||
- finish plugin pausing/unpausing, forwards must block execution
|
X finish plugin pausing/unpausing, forwards must block execution
|
||||||
- do admin api
|
- do admin api
|
||||||
- add debugging output to logger
|
X add debugging output to logger
|
||||||
- finish ML api, expose through interface
|
- finish ML api, expose through interface
|
||||||
- add error messages to format routine
|
X add error messages to format routine
|
||||||
- finish global unloading
|
- finish global unloading
|
||||||
- add hex format specifier
|
- add hex format specifier
|
||||||
|
73
core/CDbgReporter.cpp
Normal file
73
core/CDbgReporter.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include "CDbgReporter.h"
|
||||||
|
#include "CLogger.h"
|
||||||
|
#include "PluginSys.h"
|
||||||
|
|
||||||
|
void CDbgReporter::OnSourceModAllInitialized()
|
||||||
|
{
|
||||||
|
g_pSourcePawn->SetDebugListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbgReporter::OnContextExecuteError(IPluginContext *ctx, IContextTrace *error)
|
||||||
|
{
|
||||||
|
const char *lastname;
|
||||||
|
const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename();
|
||||||
|
int n_err = error->GetErrorCode();
|
||||||
|
|
||||||
|
if (n_err != SP_ERROR_NATIVE)
|
||||||
|
{
|
||||||
|
g_Logger.LogError("[SOURCEMOD] Plugin \"%s\" encountered error %d: %s",
|
||||||
|
plname,
|
||||||
|
n_err,
|
||||||
|
error->GetErrorString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lastname=error->GetLastNative(NULL)) != NULL)
|
||||||
|
{
|
||||||
|
const char *custerr;
|
||||||
|
if ((custerr=error->GetCustomErrorString()) != NULL)
|
||||||
|
{
|
||||||
|
g_Logger.LogError("[SOURCEMOD] Native \"%s\" reported: \"%s\"", lastname, custerr);
|
||||||
|
} else {
|
||||||
|
g_Logger.LogError("[SOURCEMOD] Native \"%s\" encountered a generic error.", lastname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!error->DebugInfoAvailable())
|
||||||
|
{
|
||||||
|
g_Logger.LogError("[SOURCEMOD] Debug mode is not enabled for this plugin.");
|
||||||
|
g_Logger.LogError("[SOURCEMOD] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on",
|
||||||
|
_GetPluginIndex(ctx));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CallStackInfo stk_info;
|
||||||
|
int i = 0;
|
||||||
|
g_Logger.LogError("[SOURCEMOD] Displaying call stack trace:");
|
||||||
|
while (error->GetTraceInfo(&stk_info))
|
||||||
|
{
|
||||||
|
g_Logger.LogError("[SOURCEMOD] [%d] Line %d, %s::%s()",
|
||||||
|
i++,
|
||||||
|
stk_info.line,
|
||||||
|
stk_info.filename,
|
||||||
|
stk_info.function);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDbgReporter::_GetPluginIndex(IPluginContext *ctx)
|
||||||
|
{
|
||||||
|
int id = 1;
|
||||||
|
IPluginIterator *iter = g_PluginSys.GetPluginIterator();
|
||||||
|
|
||||||
|
for (; iter->MorePlugins(); iter->NextPlugin(), id++)
|
||||||
|
{
|
||||||
|
IPlugin *pl = iter->GetPlugin();
|
||||||
|
if (pl->GetBaseContext() == ctx)
|
||||||
|
{
|
||||||
|
iter->Release();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iter->Release();
|
||||||
|
return -1;
|
||||||
|
}
|
19
core/CDbgReporter.h
Normal file
19
core/CDbgReporter.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef _INCLUDE_SOURCEMOD_CDBGREPORTER_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_CDBGREPORTER_H_
|
||||||
|
|
||||||
|
#include "sp_vm_api.h"
|
||||||
|
#include "sm_globals.h"
|
||||||
|
|
||||||
|
class CDbgReporter :
|
||||||
|
public SMGlobalClass,
|
||||||
|
public IDebugListener
|
||||||
|
{
|
||||||
|
public: // SMGlobalClass
|
||||||
|
void OnSourceModAllInitialized();
|
||||||
|
public: // IDebugListener
|
||||||
|
void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error);
|
||||||
|
private:
|
||||||
|
int _GetPluginIndex(IPluginContext *ctx);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_CDBGREPORTER_H_
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8,00"
|
||||||
Name="sourcemod_mm"
|
Name="sourcemod_mm"
|
||||||
ProjectGUID="{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
|
ProjectGUID="{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
|
||||||
RootNamespace="sourcemod_mm"
|
RootNamespace="sourcemod_mm"
|
||||||
@ -179,6 +179,10 @@
|
|||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\CDbgReporter.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\CLogger.cpp"
|
RelativePath="..\CLogger.cpp"
|
||||||
>
|
>
|
||||||
@ -253,6 +257,10 @@
|
|||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\CDbgReporter.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\CLogger.h"
|
RelativePath="..\CLogger.h"
|
||||||
>
|
>
|
||||||
|
@ -2,20 +2,18 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
|
#include "CLogger.h"
|
||||||
|
|
||||||
#define LADJUST 0x00000004 /* left adjustment */
|
#define LADJUST 0x00000004 /* left adjustment */
|
||||||
#define ZEROPAD 0x00000080 /* zero (as opposed to blank) pad */
|
#define ZEROPAD 0x00000080 /* zero (as opposed to blank) pad */
|
||||||
#define to_digit(c) ((c) - '0')
|
#define to_digit(c) ((c) - '0')
|
||||||
#define is_digit(c) ((unsigned)to_digit(c) <= 9)
|
#define is_digit(c) ((unsigned)to_digit(c) <= 9)
|
||||||
|
|
||||||
//:TODO: fix this macro when we have a debugger
|
#define CHECK_ARGS(x) \
|
||||||
|
if ((arg+x) > args) { \
|
||||||
#define CHECK_ARGS(n)/* \
|
g_Logger.LogError("String formatted incorrectly - parameter %d (total %d)", arg, args); \
|
||||||
if ((arg+n) > args) { \
|
|
||||||
LogError(amx, AMX_ERR_PARAMS, "String formatted incorrectly - parameter %d (total %d)", arg, args); \
|
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//:TODO: review this code before we choose a license
|
//:TODO: review this code before we choose a license
|
||||||
|
|
||||||
@ -421,8 +419,7 @@ size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext
|
|||||||
}
|
}
|
||||||
|
|
||||||
int arg;
|
int arg;
|
||||||
//int args = params[0] / sizeof(cell); //:TODO: wrong, i think params[0] has now the param count not the byte count
|
int args = params[0];
|
||||||
// either way this is only used when the above macro is fixed, until then not needed
|
|
||||||
char *buf_p;
|
char *buf_p;
|
||||||
char ch;
|
char ch;
|
||||||
int flags;
|
int flags;
|
||||||
|
@ -255,6 +255,10 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
|
|||||||
for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
|
for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
|
||||||
{
|
{
|
||||||
func = (*iter);
|
func = (*iter);
|
||||||
|
if (func->GetParentPlugin()->GetStatus() == Plugin_Paused)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned int i=0; i<num_params; i++)
|
for (unsigned int i=0; i<num_params; i++)
|
||||||
{
|
{
|
||||||
|
@ -472,6 +472,8 @@ bool CPlugin::SetPauseState(bool paused)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_status = (paused) ? Plugin_Paused : Plugin_Running;
|
||||||
|
|
||||||
IPluginFunction *pFunction = GetFunctionByName("OnPluginPauseChange");
|
IPluginFunction *pFunction = GetFunctionByName("OnPluginPauseChange");
|
||||||
if (pFunction)
|
if (pFunction)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user