diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-01-09 19:44:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-09 19:44:10 +0100 |
commit | c037f6339f1fc9636b4fc9056ae0b2e2b673024d (patch) | |
tree | e483dac8a1c4ac409be699b23f49d5bebce95164 /core | |
parent | 958a15c7a7ddf7e4247ea73ce6cc2b63cd0c644b (diff) | |
parent | 1c6269f2dd3e1a46dbb6a36c3363c9c535be8b64 (diff) |
Merge pull request #15463 from neikeq/the-stack-frame-madness
Mono: Implement stack info for errors and exceptions
Diffstat (limited to 'core')
-rw-r--r-- | core/script_debugger_local.cpp | 5 | ||||
-rw-r--r-- | core/script_debugger_local.h | 1 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 83 | ||||
-rw-r--r-- | core/script_debugger_remote.h | 1 | ||||
-rw-r--r-- | core/script_language.h | 4 |
5 files changed, 51 insertions, 43 deletions
diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index 57463a662d..0da377453e 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -294,6 +294,11 @@ void ScriptDebuggerLocal::send_message(const String &p_message, const Array &p_a print_line("MESSAGE: '" + p_message + "' - " + String(Variant(p_args))); } +void ScriptDebuggerLocal::send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info) { + + print_line("ERROR: '" + (p_descr.empty() ? p_err : p_descr) + "'"); +} + ScriptDebuggerLocal::ScriptDebuggerLocal() { profiling = false; diff --git a/core/script_debugger_local.h b/core/script_debugger_local.h index c93120331d..c87bc90bb4 100644 --- a/core/script_debugger_local.h +++ b/core/script_debugger_local.h @@ -44,6 +44,7 @@ class ScriptDebuggerLocal : public ScriptDebugger { public: void debug(ScriptLanguage *p_script, bool p_can_continue); virtual void send_message(const String &p_message, const Array &p_args); + virtual void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info); virtual bool is_profiling() const { return profiling; } virtual void add_profiling_frame_data(const StringName &p_name, const Array &p_data) {} diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index e3dc8eb53a..a297bb738f 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -432,22 +432,6 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char if (p_type == ERR_HANDLER_SCRIPT) return; //ignore script errors, those go through debugger - ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)ud; - - OutputError oe; - oe.error = p_err; - oe.error_descr = p_descr; - oe.source_file = p_file; - oe.source_line = p_line; - oe.source_func = p_func; - oe.warning = p_type == ERR_HANDLER_WARNING; - uint64_t time = OS::get_singleton()->get_ticks_msec(); - oe.hr = time / 3600000; - oe.min = (time / 60000) % 60; - oe.sec = (time / 1000) % 60; - oe.msec = time % 1000; - Array cstack; - Vector<ScriptLanguage::StackInfo> si; for (int i = 0; i < ScriptServer::get_language_count(); i++) { @@ -456,32 +440,8 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char break; } - cstack.resize(si.size() * 2); - for (int i = 0; i < si.size(); i++) { - String path; - int line = 0; - if (si[i].script.is_valid()) { - path = si[i].script->get_path(); - line = si[i].line; - } - cstack[i * 2 + 0] = path; - cstack[i * 2 + 1] = line; - } - - oe.callstack = cstack; - - sdr->mutex->lock(); - - if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) { - - if (sdr->errors.size() >= sdr->max_errors_per_frame) { - sdr->n_errors_dropped++; - } else { - sdr->errors.push_back(oe); - } - } - - sdr->mutex->unlock(); + ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)ud; + sdr->send_error(p_func, p_file, p_line, p_err, p_descr, p_type, si); } bool ScriptDebuggerRemote::_parse_live_edit(const Array &p_command) { @@ -928,6 +888,45 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_ mutex->unlock(); } +void ScriptDebuggerRemote::send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info) { + + OutputError oe; + oe.error = p_err; + oe.error_descr = p_descr; + oe.source_file = p_file; + oe.source_line = p_line; + oe.source_func = p_func; + oe.warning = p_type == ERR_HANDLER_WARNING; + uint64_t time = OS::get_singleton()->get_ticks_msec(); + oe.hr = time / 3600000; + oe.min = (time / 60000) % 60; + oe.sec = (time / 1000) % 60; + oe.msec = time % 1000; + Array cstack; + + cstack.resize(p_stack_info.size() * 3); + for (int i = 0; i < p_stack_info.size(); i++) { + cstack[i * 3 + 0] = p_stack_info[i].file; + cstack[i * 3 + 1] = p_stack_info[i].func; + cstack[i * 3 + 2] = p_stack_info[i].line; + } + + oe.callstack = cstack; + + mutex->lock(); + + if (!locking && tcp_client->is_connected_to_host()) { + + if (errors.size() >= max_errors_per_frame) { + n_errors_dropped++; + } else { + errors.push_back(oe); + } + } + + mutex->unlock(); +} + void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) { ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this; diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 924d5de2c4..2c4e29f172 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -157,6 +157,7 @@ public: virtual void request_quit(); virtual void send_message(const String &p_message, const Array &p_args); + virtual void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info); virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata); virtual void set_live_edit_funcs(LiveEditFuncs *p_funcs); diff --git a/core/script_language.h b/core/script_language.h index 6bf2129f9b..66614a293c 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -254,7 +254,8 @@ public: virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) = 0; struct StackInfo { - Ref<Script> script; + String file; + String func; int line; }; @@ -391,6 +392,7 @@ public: ScriptLanguage *get_break_language() const; virtual void send_message(const String &p_message, const Array &p_args) = 0; + virtual void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info) = 0; virtual bool is_remote() const { return false; } virtual void request_quit() {} |