[mono] get stacktraces for all inner exceptions

This commit is contained in:
Paul Joannon 2018-02-24 16:36:48 +01:00
parent bd3b958a25
commit 89af6c2cd7
No known key found for this signature in database
GPG key ID: 93604DC6128B663C

View file

@ -420,6 +420,15 @@ void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution) {
if (!ScriptDebugger::get_singleton())
return;
ScriptLanguage::StackInfo separator;
separator.file = "";
separator.func = "--- " + TTR("End of inner exception stack trace") + " ---";
separator.line = 0;
Vector<ScriptLanguage::StackInfo> si;
String exc_msg = "";
while (p_exc != NULL) {
GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace);
MonoObject *stack_trace = mono_object_new(mono_domain_get(), st_klass->get_mono_ptr());
@ -442,15 +451,25 @@ void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution) {
}
}
Vector<ScriptLanguage::StackInfo> si;
if (stack_trace != NULL && !p_recursion_caution)
si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace);
Vector<ScriptLanguage::StackInfo> _si;
if (stack_trace != NULL && !p_recursion_caution) {
_si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace);
for (int i = _si.size() - 1; i >= 0; i--)
si.insert(0, _si[i]);
}
exc_msg += (exc_msg.length() > 0 ? " ---> " : "") + GDMonoUtils::get_exception_name_and_message(p_exc);
GDMonoProperty *p_prop = GDMono::get_singleton()->get_class(mono_object_get_class(p_exc))->get_property("InnerException");
p_exc = p_prop != NULL ? p_prop->get_value(p_exc) : NULL;
if (p_exc != NULL)
si.insert(0, separator);
}
String file = si.size() ? si[0].file : __FILE__;
String func = si.size() ? si[0].func : FUNCTION_STR;
int line = si.size() ? si[0].line : __LINE__;
String error_msg = "Unhandled exception";
String exc_msg = GDMonoUtils::get_exception_name_and_message(p_exc);
ScriptDebugger::get_singleton()->send_error(func, file, line, error_msg, exc_msg, ERR_HANDLER_ERROR, si);
#endif