Add LogStackTrace Native (#684)#685
Add LogStackTrace Native (#684)#685KyleSanderson merged 1 commit intoalliedmodders:masterfrom Headline:sync-upstream
Conversation
KyleSanderson
left a comment
There was a problem hiding this comment.
I'm thankful this isn't actually RequestStackFrame, but RequestStackTrace. I think this would confuse the hell out of people if it was the former :-P
core/logic/smn_core.cpp
Outdated
| ke::Vector<ke::AString> arr; | ||
|
|
||
| IFrameIterator *it = pContext->CreateFrameIterator(); | ||
| arr = g_DbgReporter.GetStackTrace(it); |
There was a problem hiding this comment.
nit: initialization should begin here.
| IFrameIterator *it = pContext->CreateFrameIterator(); | ||
| arr = g_DbgReporter.GetStackTrace(it); | ||
| pContext->DestroyFrameIterator(it); | ||
|
|
There was a problem hiding this comment.
The plugin calling this native should be present in the output, similar to SetFailState.
core/logic/DebugReporter.h
Outdated
| void ReportError(const IErrorReport &report, IFrameIterator &iter); | ||
| void OnDebugSpew(const char *msg, ...); | ||
| public: | ||
| ke::Vector<ke::AString> GetStackTrace(IFrameIterator *iter); |
There was a problem hiding this comment.
nit: double space after the type.
core/logic/DebugReporter.cpp
Outdated
| ke::Vector<ke::AString> arr = GetStackTrace(&iter); | ||
| for (size_t i = 0; i < arr.length(); i++) | ||
| { | ||
| g_Logger.LogError(arr[i].chars()); |
There was a problem hiding this comment.
You're double formatting here, see Logger::LogError. Instead what you want to do is something like: g_Logger.LogError("%s", arr[i].chars());
core/logic/smn_core.cpp
Outdated
| g_Logger.LogError("[SM] Stack trace requested: %s", buffer); | ||
| for (size_t i = 0; i < arr.length(); i++) | ||
| { | ||
| g_Logger.LogError(arr[i].chars()); |
There was a problem hiding this comment.
ditto on the formatting issue.
core/logic/DebugReporter.cpp
Outdated
| if (!iter.Done()) | ||
| ke::Vector<ke::AString> DebugReport::GetStackTrace(IFrameIterator *iter) | ||
| { | ||
| char temp[1024]; |
There was a problem hiding this comment.
I forget if we have a mapper, but we're limiting our stack traces here to 1024 characters from previously 3072. I'm not sure if this is desired?
KyleSanderson
left a comment
There was a problem hiding this comment.
lgtm minus the nits (but they're nits); nice job.
core/logic/DebugReporter.cpp
Outdated
| } | ||
| } | ||
|
|
||
|
|
core/logic/smn_core.cpp
Outdated
| return 0; | ||
| } | ||
|
|
||
|
|
core/logic/smn_core.cpp
Outdated
| { | ||
| g_Logger.LogError("%s", arr[i].chars()); | ||
| } | ||
| } |
There was a problem hiding this comment.
This fails to build currently because there's a cell_t expected to be returned but this function returns nothing.
In order for this to be merged, this pr for sourcepawn must be merged.
Essentially this adds pull request adds LogStackTrace, which will serve as a debugging function that outputs a stack trace where the native is called, but does not halt execution. For more info: see #684
will output in errors