Merge pull request #36751 from Faless/debugger/threads_and_profilers

ScriptDebugger refactor, threading, profilers.
This commit is contained in:
Rémi Verschelde
2020-03-09 19:08:07 +01:00
committed by GitHub
65 changed files with 3161 additions and 2400 deletions
+7 -5
View File
@@ -33,6 +33,8 @@
#include <mono/metadata/threads.h>
#include <stdint.h>
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
#include "core/io/json.h"
#include "core/os/file_access.h"
#include "core/os/mutex.h"
@@ -1134,11 +1136,11 @@ void CSharpLanguage::thread_exit() {
bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const String &p_error) {
// Not a parser error in our case, but it's still used for other type of errors
if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_line = p_line;
_debug_parse_err_file = p_file;
_debug_error = p_error;
ScriptDebugger::get_singleton()->debug(this, false, true);
EngineDebugger::get_script_debugger()->debug(this, false, true);
return true;
} else {
return false;
@@ -1147,11 +1149,11 @@ bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const S
bool CSharpLanguage::debug_break(const String &p_error, bool p_allow_continue) {
if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_line = -1;
_debug_parse_err_file = "";
_debug_error = p_error;
ScriptDebugger::get_singleton()->debug(this, p_allow_continue);
EngineDebugger::get_script_debugger()->debug(this, p_allow_continue);
return true;
} else {
return false;
@@ -2998,7 +3000,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
if (native) {
String native_name = NATIVE_GDMONOCLASS_NAME(native);
if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) {
if (ScriptDebugger::get_singleton()) {
if (EngineDebugger::is_active()) {
CSharpLanguage::get_singleton()->debug_break_parse(get_path(), 0, "Script inherits from native type '" + native_name + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
}
ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + native_name +
+3 -2
View File
@@ -37,6 +37,7 @@
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/profiler.h>
#include "core/debugger/engine_debugger.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/os/os.h"
@@ -1183,8 +1184,8 @@ void GDMono::unhandled_exception_hook(MonoObject *p_exc, void *) {
#ifdef DEBUG_ENABLED
GDMonoUtils::debug_send_unhandled_exception_error((MonoException *)p_exc);
if (ScriptDebugger::get_singleton())
ScriptDebugger::get_singleton()->idle_poll();
if (EngineDebugger::is_active())
EngineDebugger::get_singleton()->poll_events(false);
#endif
exit(mono_environment_exitcode_get());
+5 -2
View File
@@ -38,6 +38,9 @@
#include "gd_mono_marshal.h"
#include "gd_mono_utils.h"
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
#include <mono/metadata/exception.h>
namespace GDMonoInternals {
@@ -120,8 +123,8 @@ void unhandled_exception(MonoException *p_exc) {
} else {
#ifdef DEBUG_ENABLED
GDMonoUtils::debug_send_unhandled_exception_error((MonoException *)p_exc);
if (ScriptDebugger::get_singleton())
ScriptDebugger::get_singleton()->idle_poll();
if (EngineDebugger::is_active())
EngineDebugger::get_singleton()->poll_events(false);
#endif
}
}
+5 -3
View File
@@ -32,6 +32,8 @@
#include <mono/metadata/exception.h>
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
#include "core/os/dir_access.h"
#include "core/os/mutex.h"
#include "core/os/os.h"
@@ -39,7 +41,7 @@
#include "core/reference.h"
#ifdef TOOLS_ENABLED
#include "editor/debugger/script_editor_debugger.h"
#include "editor/debugger/editor_debugger_node.h"
#endif
#include "../csharp_script.h"
@@ -351,7 +353,7 @@ void debug_print_unhandled_exception(MonoException *p_exc) {
void debug_send_unhandled_exception_error(MonoException *p_exc) {
#ifdef DEBUG_ENABLED
if (!ScriptDebugger::get_singleton()) {
if (!EngineDebugger::is_active()) {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
ERR_PRINT(GDMonoUtils::get_exception_name_and_message(p_exc));
@@ -410,7 +412,7 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) {
int line = si.size() ? si[0].line : __LINE__;
String error_msg = "Unhandled exception";
ScriptDebugger::get_singleton()->send_error(func, file, line, error_msg, exc_msg, ERR_HANDLER_ERROR, si);
EngineDebugger::get_script_debugger()->send_error(func, file, line, error_msg, exc_msg, ERR_HANDLER_ERROR, si);
#endif
}