-
-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LogStackTrace Native (#684) #685
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: initialization should begin here.
core/logic/smn_core.cpp
Outdated
IFrameIterator *it = pContext->CreateFrameIterator(); | ||
arr = g_DbgReporter.GetStackTrace(it); | ||
pContext->DestroyFrameIterator(it); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin calling this native should be present in the output, similar to SetFailState.
core/logic/DebugReporter.h
Outdated
@@ -45,6 +47,7 @@ class DebugReport : | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm minus the nits (but they're nits); nice job.
core/logic/DebugReporter.cpp
Outdated
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: weird newline
core/logic/smn_core.cpp
Outdated
return 0; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto on weird newline
core/logic/smn_core.cpp
Outdated
{ | ||
g_Logger.LogError("%s", arr[i].chars()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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