Skip to content

Commit

Permalink
Fix LogStackTrace Anomaly (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
Headline committed Jul 31, 2018
1 parent 255b932 commit 7068c3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/logic/smn_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,8 @@ static cell_t FrameIterator_GetFilePath(IPluginContext *pContext, const cell_t *
static cell_t LogStackTrace(IPluginContext *pContext, const cell_t *params)
{
char buffer[512];

g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1);

IFrameIterator *it = pContext->CreateFrameIterator();
ke::Vector<ke::AString> arr = g_DbgReporter.GetStackTrace(it);
pContext->DestroyFrameIterator(it);
Expand All @@ -951,7 +950,7 @@ static cell_t LogStackTrace(IPluginContext *pContext, const cell_t *params)

g_Logger.LogError("[SM] Stack trace requested: %s", buffer);
g_Logger.LogError("[SM] Called from: %s", pPlugin->GetFilename());
for (size_t i = 0; i < arr.length(); i)
for (size_t i = 0; i < arr.length(); ++i)
{
g_Logger.LogError("%s", arr[i].chars());
}
Expand Down
10 changes: 10 additions & 0 deletions plugins/include/sourcemod.inc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ native void SetFailState(const char[] string, any ...);
*/
native void ThrowError(const char[] fmt, any ...);

/**
* Logs a stack trace from the current function call. Code
* execution continues after the call
*
* @param fmt Format string to send with the stack trace.
* @param ... Format arguments.
* @error Always logs a stack trace.
*/
native void LogStackTrace(const char[] fmt, any ...);

/**
* Gets the system time as a unix timestamp.
*
Expand Down

0 comments on commit 7068c3e

Please sign in to comment.